MYST_RETAIN_SYMBOLS env var to retain symbols #1449
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Normally, when run under a debugger, Mystikos writes out each loaded shared library to /tmp/myst/ so that the debugger can load symbols from these libraries. At the end of the execution these files are deleted.
rr debugger allows
record and replay
debugging. You record a failure once, then debug the recording, deterministically, as many times as you want. The same execution is replayed every time. rr also provides efficient reverse execution under gdb. Set breakpoints and data watchpoints and quickly reverse-execute to where they were hit.At a very high-level, rr works by capuring all kernel interactions, including thread scheduling, and then re-applying all the interactions during playback. The playback is not a real-execution, and does not produce most side effects (e.g writing files, opening sockets etc).
Thus, during playback, the shared libraries necessay for the debugger are not written out. To make rr work for Mystikos, the symbol files need to be retained during execution. That is the purpose of the MYST_RETAIN_SYMBOLS flag.
Prerequisites:
Usage:
For a test, doing
make TARGET=linux
would print out the actual Mystikos command. ExecuteMYST_RETAIN_SYMBOLS=1 rr record <mystikos command>
to create a recording.E.g:
$ MYST_RETAIN_SYMBOLS=1 rr record myst exec-linux rootfs /bin/hello red green blue
rr: Saving execution to trace directory `/home/user/.local/share/rr/myst-35'.
Hello world!
I received: argv[0]={/bin/hello}, argv[1]={red}, argv[2]={green}, argv[3]={blue}
=== passed test (/bin/hello)
To replay and debug, do
rr replay -d /path/to/myst-gdb
E.g:$ rr replay -d ../../../build/bin/myst-gdb
GNU gdb (Ubuntu 11.1-0ubuntu2) 11.1
0x00007fe413b720d0 in _start () from /lib64/ld-linux-x86-64.so.2
(rr)
Most GDB commands are supported; but keep in mind that this is a replay, not an actual execution. It is like watching a video where you can easily skip forward and backward, but not actually waching something actually happen.
Put a breakpoint:
(rr) b main
Breakpoint 2 at 0x10000024e32: file host.c, line 527.
(rr) c
Continuing.
Breakpoint 2, main (argc=7, argv=0x7ffda41c9688, envp=0x7ffda41c96c8) at host.c:527
527 int ec = _main(argc, argv, envp);
(rr) c
Continuing.
oegdb: Loaded enclave module /home/anand/msft/mystikos/build/lib/libmystkernel.so
oegdb: analyzing symbols for module /home/anand/msft/mystikos/build/lib/libmystkernel.so
oegdb: Loaded enclave module ./.mystX68Tlv/libmystcrt
oegdb: analyzing symbols for module ./.mystX68Tlv/libmystcrt
oegdb: Loaded enclave module ./.mystX68Tlv/hello
oegdb: analyzing symbols for module ./.mystX68Tlv/hello
Breakpoint 2, main (argc=4, argv=0x7fe412cf2010) at hello.c:10
10 assert(argc == 4);
(rr)
Step over, debug as before.
(rr) n
11 assert(strcmp(argv[0], "/bin/hello") == 0);
(rr) n
12 assert(strcmp(argv[1], "red") == 0);
(rr) n
13 assert(strcmp(argv[2], "green") == 0);
(rr) n
14 assert(strcmp(argv[3], "blue") == 0);
Reverse execution works, but seems flaky. Needs more investigation.
Signed-off-by: Anand Krishnamoorthi anakrish@microsoft.com
Signed-off-by: Vikas Tikoo vikasamar@gmail.com