1

I came across various Bytecode static instrumentation tools and frameworks for C#,JAVA (such as C#-Cecil,MBEL,RAIL. JAVA-Javassist,BCEL,reJ,Serp,JMangler). But did not find enough resources for C++.

I want to insert print statements which will print the methods's name itself to the console.

Are there tools or frameworks which will allow us to inject code to an C++ .so or .o files, or do a static binary instrumenation?

I came across tools like Dyninst,EEL,ERESI,PEBIL(for linux) but there are not enough resources which will show the correct implementation of static binary instrumentation.

Sharath
  • 39
  • 2
  • 1
    Asking for specific help about a specific tool is [on topic](https://stackoverflow.com/help/on-topic). Asking for recommendations is not. See [the software recommendations SE](https://softwarerecs.stackexchange.com/) instead. – Some programmer dude May 19 '21 at 08:48
  • 1
    There are a variety of techniques available to modify even binary and object files. Most of them are platform specific but are available for all major platforms more or less. Maybe, it's better to [edit] your question and give a specific use case of what you want to achieve (at best, with a [mcve]), and what constraints do you have to add/modify source code (which should be your first choice). – Scheff's Cat May 19 '21 at 08:48
  • C++ doesn't have reflection capabilities comparable to C#. Thus, function names are nothing you can rely on at run-time. (There might be appearances of them for platform-specific reasons like e.g. debug symbols or symbols for late linking but that's beyond the C++ standard.) The function name is available e.g. as `__FUNCTION__` or `__func__` (since C++20: `std::source_location::function_name`) but I'm not sure how anything of this can be found at runtime in the binary. (FYI: [SO: Is there a way to get function name inside a C++ function?](https://stackoverflow.com/q/733056/7478597)) – Scheff's Cat May 20 '21 at 11:05

0 Answers0