mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-12 21:56:54 +00:00
container regex matching
This commit is contained in:
parent
abec0dcce6
commit
2dc5479c32
@ -72,6 +72,14 @@ std::unique_ptr<ContainerInfo> ContainerInfo::loadFromFile(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::regex matcher;
|
||||
if (std::optional<std::string> str =
|
||||
(*info)["matcher"].value<std::string>()) {
|
||||
matcher = std::regex(*str, std::regex_constants::grep);
|
||||
} else {
|
||||
matcher = std::regex("^" + typeName, std::regex_constants::grep);
|
||||
}
|
||||
|
||||
std::optional<size_t> numTemplateParams =
|
||||
(*info)["numTemplateParams"].value<size_t>();
|
||||
|
||||
@ -122,6 +130,7 @@ std::unique_ptr<ContainerInfo> ContainerInfo::loadFromFile(
|
||||
|
||||
return std::unique_ptr<ContainerInfo>(new ContainerInfo{
|
||||
std::move(typeName),
|
||||
std::move(matcher),
|
||||
numTemplateParams,
|
||||
ctype,
|
||||
std::move(header),
|
||||
|
@ -16,6 +16,7 @@
|
||||
#pragma once
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -73,6 +74,7 @@ const char *containerTypeEnumToStr(ContainerTypeEnum ty);
|
||||
|
||||
struct ContainerInfo {
|
||||
std::string typeName;
|
||||
std::regex matcher;
|
||||
std::optional<size_t> numTemplateParams;
|
||||
ContainerTypeEnum ctype = UNKNOWN_TYPE;
|
||||
std::string header;
|
||||
|
@ -166,20 +166,11 @@ std::optional<ContainerInfo> OICodeGen::getContainerInfo(
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string nameStr = std::string(*name);
|
||||
for (auto it = containerInfoList.rbegin(); it != containerInfoList.rend();
|
||||
it++) {
|
||||
const auto &info = *it;
|
||||
if (name->starts_with(info->typeName)) {
|
||||
// Blob must match exactly. Otherwise it also matches BlobsMap
|
||||
if (info->ctype == CAFFE2_BLOB_TYPE && *name != "caffe2::Blob") {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// IOBuf must also match exactly, or it also matches IOBufQueue
|
||||
if (info->ctype == FOLLY_IOBUF_TYPE && *name != "folly::IOBuf") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (std::regex_search(nameStr, info->matcher)) {
|
||||
return *info;
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
BOOST_CLASS_VERSION(Type, version)
|
||||
|
||||
DEFINE_TYPE_VERSION(PaddingInfo, 120, 3)
|
||||
DEFINE_TYPE_VERSION(ContainerInfo, 168, 4)
|
||||
DEFINE_TYPE_VERSION(ContainerInfo, 200, 5)
|
||||
DEFINE_TYPE_VERSION(struct drgn_location_description, 32, 2)
|
||||
DEFINE_TYPE_VERSION(struct drgn_object_locator, 72, 2)
|
||||
DEFINE_TYPE_VERSION(FuncDesc::Arg, 128, 2)
|
||||
|
@ -1,5 +1,6 @@
|
||||
[info]
|
||||
typeName = "caffe2::Blob"
|
||||
matcher = "^caffe2::Blob$"
|
||||
numTemplateParams = 0
|
||||
ctype = "CAFFE2_BLOB_TYPE"
|
||||
header = "caffe2/core/blob.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
[info]
|
||||
typeName = "folly::IOBufQueue"
|
||||
matcher = "^folly::IOBufQueue$"
|
||||
numTemplateParams = 0
|
||||
ctype = "FOLLY_IOBUFQUEUE_TYPE"
|
||||
header = "folly/io/IOBufQueue.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
[info]
|
||||
typeName = "folly::IOBuf"
|
||||
matcher = "^folly::IOBuf$"
|
||||
numTemplateParams = 0
|
||||
ctype = "FOLLY_IOBUF_TYPE"
|
||||
header = "folly/io/IOBuf.h"
|
||||
|
Loading…
Reference in New Issue
Block a user