diff --git a/.clang-format b/.clang-format index af103ec..0341afb 100644 --- a/.clang-format +++ b/.clang-format @@ -8,3 +8,4 @@ AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false DerivePointerAlignment: false PointerAlignment: Left +BinPackParameters: false diff --git a/examples/oil-metrics/Metrics.cpp b/examples/oil-metrics/Metrics.cpp index 5d7160e..cd4f258 100644 --- a/examples/oil-metrics/Metrics.cpp +++ b/examples/oil-metrics/Metrics.cpp @@ -54,7 +54,9 @@ void Metrics::save(std::string object) { } } -void Metrics::saveArg(const char* name, const char* argName, ArgTiming timing, +void Metrics::saveArg(const char* name, + const char* argName, + ArgTiming timing, size_t size) { std::string out = "{\"type\": \"size\", \"traceName\": \""; out += name; diff --git a/examples/oil-metrics/Metrics.h b/examples/oil-metrics/Metrics.h index 93be64d..f3f47b9 100644 --- a/examples/oil-metrics/Metrics.h +++ b/examples/oil-metrics/Metrics.h @@ -58,7 +58,9 @@ class Metrics { } static void save(std::string object); - static void saveArg(const char* name, const char* argName, ArgTiming timing, + static void saveArg(const char* name, + const char* argName, + ArgTiming timing, size_t size); static void saveDuration(const char* name, std::chrono::milliseconds duration); diff --git a/include/ObjectIntrospection.h b/include/ObjectIntrospection.h index 895e257..82cda95 100644 --- a/include/ObjectIntrospection.h +++ b/include/ObjectIntrospection.h @@ -145,8 +145,10 @@ class CodegenHandler { return lib->getObjectSize((void*)&objectAddr, objectSize); } - static int getObjectSize(const T& objectAddr, size_t& objectSize, - const options& opts, bool checkOptions = true) { + static int getObjectSize(const T& objectAddr, + size_t& objectSize, + const options& opts, + bool checkOptions = true) { OILibrary* lib; if (int responseCode = getLibrary(lib, opts, checkOptions); responseCode != Response::OIL_SUCCESS) { @@ -180,7 +182,8 @@ class CodegenHandler { return Response::OIL_SUCCESS; } - static int getLibrary(OILibrary*& result, const options& opts, + static int getLibrary(OILibrary*& result, + const options& opts, bool checkOptions) { std::atomic* curBoxedLib = getBoxedLib()->load(); @@ -224,7 +227,9 @@ class CodegenHandler { * Ahead-Of-Time (AOT) compilation. */ template -int getObjectSize(const T& objectAddr, size_t& objectSize, const options& opts, +int getObjectSize(const T& objectAddr, + size_t& objectSize, + const options& opts, bool checkOptions = true) { return CodegenHandler::getObjectSize(objectAddr, objectSize, opts, checkOptions); diff --git a/src/ContainerInfo.h b/src/ContainerInfo.h index 3294dbc..33c508a 100644 --- a/src/ContainerInfo.h +++ b/src/ContainerInfo.h @@ -36,9 +36,11 @@ struct ContainerInfo { ContainerInfo& operator=(const ContainerInfo& other) = delete; ContainerInfo() = default; - ContainerInfo(std::string typeName_, std::regex matcher_, + ContainerInfo(std::string typeName_, + std::regex matcher_, std::optional numTemplateParams_, - ContainerTypeEnum ctype_, std::string header_, + ContainerTypeEnum ctype_, + std::string header_, std::vector ns_, std::vector replaceTemplateParamIndex_, std::optional allocatorIndex_, diff --git a/src/DrgnUtils.cpp b/src/DrgnUtils.cpp index f3a331e..e22e30b 100644 --- a/src/DrgnUtils.cpp +++ b/src/DrgnUtils.cpp @@ -98,7 +98,8 @@ const char* symbol::name(drgn_symbol* sym) { namespace drgn_utils { -void getDrgnArrayElementType(drgn_type* type, drgn_type** outElemType, +void getDrgnArrayElementType(drgn_type* type, + drgn_type** outElemType, size_t& outNumElems) { size_t elems = 1; diff --git a/src/DrgnUtils.h b/src/DrgnUtils.h index f15a3d0..2e45ea1 100644 --- a/src/DrgnUtils.h +++ b/src/DrgnUtils.h @@ -137,7 +137,8 @@ namespace drgn_utils { * data can be moved here. */ -void getDrgnArrayElementType(drgn_type* type, drgn_type** outElemType, +void getDrgnArrayElementType(drgn_type* type, + drgn_type** outElemType, size_t& outNumElems); std::string typeToName(drgn_type* type); diff --git a/src/OICodeGen.cpp b/src/OICodeGen.cpp index 2fcd57b..a410365 100644 --- a/src/OICodeGen.cpp +++ b/src/OICodeGen.cpp @@ -330,7 +330,8 @@ std::string OICodeGen::stripFullyQualifiedNameWithSeparators( // Replace a specific template parameter with a generic DummySizedOperator void OICodeGen::replaceTemplateOperator( TemplateParamList& template_params, - std::vector& template_params_strings, size_t index) { + std::vector& template_params_strings, + size_t index) { if (index >= template_params.size()) { // Should this happen? return; @@ -365,7 +366,8 @@ void OICodeGen::replaceTemplateOperator( } void OICodeGen::replaceTemplateParameters( - drgn_type* type, TemplateParamList& template_params, + drgn_type* type, + TemplateParamList& template_params, std::vector& template_params_strings, const std::string& nameWithoutTemplate) { auto optContainerInfo = getContainerInfo(type); @@ -393,7 +395,8 @@ void OICodeGen::replaceTemplateParameters( } } -bool OICodeGen::buildName(drgn_type* type, std::string& text, +bool OICodeGen::buildName(drgn_type* type, + std::string& text, std::string& outName) { int ptrDepth = 0; drgn_type* ut = type; @@ -418,7 +421,8 @@ bool OICodeGen::buildName(drgn_type* type, std::string& text, return true; } -bool OICodeGen::buildNameInt(drgn_type* type, std::string& nameWithoutTemplate, +bool OICodeGen::buildNameInt(drgn_type* type, + std::string& nameWithoutTemplate, std::string& outName) { // Calling buildName only makes sense if a type is a container and has // template parameters. For a generic template class, we just flatten the @@ -588,7 +592,8 @@ bool OICodeGen::buildNameInt(drgn_type* type, std::string& nameWithoutTemplate, } bool OICodeGen::getTemplateParams( - drgn_type* type, size_t numTemplateParams, + drgn_type* type, + size_t numTemplateParams, std::vector>& v) { drgn_type_template_parameter* tParams = drgn_type_template_parameters(type); @@ -1662,8 +1667,10 @@ std::optional OICodeGen::getNameForType(drgn_type* type) { } void OICodeGen::getFuncDefClassMembers( - std::string& code, drgn_type* type, - std::unordered_map& memberNames, bool skipPadding) { + std::string& code, + drgn_type* type, + std::unordered_map& memberNames, + bool skipPadding) { if (drgn_type_kind(type) == DRGN_TYPE_TYPEDEF) { // Handle case where parent is a typedef getFuncDefClassMembers(code, drgnUnderlyingType(type), memberNames); @@ -1761,7 +1768,8 @@ void OICodeGen::enumerateDescendants(drgn_type* type, drgn_type* baseType) { } } -void OICodeGen::getFuncDefinitionStr(std::string& code, drgn_type* type, +void OICodeGen::getFuncDefinitionStr(std::string& code, + drgn_type* type, const std::string& typeName) { if (classMembersMap.find(type) == classMembersMap.end()) { return; @@ -2380,8 +2388,10 @@ bool OICodeGen::addPadding(uint64_t padding_bits, std::string& code) { return true; } -static inline void addSizeComment(bool genPaddingStats, std::string& code, - size_t offset, size_t sizeInBits) { +static inline void addSizeComment(bool genPaddingStats, + std::string& code, + size_t offset, + size_t sizeInBits) { if (!genPaddingStats) { return; } @@ -2417,8 +2427,10 @@ void OICodeGen::deduplicateMemberName( std::optional OICodeGen::generateMember( const DrgnClassMemberInfo& m, - std::unordered_map& memberNames, uint64_t currOffsetBits, - std::string& code, bool isInUnion) { + std::unordered_map& memberNames, + uint64_t currOffsetBits, + std::string& code, + bool isInUnion) { // Generate unique name for member std::string memberName = m.member_name; deduplicateMemberName(memberNames, memberName); @@ -2513,8 +2525,11 @@ std::optional OICodeGen::generateMember( } bool OICodeGen::generateParent( - drgn_type* p, std::unordered_map& memberNames, - uint64_t& currOffsetBits, std::string& code, size_t offsetToNextMember) { + drgn_type* p, + std::unordered_map& memberNames, + uint64_t& currOffsetBits, + std::string& code, + size_t offsetToNextMember) { // Parent class could be a typedef PaddingInfo paddingInfo{}; bool violatesAlignmentRequirement = false; @@ -2606,9 +2621,13 @@ std::optional OICodeGen::getAlignmentRequirements(drgn_type* e) { } bool OICodeGen::generateStructMembers( - drgn_type* e, std::unordered_map& memberNames, - std::string& code, uint64_t& out_offset_bits, PaddingInfo& paddingInfo, - bool& violatesAlignmentRequirement, size_t offsetToNextMemberInSubclass) { + drgn_type* e, + std::unordered_map& memberNames, + std::string& code, + uint64_t& out_offset_bits, + PaddingInfo& paddingInfo, + bool& violatesAlignmentRequirement, + size_t offsetToNextMemberInSubclass) { if (classMembersMap.find(e) == classMembersMap.end()) { VLOG(1) << "Failed to find type in classMembersMap: " << e; } @@ -3632,8 +3651,10 @@ bool OICodeGen::generate(std::string& code) { * Generate static_asserts for the offsets of each member of the given type */ bool OICodeGen::staticAssertMemberOffsets( - const std::string& struct_name, drgn_type* struct_type, - std::string& assert_str, std::unordered_map& memberNames, + const std::string& struct_name, + drgn_type* struct_type, + std::string& assert_str, + std::unordered_map& memberNames, uint64_t base_offset) { if (knownDummyTypeList.find(struct_type) != knownDummyTypeList.end()) { return true; diff --git a/src/OICodeGen.h b/src/OICodeGen.h index 7efb703..ae11df1 100644 --- a/src/OICodeGen.h +++ b/src/OICodeGen.h @@ -224,7 +224,8 @@ class OICodeGen { bool isKnownType(const std::string& type, std::string& matched); static bool getTemplateParams( - drgn_type* type, size_t numTemplateParams, + drgn_type* type, + size_t numTemplateParams, std::vector>& v); bool enumerateTemplateParamIdxs(drgn_type* type, @@ -233,7 +234,8 @@ class OICodeGen { bool& ifStub); bool getContainerTemplateParams(drgn_type* type, bool& ifStub); void enumerateDescendants(drgn_type* type, drgn_type* baseType); - void getFuncDefinitionStr(std::string& code, drgn_type* type, + void getFuncDefinitionStr(std::string& code, + drgn_type* type, const std::string& typeName); std::optional getDrgnTypeSize(drgn_type* type); @@ -251,19 +253,24 @@ class OICodeGen { std::optional generateMember( const DrgnClassMemberInfo& m, std::unordered_map& memberNames, - uint64_t currOffsetBits, std::string& code, bool isInUnion); + uint64_t currOffsetBits, + std::string& code, + bool isInUnion); bool generateParent(drgn_type* p, std::unordered_map& memberNames, - uint64_t& currOffsetBits, std::string& code, + uint64_t& currOffsetBits, + std::string& code, size_t offsetToNextMember); std::optional getAlignmentRequirements(drgn_type* e); bool generateStructMembers(drgn_type* e, std::unordered_map& memberNames, - std::string& code, uint64_t& out_offset_bits, + std::string& code, + uint64_t& out_offset_bits, PaddingInfo& paddingInfo, bool& violatesAlignmentRequirement, size_t offsetToNextMember); - void getFuncDefClassMembers(std::string& code, drgn_type* type, + void getFuncDefClassMembers(std::string& code, + drgn_type* type, std::unordered_map& memberNames, bool skipPadding = false); bool isDrgnSizeComplete(drgn_type* type); @@ -274,7 +281,8 @@ class OICodeGen { bool ifEnumerateClass(const std::string& typeName); bool enumerateClassParents(drgn_type* type, const std::string& typeName); - bool enumerateClassMembers(drgn_type* type, const std::string& typeName, + bool enumerateClassMembers(drgn_type* type, + const std::string& typeName, bool& isStubbed); bool enumerateClassTemplateParams(drgn_type* type, const std::string& typeName, @@ -308,17 +316,21 @@ class OICodeGen { void getClassMembersIncludingParent(drgn_type* type, std::vector& out); bool staticAssertMemberOffsets( - const std::string& struct_name, drgn_type* struct_type, + const std::string& struct_name, + drgn_type* struct_type, std::string& assert_str, std::unordered_map& member_names, uint64_t base_offset = 0); - bool addStaticAssertsForType(drgn_type* type, bool generateAssertsForOffsets, + bool addStaticAssertsForType(drgn_type* type, + bool generateAssertsForOffsets, std::string& code); - bool buildNameInt(drgn_type* type, std::string& nameWithoutTemplate, + bool buildNameInt(drgn_type* type, + std::string& nameWithoutTemplate, std::string& outName); void replaceTemplateOperator( std::vector>& template_params, - std::vector& template_params_strings, size_t index); + std::vector& template_params_strings, + size_t index); void replaceTemplateParameters( drgn_type* type, std::vector>& template_params, diff --git a/src/OICompiler.cpp b/src/OICompiler.cpp index 644ee91..59b357d 100644 --- a/src/OICompiler.cpp +++ b/src/OICompiler.cpp @@ -53,8 +53,10 @@ using namespace llvm::object; using namespace ObjectIntrospection; static const char* symbolLookupCallback( - [[maybe_unused]] void* disInfo, [[maybe_unused]] uint64_t referenceValue, - uint64_t* referenceType, [[maybe_unused]] uint64_t referencePC, + [[maybe_unused]] void* disInfo, + [[maybe_unused]] uint64_t referenceValue, + uint64_t* referenceType, + [[maybe_unused]] uint64_t referencePC, [[maybe_unused]] const char** referenceName) { *referenceType = LLVMDisassembler_ReferenceType_InOut_None; return nullptr; @@ -233,13 +235,15 @@ class OIMemoryManager : public RTDyldMemoryManager { bool needsToReserveAllocationSpace(void) override { return true; } - void reserveAllocationSpace(uintptr_t, uint32_t, uintptr_t, uint32_t, - uintptr_t, uint32_t) override; + void reserveAllocationSpace( + uintptr_t, uint32_t, uintptr_t, uint32_t, uintptr_t, uint32_t) override; - uint8_t* allocateCodeSection(uintptr_t, unsigned, unsigned, + uint8_t* allocateCodeSection(uintptr_t, + unsigned, + unsigned, StringRef) override; - uint8_t* allocateDataSection(uintptr_t, unsigned, unsigned, StringRef, - bool) override; + uint8_t* allocateDataSection( + uintptr_t, unsigned, unsigned, StringRef, bool) override; /* Hook to set up proper memory permission. We don't handle that */ bool finalizeMemory(std::string*) override { @@ -268,9 +272,12 @@ class OIMemoryManager : public RTDyldMemoryManager { } }; -void OIMemoryManager::reserveAllocationSpace( - uintptr_t codeSize, uint32_t codeAlign, uintptr_t roDataSize, - uint32_t roDataAlign, uintptr_t rwDataSize, uint32_t rwDataAlign) { +void OIMemoryManager::reserveAllocationSpace(uintptr_t codeSize, + uint32_t codeAlign, + uintptr_t roDataSize, + uint32_t roDataAlign, + uintptr_t rwDataSize, + uint32_t rwDataAlign) { /* * It looks like the sizes given to us already take into account the * alignment restrictions the different type of sections may have. Aligning @@ -294,7 +301,9 @@ void OIMemoryManager::reserveAllocationSpace( } uint8_t* OIMemoryManager::allocateCodeSection( - uintptr_t size, unsigned alignment, [[maybe_unused]] unsigned sectionID, + uintptr_t size, + unsigned alignment, + [[maybe_unused]] unsigned sectionID, StringRef sectionName) { VLOG(1) << "allocateCodeSection(Size = " << size << ", Alignment = " << alignment @@ -304,8 +313,11 @@ uint8_t* OIMemoryManager::allocateCodeSection( } uint8_t* OIMemoryManager::allocateDataSection( - uintptr_t size, unsigned alignment, [[maybe_unused]] unsigned sectionID, - StringRef sectionName, [[maybe_unused]] bool isReadOnly) { + uintptr_t size, + unsigned alignment, + [[maybe_unused]] unsigned sectionID, + StringRef sectionName, + [[maybe_unused]] bool isReadOnly) { VLOG(1) << "allocateDataSection(Size = " << size << ", Alignment = " << alignment << ", SectionName = " << sectionName.data() << ")"; @@ -451,7 +463,8 @@ static void debugDisAsm( } } -bool OICompiler::compile(const std::string& code, const fs::path& sourcePath, +bool OICompiler::compile(const std::string& code, + const fs::path& sourcePath, const fs::path& objectPath) { Metrics::Tracing _("compile"); @@ -554,7 +567,8 @@ bool OICompiler::compile(const std::string& code, const fs::path& sourcePath, } std::optional OICompiler::applyRelocs( - uintptr_t baseRelocAddress, const std::set& objectFiles, + uintptr_t baseRelocAddress, + const std::set& objectFiles, const std::unordered_map& syntheticSymbols) { Metrics::Tracing relocationTracing("relocation"); diff --git a/src/OICompiler.h b/src/OICompiler.h index bc23456..9883ea0 100644 --- a/src/OICompiler.h +++ b/src/OICompiler.h @@ -157,7 +157,8 @@ class OICompiler { * another call. */ std::optional applyRelocs( - uintptr_t, const std::set&, + uintptr_t, + const std::set&, const std::unordered_map&); /** diff --git a/src/OID.cpp b/src/OID.cpp index e1598e7..b10121c 100644 --- a/src/OID.cpp +++ b/src/OID.cpp @@ -282,8 +282,10 @@ struct Config { } // namespace Oid static ExitStatus::ExitStatus runScript( - const std::string& fileName, std::istream& script, - const Oid::Config& oidConfig, const OICodeGen::Config& codeGenConfig, + const std::string& fileName, + std::istream& script, + const Oid::Config& oidConfig, + const OICodeGen::Config& codeGenConfig, const OICompiler::Config& compilerConfig, const TreeBuilder::Config& tbConfig) { if (!fileName.empty()) { diff --git a/src/OIDebugger.cpp b/src/OIDebugger.cpp index 4a8f840..ab0448c 100644 --- a/src/OIDebugger.cpp +++ b/src/OIDebugger.cpp @@ -143,7 +143,8 @@ uint64_t OIDebugger::singlestepInst(pid_t pid, struct user_regs_struct& regs) { return regs.rip; } -void OIDebugger::dumpRegs(const char* text, pid_t pid, +void OIDebugger::dumpRegs(const char* text, + pid_t pid, struct user_regs_struct* regs) { VLOG(1) << "(" << text << ")" << " dumpRegs: pid: " << std::dec << pid << std::hex << " rip " @@ -457,7 +458,8 @@ bool OIDebugger::contTargetThread(bool detach) const { return true; } -bool OIDebugger::replayTrappedInstr(const trapInfo& t, pid_t pid, +bool OIDebugger::replayTrappedInstr(const trapInfo& t, + pid_t pid, struct user_regs_struct& regs, struct user_fpregs_struct& fpregs) const { /* @@ -558,7 +560,9 @@ bool OIDebugger::locateObjectsAddresses(const trapInfo& tInfo, } OIDebugger::processTrapRet OIDebugger::processFuncTrap( - const trapInfo& tInfo, pid_t pid, struct user_regs_struct& regs, + const trapInfo& tInfo, + pid_t pid, + struct user_regs_struct& regs, struct user_fpregs_struct& fpregs) { assert(tInfo.trapKind != OID_TRAP_JITCODERET); @@ -904,7 +908,8 @@ bool OIDebugger::canProcessTrapForThread(pid_t thread_pid) const { * (default) we wait for any thread to stop, if false we wait for the thread * specified by the first parameter 'pid' to stop. */ -OIDebugger::processTrapRet OIDebugger::processTrap(pid_t pid, bool blocking, +OIDebugger::processTrapRet OIDebugger::processTrap(pid_t pid, + bool blocking, bool anyPid) { int status = 0; pid_t newpid = 0; @@ -1868,7 +1873,8 @@ bool OIDebugger::removeTrap(pid_t pid, const trapInfo& t) { return true; } -OIDebugger::OIDebugger(OICodeGen::Config genConfig, OICompiler::Config ccConfig, +OIDebugger::OIDebugger(OICodeGen::Config genConfig, + OICompiler::Config ccConfig, TreeBuilder::Config tbConfig) : compilerConfig{std::move(ccConfig)}, generatorConfig{std::move(genConfig)}, @@ -1879,11 +1885,12 @@ OIDebugger::OIDebugger(OICodeGen::Config genConfig, OICompiler::Config ccConfig, VLOG(1) << "CodeGen config: " << generatorConfig.toString(); } -OIDebugger::OIDebugger(pid_t pid, OICodeGen::Config genConfig, +OIDebugger::OIDebugger(pid_t pid, + OICodeGen::Config genConfig, OICompiler::Config ccConfig, TreeBuilder::Config tbConfig) - : OIDebugger(std::move(genConfig), std::move(ccConfig), - std::move(tbConfig)) { + : OIDebugger( + std::move(genConfig), std::move(ccConfig), std::move(tbConfig)) { traceePid = pid; symbols = std::make_shared(traceePid); setDataSegmentSize(dataSegSize); @@ -1891,11 +1898,12 @@ OIDebugger::OIDebugger(pid_t pid, OICodeGen::Config genConfig, cache.symbols = symbols; } -OIDebugger::OIDebugger(fs::path debugInfo, OICodeGen::Config genConfig, +OIDebugger::OIDebugger(fs::path debugInfo, + OICodeGen::Config genConfig, OICompiler::Config ccConfig, TreeBuilder::Config tbConfig) - : OIDebugger(std::move(genConfig), std::move(ccConfig), - std::move(tbConfig)) { + : OIDebugger( + std::move(genConfig), std::move(ccConfig), std::move(tbConfig)) { symbols = std::make_shared(std::move(debugInfo)); cache.symbols = symbols; } @@ -1910,7 +1918,8 @@ OIDebugger::OIDebugger(fs::path debugInfo, OICodeGen::Config genConfig, * @param[in] target_addr - target address where new data are to be written * @param[in] bufsz - length of 'target_addr' buffer in bytes */ -bool OIDebugger::writeTargetMemory(void* local_buffer, void* target_addr, +bool OIDebugger::writeTargetMemory(void* local_buffer, + void* target_addr, size_t bufsz) const { VLOG(1) << "Writing buffer " << std::hex << local_buffer << ", bufsz " << std::dec << bufsz << " into target " << std::hex << target_addr; @@ -1953,7 +1962,8 @@ bool OIDebugger::writeTargetMemory(void* local_buffer, void* target_addr, * @param[in] local_addr - local address where new data are to be written * @param[in] bufsz - length of 'local_addr' buffer in bytes */ -bool OIDebugger::readTargetMemory(void* remote_buffer, void* local_addr, +bool OIDebugger::readTargetMemory(void* remote_buffer, + void* local_addr, size_t bufsz) const { VLOG(1) << "Reading buffer " << std::hex << remote_buffer << ", bufsz " << std::dec << bufsz << " into local " << std::hex << local_addr; diff --git a/src/OIDebugger.h b/src/OIDebugger.h index 13bace8..f6a750c 100644 --- a/src/OIDebugger.h +++ b/src/OIDebugger.h @@ -36,7 +36,9 @@ class OIDebugger { public: OIDebugger(pid_t, OICodeGen::Config, OICompiler::Config, TreeBuilder::Config); - OIDebugger(fs::path, OICodeGen::Config, OICompiler::Config, + OIDebugger(fs::path, + OICodeGen::Config, + OICompiler::Config, TreeBuilder::Config); bool segmentInit(void); @@ -186,8 +188,9 @@ class OIDebugger { std::unordered_map> threadTrapState; std::unordered_map replayInstMap; - std::unordered_map>> + std::unordered_map< + irequest, + std::tuple>> typeInfos; template @@ -217,10 +220,13 @@ class OIDebugger { const uint64_t); bool functionPatch(const prequest&); bool canProcessTrapForThread(pid_t) const; - bool replayTrappedInstr(const trapInfo&, pid_t, struct user_regs_struct&, + bool replayTrappedInstr(const trapInfo&, + pid_t, + struct user_regs_struct&, struct user_fpregs_struct&) const; bool locateObjectsAddresses(const trapInfo&, struct user_regs_struct&); - processTrapRet processFuncTrap(const trapInfo&, pid_t, + processTrapRet processFuncTrap(const trapInfo&, + pid_t, struct user_regs_struct&, struct user_fpregs_struct&); processTrapRet processJitCodeRet(const trapInfo&, pid_t); diff --git a/src/OIGenerator.h b/src/OIGenerator.h index 4575081..edb6286 100644 --- a/src/OIGenerator.h +++ b/src/OIGenerator.h @@ -55,8 +55,10 @@ class OIGenerator { std::filesystem::path generateForType( const OICodeGen::Config& generatorConfig, - const OICompiler::Config& compilerConfig, const drgn_qualified_type& type, - const std::string& linkageName, SymbolService& symbols); + const OICompiler::Config& compilerConfig, + const drgn_qualified_type& type, + const std::string& linkageName, + SymbolService& symbols); }; } // namespace ObjectIntrospection diff --git a/src/OIUtils.cpp b/src/OIUtils.cpp index 73df636..54fd545 100644 --- a/src/OIUtils.cpp +++ b/src/OIUtils.cpp @@ -32,8 +32,10 @@ using namespace ObjectIntrospection; using namespace std::literals; std::optional> processConfigFile( - const std::string& configFilePath, std::map featureMap, - OICompiler::Config& compilerConfig, OICodeGen::Config& generatorConfig) { + const std::string& configFilePath, + std::map featureMap, + OICompiler::Config& compilerConfig, + OICodeGen::Config& generatorConfig) { fs::path configDirectory = fs::path(configFilePath).remove_filename(); toml::table config; diff --git a/src/OIUtils.h b/src/OIUtils.h index 5759ff7..e5f8f27 100644 --- a/src/OIUtils.h +++ b/src/OIUtils.h @@ -25,7 +25,9 @@ namespace OIUtils { std::optional> processConfigFile( - const std::string& configFilePath, std::map featureMap, - OICompiler::Config& compilerConfig, OICodeGen::Config& generatorConfig); + const std::string& configFilePath, + std::map featureMap, + OICompiler::Config& compilerConfig, + OICodeGen::Config& generatorConfig); } // namespace OIUtils diff --git a/src/PaddingHunter.h b/src/PaddingHunter.h index 3c5baec..58a5054 100644 --- a/src/PaddingHunter.h +++ b/src/PaddingHunter.h @@ -21,8 +21,12 @@ struct PaddingInfo { public: PaddingInfo() = default; - PaddingInfo(size_t strSize, int saveSz, size_t paddSz, size_t issetSz, - std::string def, size_t instCnt) + PaddingInfo(size_t strSize, + int saveSz, + size_t paddSz, + size_t issetSz, + std::string def, + size_t instCnt) : structSize{strSize}, alignmentRequirement{8}, savingSize{static_cast(saveSz)}, diff --git a/src/Serialize.cpp b/src/Serialize.cpp index 8c75606..5535070 100644 --- a/src/Serialize.cpp +++ b/src/Serialize.cpp @@ -67,7 +67,8 @@ void serialize(Archive& ar, PaddingInfo& p, const unsigned int version) { INSTANCIATE_SERIALIZE(PaddingInfo) template -void serialize(Archive& ar, struct drgn_location_description& location, +void serialize(Archive& ar, + struct drgn_location_description& location, const unsigned int version) { verify_version(version); ar& location.start; @@ -86,7 +87,8 @@ void serialize(Archive& ar, struct drgn_location_description& location, INSTANCIATE_SERIALIZE(struct drgn_location_description) template -void serialize(Archive& ar, struct drgn_object_locator& locator, +void serialize(Archive& ar, + struct drgn_object_locator& locator, const unsigned int version) { verify_version(version); ar& locator.module_start; @@ -124,7 +126,8 @@ void serialize(Archive& ar, FuncDesc::Arg& arg, const unsigned int version) { INSTANCIATE_SERIALIZE(FuncDesc::Arg) template -void serialize(Archive& ar, FuncDesc::Retval& retval, +void serialize(Archive& ar, + FuncDesc::Retval& retval, const unsigned int version) { verify_version(version); ar& retval.typeName; @@ -134,7 +137,8 @@ void serialize(Archive& ar, FuncDesc::Retval& retval, INSTANCIATE_SERIALIZE(FuncDesc::Retval) template -void serialize(Archive& ar, FuncDesc::Range& range, +void serialize(Archive& ar, + FuncDesc::Range& range, const unsigned int version) { verify_version(version); ar& range.start; @@ -188,7 +192,8 @@ static void serialize_c_string(Archive& ar, char** string) { // what you're doing (or ask someone who does) before touching anything. // ########################################################################### template -void serialize(Archive& ar, struct drgn_type& type, +void serialize(Archive& ar, + struct drgn_type& type, const unsigned int version) { #define assert_in_same_union(member_1, member_2) \ do { \ @@ -307,7 +312,8 @@ void serialize(Archive& ar, struct drgn_type& type, INSTANCIATE_SERIALIZE(struct drgn_type) template -void serialize(Archive& ar, struct DrgnClassMemberInfo& m, +void serialize(Archive& ar, + struct DrgnClassMemberInfo& m, const unsigned int version) { verify_version(version); ar& m.type; @@ -319,7 +325,8 @@ void serialize(Archive& ar, struct DrgnClassMemberInfo& m, INSTANCIATE_SERIALIZE(DrgnClassMemberInfo) template -void serialize(Archive& ar, struct drgn_qualified_type& type, +void serialize(Archive& ar, + struct drgn_qualified_type& type, const unsigned int version) { verify_version(version); ar& type.type; @@ -338,7 +345,8 @@ void serialize(Archive& ar, RootInfo& rootInfo, const unsigned int version) { INSTANCIATE_SERIALIZE(RootInfo) template -void serialize(Archive& ar, struct TypeHierarchy& th, +void serialize(Archive& ar, + struct TypeHierarchy& th, const unsigned int version) { verify_version(version); ar& th.classMembersMap; diff --git a/src/SymbolService.cpp b/src/SymbolService.cpp index f89ff67..bd6e1c3 100644 --- a/src/SymbolService.cpp +++ b/src/SymbolService.cpp @@ -119,8 +119,11 @@ struct ModParams { * */ -static int moduleCallback(Dwfl_Module* mod, void** /* userData */, - const char* name, Dwarf_Addr /* start */, void* arg) { +static int moduleCallback(Dwfl_Module* mod, + void** /* userData */, + const char* name, + Dwarf_Addr /* start */, + void* arg) { ModParams* m = (ModParams*)arg; int nsym = dwfl_module_getsymtab(mod); @@ -296,8 +299,10 @@ static std::string bytesToHexString(const unsigned char* bytes, int nbbytes) { * to this callback. So we always return DWARF_CB_ABORT, as this is * the only build ID we are interested in. */ -static int buildIDCallback(Dwfl_Module* mod, void** /* userData */, - const char* name, Dwarf_Addr /* start */, +static int buildIDCallback(Dwfl_Module* mod, + void** /* userData */, + const char* name, + Dwarf_Addr /* start */, void* arg) { auto* buildID = static_cast*>(arg); @@ -430,8 +435,10 @@ struct drgn_program* SymbolService::getDrgnProgram() { * Although 'parseFormalParam' has an all-encompassing sounding name, its sole * task is to extract the location information for this parameter if any exist. */ -static void parseFormalParam(Dwarf_Die& param, struct drgn_module* module, - struct drgn_program* prog, Dwarf_Die& funcDie, +static void parseFormalParam(Dwarf_Die& param, + struct drgn_module* module, + struct drgn_program* prog, + Dwarf_Die& funcDie, std::shared_ptr& fd) { /* * NOTE: It is vital that the function descriptors list of arguments diff --git a/src/Syscall.h b/src/Syscall.h index 04202a0..521e5ec 100644 --- a/src/Syscall.h +++ b/src/Syscall.h @@ -43,7 +43,9 @@ struct StringLiteral { * know how to use the _Args to also statically check the type of the arguments. * In the meantime, I can use the size of _Args to do a simple count check. */ -template struct Syscall { /* User friendly syscall name */ diff --git a/src/TreeBuilder.cpp b/src/TreeBuilder.cpp index 44f2120..eabbb04 100644 --- a/src/TreeBuilder.cpp +++ b/src/TreeBuilder.cpp @@ -177,9 +177,19 @@ struct TreeBuilder::Node { */ size_t exclusiveSize{}; - MSGPACK_DEFINE_ARRAY(id, name, typeName, typePath, isTypedef, staticSize, - dynamicSize, paddingSavingsSize, containerStats, pointer, - children, isset, exclusiveSize) + MSGPACK_DEFINE_ARRAY(id, + name, + typeName, + typePath, + isTypedef, + staticSize, + dynamicSize, + paddingSavingsSize, + containerStats, + pointer, + children, + isset, + exclusiveSize) }; TreeBuilder::~TreeBuilder() { @@ -214,7 +224,8 @@ bool TreeBuilder::emptyOutput() const { } void TreeBuilder::build(const std::vector& data, - const std::string& argName, struct drgn_type* type, + const std::string& argName, + struct drgn_type* type, const TypeHierarchy& typeHierarchy) { th = &typeHierarchy; oidData = &data; @@ -385,7 +396,8 @@ static std::string_view drgnKindStr(struct drgn_type* type) { return kind; } -void TreeBuilder::setSize(TreeBuilder::Node& node, uint64_t dynamicSize, +void TreeBuilder::setSize(TreeBuilder::Node& node, + uint64_t dynamicSize, uint64_t memberSizes) { node.dynamicSize = dynamicSize; if (memberSizes > node.staticSize + node.dynamicSize) { diff --git a/src/TreeBuilder.h b/src/TreeBuilder.h index a27fd82..1702ac6 100644 --- a/src/TreeBuilder.h +++ b/src/TreeBuilder.h @@ -50,8 +50,10 @@ class TreeBuilder { TreeBuilder(Config); ~TreeBuilder(); - void build(const std::vector&, const std::string&, - struct drgn_type*, const TypeHierarchy&); + void build(const std::vector&, + const std::string&, + struct drgn_type*, + const TypeHierarchy&); void dumpJson(); void setPaddedStructs(std::map* paddedStructs); bool emptyOutput() const; @@ -114,6 +116,7 @@ class TreeBuilder { std::string_view serialize(const T&); void JSON(NodeID id, std::ofstream& output); - static void setSize(TreeBuilder::Node& node, uint64_t dynamicSize, + static void setSize(TreeBuilder::Node& node, + uint64_t dynamicSize, uint64_t memberSizes); }; diff --git a/test/integration/runner_common.cpp b/test/integration/runner_common.cpp index a10a728..3f94aac 100644 --- a/test/integration/runner_common.cpp +++ b/test/integration/runner_common.cpp @@ -295,7 +295,8 @@ OidProc OidIntegration::runOidOnProcess(OidOpts opts, void OidIntegration::compare_json(const bpt::ptree& expected_json, const bpt::ptree& actual_json, - const std::string& full_key, bool expect_eq) { + const std::string& full_key, + bool expect_eq) { if (expected_json.empty()) { if (expect_eq) { ASSERT_EQ(expected_json.data(), actual_json.data()) @@ -358,7 +359,8 @@ std::string OilIntegration::TmpDirStr() { return std::string("/tmp/oil-integration-XXXXXX"); } -Proc OilIntegration::runOilTarget(OidOpts opts, std::string configPrefix, +Proc OilIntegration::runOilTarget(OidOpts opts, + std::string configPrefix, std::string configSuffix) { fs::path thisConfig = createCustomConfig(configPrefix, configSuffix); diff --git a/test/integration/runner_common.h b/test/integration/runner_common.h index cd38a99..6dd5c0e 100644 --- a/test/integration/runner_common.h +++ b/test/integration/runner_common.h @@ -51,8 +51,10 @@ class OidIntegration : public IntegrationBase { protected: std::string TmpDirStr() override; - OidProc runOidOnProcess(OidOpts opts, std::vector extra_args, - std::string configPrefix, std::string configSuffix); + OidProc runOidOnProcess(OidOpts opts, + std::vector extra_args, + std::string configPrefix, + std::string configSuffix); /* * compare_json @@ -70,6 +72,7 @@ class OilIntegration : public IntegrationBase { protected: std::string TmpDirStr() override; - Proc runOilTarget(OidOpts opts, std::string configPrefix, + Proc runOilTarget(OidOpts opts, + std::string configPrefix, std::string configSuffix); }; diff --git a/test/test_parser.cpp b/test/test_parser.cpp index d9bf935..4a2e419 100644 --- a/test/test_parser.cpp +++ b/test/test_parser.cpp @@ -34,7 +34,8 @@ static std::string parseBadString(const std::string& script) { return testing::internal::GetCapturedStderr(); } -static void EXPECT_REQ_EQ(const prequest& req, const std::string& type, +static void EXPECT_REQ_EQ(const prequest& req, + const std::string& type, const std::string& func, const std::vector& args) { EXPECT_EQ(req.type, type);