New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MachRegister::getReturnAddress not implemented on x86/x86_64 #40
Comments
Is this in a rewritten binary? There's a stepper in Dyninst itself that will handle this, but it depends on the mutator knowing where it's put things. Alternately, you can force the rewriter (or Dyninst in create/attach mode, for that matter) to emit stack frames (there's a BPatch flag for that). I should also note that the ARM-only interface there is deliberate. Unlike x86 (but like power) the ARM ABI has the RA living in a register after a call; unlike power, ARM will leave that register reserved until/unless it needs to spill it (e.g. for another call). What you want on x86 is to unwind in terms of stack pointer and frame pointer (if applicable). What we want to do during rewriting is augment the binary's unwind information so that it's straightforward to walk through non-standard frames, but that's a big project. |
I'm trying to support both run-time rewriting and rewritten binaries. |
I'm now calling setInstrStackFrames(true), but I'm still not getting the function names for runtime rewriting, and the rewritten binary is crashing with: Program received signal SIGSEGV, Segmentation fault. My code is at https://github.com/pefoley2/dynprof, fwiw. |
I got a stackwalker debug log and it looks like the addresses are somehow getting messed up. http://termbin.com/8beh |
Is there a way to get a valid RA on x86 so that i can lookup the function name? |
That's one of the points of the Dyninst internal instrumentation stepper. We don't actually preserve how we've relocated code when we rewrite. There should be symbols corresponding to the relocated function, though. And that RA looks quite likely to be somewhere in .dyninstInst (at a guess, the section starts at 0x50000000?) |
Ah, that makes sense. |
Statically, build a call graph. Dynamically, do stackwalking, but ideally on as unperturbed an application as possible. |
I guess the problem is most likely that I'm inserting multiple snippets at both the entry and exit points of each function in the program I'm instrumenting. What I'd like to be able to do is distinguish between a()->b() and c->b(), but it doesn't seem like the existing APIs let you climb out of a snippet in the called function to figure out what the original caller function was. |
If you only care about entry and exit, can you just instrument the call site? |
Yeah, I'm going to try that next. |
Alternately (and faster), your entry/exit snippets can store the current context in (possibly per-thread) mutatee-side data structures and build your calling context trees that way. Closing this as the discussion has gone far afield from the original issue, which I'm stamping "by design". |
I'm trying to manually create a Stackwalker::Frame object by passing in ra, sp and fp.
It appears that MachRegister::getReturnAddress is the best way to get the ra register, but it's not currently implemented on x86. Is there another way to get the necessary context to create a frame object?
For reference, I'm trying to get the parent function from within a snippet inserted at the entry point of the function I'm interested in. I tried using the Walker::walkStack api, but that doesn't seem to be able to properly walk back out of an snippet, so manually creating a Frame object based on BPatch_registerExpr values from the function the snippet is inserted into seems like the best approach.
https://github.com/dyninst/dyninst/blob/master/common/src/dyn_regs.C#L259
The text was updated successfully, but these errors were encountered: