gm281 / lldb-trace

Gives complete trace of a function execution including all sub-calls.
107 stars 17 forks source link

Trace failing silently or with overflow errors #1

Open Qix- opened 7 years ago

Qix- commented 7 years ago

Trying to get this to work, and for some reason it's refusing to run.

(lldb) trace -f /tmp/TRACE2 -v
Traceback (most recent call last):
  File "/Users/junon/.lldb/ext/lldb-trace/trace.py", line 314, in trace
    parent_frame = thread.GetFrameAtIndex(frame.GetFrameID() + 1)
  File "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py", line 9508, in GetFrameAtIndex
    return _lldb.SBThread_GetFrameAtIndex(self, *args)
OverflowError: in method 'SBThread_GetFrameAtIndex', argument 2 of type 'uint32_t'

Sometimes it will fail silently and produce no output, too. Why would this be?

gm281 commented 7 years ago

Hi, I've just pushed couple of fixes + extra logging. It's unlikely that this will solve your problem though (different symptom).

Taking an educated guess, it looks like the stack trace of the target you're attached to at the time isn't valid (perhaps the target isn't even valid). What does: bt say?

Also, what are you trying to trace exactly? The trace script has limitations (any hand-crafted assembly is likely to break it :().

Qix- commented 7 years ago

There was no hand-crafted assembly (though I see why that would break it), and bt returned correct results. :/

saagarjha commented 6 years ago

Just a shot in the dark, but I was getting similar errors because I didn't read the instructions clearly enough. In particular:

Stop the process execution at the root function you're interested in tracing, e.g. using breakpoints.

Did you place a breakpoint at main, start the process, then try running trace; as opposed to say running it right after starting lldb?