-
Notifications
You must be signed in to change notification settings - Fork 573
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
i#2414 drcallstack: Add libunwind-based callstack walking #5154
Conversation
Adds a new extension "drcallstack" which provides callstack walking facilities. This initial implementation adds a libunwind-based implementation and targets only Linux for now. Adds an interface to walk one step at a time over callstack frames. The implementation converts the dr_mcontext_t into libunwind's context structure and invokes the libunwind step API. Getting libunwind to work requires several steps: + Ignore libpthread exports when importing any symbol that does not start with "pthread". Otherwise libunwind crashes using __errno_location from libpthread instead of from libc. We add a warning when a private libpthread is loaded to help diagnose any other potential problems (xref #956). + Have dl_iterate_phdr operate on app libraries instead of private libraries. This is done with a new flag and logic in the redirection code, with the flag set for libraries named "libunwind*". A statically-linked libunwind is not supported. Updates drwrap to set the mcontext pc field to simplify usage. Adds a test and documentation. Adds a sample client showing how to use this library. Issue: #2414, #956
…for CI but not cross-compile; fixes for ARM and AArch64 (gested natively on both now)
…ing; allow host-not-target to not have libunwind.h
Hmm, it can't find the Also, we have a packaging problem: there is no libunwind-dev package for cross-compiling, but that's how we make our aarchxx packages. Bundling our own libunwind.h is a possibility; it's not a simple header though, with many macros and sub-headers and arch-specific content. |
Note that here I'm assuming libunwind:i386 is there and we just need the header.
Here we need the header and the actual library so we would need to package the library up. It has a favorable license for that so that is a possible solution. Unfortunately we want a shared library to get the right isolation; though maybe a static library linked into drcallstack would work out. |
…5152) This patch replaces the install(CODE) commands that generate files on the fly. Instead, the files are generated at configuration time and just copied at install time. By that, install relocation via various strategies like DESTDIR and CPack works correctly. Further, this gets rid of a lot of complex escaping and makes the results more predictable. When appending to cmake-generated files, we also ensure that the file is cleared on a re-configuration run to avoid duplicates in the file. This patch enables a user to install multiple DynamoRIO versions simultaneously and to switch between them by using tools like xstow. It also helps as a preparation to package DynamoRIO for Linux distributions like Debian. Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> Issue: #5153
…iles; add drcallstack-test to list of works-on-QEMU
… looking at the files
Well this x86-32 is a nightmare: GA CI is using https://packages.microsoft.com/ubuntu/20.04/prod instead of http://us.archive.ubuntu.com/ubuntu, and the microsoft one doesn't have i386 packages! I tried installing the other standard repo but it gives weird dependency errors as though something is messed up in its dep engine...considering a hacky manual install. |
…in some ld.so callstacks on 32-bit Ubuntu
PTAL at the workflow changes especially. The 32-bit one is very frustrating that we have to go those lengths just to installed libunwind-dev:i386 on their setup (vanilla Ubuntu installs fine w/ the default repos). |
Adds a new extension "drcallstack" which provides callstack walking
facilities. This initial implementation adds a libunwind-based
implementation and targets only Linux for now.
Adds an interface to walk one step at a time over callstack frames.
The implementation converts the dr_mcontext_t into libunwind's context
structure and invokes the libunwind step API.
Getting libunwind to work requires several steps:
Ignore libpthread exports when importing any symbol that does not start with
"pthread". Otherwise libunwind crashes using __errno_location from libpthread
instead of from libc. We add a warning when a private libpthread is loaded
to help diagnose any other potential problems (xref CRASH using libpthread in a client #956).
Have dl_iterate_phdr operate on app libraries instead of private libraries.
This is done with a new flag and logic in the redirection code, with the
flag set for libraries named "libunwind*".
A statically-linked libunwind is not supported.
Updates drwrap to set the mcontext pc field to simplify usage.
Adds a test and documentation.
Adds a sample client showing how to use this library.
Issue: #2414, #956