(If you fclose(3) rather than pclose(3) a FILE* you got from popen(3),
future popen(3)s fail obscurely, at least on Mac OS.)
(cherry picked from commit 2bf76e143da933184d1392fb9bea3a3896c37e76)
Change-Id: I5578fe06753061b0dbc5ee951ebf31eb2bab0389
This might not seem like much, but it's already better than Mac OS'
backtrace(3).
(cherry picked from commit 2a46f6293f19b9d6100187fbd53088088e671b88)
Change-Id: I197b06c4c19f728ad6f194b2f473bd9dcd99b8a6
Backtracing through eh_frame section is more effective allowing to reuse
ebp register for other purposes within routine. GCC with turned on
optimizations (-O1 and above) implicitly defines -fomit-frame-pointer
anyway. eh_frame sections are generated by default with GCC on any
optimization level.
This change implements remote unwinding (separate process unwinding).
Local unwinding is already implemented through _Unwind_Backtrace call
which is implemented in libgcc.
Change-Id: I1aea1ecd19c21710f9cf5f05dc272fc51b67b7aa
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
-Werror is used for this project so these warnings were causing the
clang build to fail.
Change-Id: I18c447ce239645e05f59c3cf0e2b8bb17d9d3030
Author: Edwin Vane <edwin.vane@intel.com>
Reviewed-by: Tarea A Siraj <tareq.a.siraj@intel.com>
This is a forward-compatibility patch used to avoid two problems:
1/ The C library <signal.h> is going to be updated to define 'struct sigcontext'
properly soon. Avoid redefining this structure here when it's not really needed
to prevent a type conflict.
2/ Similarly, proper ucontext_t support is going to be added, prevent conflict by
using a macro renaming trick. Mainly because there is a slight chance that the
C library definition will follow a slightly different layout/naming.
For context, see details at:
http://code.google.com/p/android/issues/detail?id=34784https://android-review.googlesource.com/#/c/38875/1
Change-Id: Ie94eb5d77297f8e0bafd146b65a648bd8805a551
Longer term, we might want to offer <ucontext.h> and have that be like glibc's,
but not today. (Note that POSIX says nothing about mcontext_t and glibc,
Mac OS, and the Linux kernel headers are all mutually incompatible.)
Change-Id: Ia074b51f4567cd54e06bbe29721389c8d1278614
Show the symbol offset, when available.
Centralized formatting of native stack traces in libcorkscrew.
It's handy for automated tools if all stacks look the same.
Since we already made them all look them same, we might as well
do the formatting in just one place.
Do not strip the Thumb bit on ARM. This fixes an off-by-one
issue that could happen when resolving a PC that was at the
very beginning of a Thumb function, since the symbol table would
have the Thumb bit set but since we stripped the bit from our
PC, we would be looking for an address one byte before the
one listed in the symbol table. It's also quite useful to see
whether a given function is executing in Thumb mode just by glancing
at the PC.
Change-Id: Icaa29add85ce0bcafe24d5ce2098e138d809e2ab
Use the alternate stack specified by sigaltstack (if there is one).
Use tgkill instead of kill to ensure that we send the signal to
precisely the right thread.
Added timeout logic.
Change-Id: I72922137d1bc0c8becff98244926bde09fe3990e
1. X86 target will also have name demangling feature.
2. Remove dependency on libiberty.so, since it will not come
with prebuilt toolchain in gcc-4.6 and after.
Change-Id: Iefbb021c5c3171b9467954eafa54046ad6805753
Keep track of whether memory maps are readable. Use the information
in try_get_word to try to avoid accidentally dereferencing an invalid
pointer within the current process. (Note that I haven't ever
seen that happen during normal unwinding, but it pays to be
a little more careful.)
Refactored try_get_word a little to make it easier to pass it the
needed state for validation checks by way of a little memory_t struct.
Improved how the memory map for the current process is cached. This is
important because we need up to date information about readable maps.
Use a 5 second cache expiration.
Improved the PC -> LR fallback logic in the unwinder so we can
eke out an extra frame sometimes.
Fixed a bug reading ELF program headers. The phnum & phentsize
fields are half-words. We were incorrectly interpreting
phnum as a whole word.
Used android_atomic_* operations carefully in the unwinder
to prevent possible memory races between the dumper and the dumpee.
This was highly unlikely (or even impossible due to the presence
of other barriers along the way) but the code is clearer now about
its invariants.
Fixed a bug in debuggerd where the pid was being passed to have
its stack dump taken instead of the tid, resulting in short
stacks because ptrace couldn't read the data if pid != tid.
Did a full sweep to ensure that we use pid / tid correctly everywhere.
Ported old code from debuggerd to rewind the program counter back
one instruction so that it points to the branch instruction itself
instead of the return address.
Change-Id: Icc4eb08320052975a4ae7f0f5f0ac9308a2d33d7
This change modifies debuggerd so that it can be used to grab
the native stacks of a process that has hung and not just crashed.
Note that only the root user can do this (for now).
adb shell debuggerd <tid>
Then use logcat to find the tombstone file that was generated
which will have the native stacks of all threads in the
requested process. The specified thread will be shown first
and will also appear in the main log.
Also made some minor tweaks to libcorkscrew so that we
could handle statically compiled executables in the future
if we compiled the library statically.
Improved the "wait_for_user_action" function to support
volume down as an alternative for devices that do not
have home keys.
Removed a mess of gotos.
Change-Id: Ic149653986b0c2f503c7f0e8b7cb1f3be7c84d1e
Supports collecting the stack trace of the current thread,
another thread in the same process, or a thread in a
different process (using ptrace).
Change-Id: Ica2594e4436edde4ceb7bcc3d78e6c31a7902cbf