Add support for debugging ART to the dalvik.gdb script.

This adds two commands:

art-on
art-off

To the gdbclient script for debugging ART-based executables in gdb.
The default is 'art-on'

Bug: 17409881
Change-Id: I90a1aed603e50853a40d5f5ec1c9b168dc17ddc7
(cherry picked from commit 22382a4774)
This commit is contained in:
Dave Allison
2014-09-08 16:33:24 -07:00
committed by Dmitriy Ivanov
parent c13cf09c4c
commit 187be4adee

View File

@@ -49,3 +49,62 @@ document dbt
frame. If omitted r5 will be used as the default (as the case in the frame. If omitted r5 will be used as the default (as the case in the
interpreter and JIT'ed code). interpreter and JIT'ed code).
end end
# ART debugging. ART uses SIGSEGV signals for internal purposes. To allow
# gdb to debug programs using ART we need to treat this signal specially. We
# also set a breakpoint in a libart.so function to stop when the program
# hits an unexpected breakpoint
set $art_debug_enabled = 0
define art-on
if $art_debug_enabled == 0
# deal with SIGSEGV signals
handle SIGSEGV noprint nostop pass
# set a breakpoint and record its number
set breakpoint pending on
break art_sigsegv_fault
set $art_bpnum = $bpnum
commands $art_bpnum
silent
printf "Caught SIGSEGV in user program\n"
end
set breakpoint pending auto
printf "ART debugging mode is enabled.\n"
set $art_debug_enabled = 1
else
printf "ART debugging mode is already enabled.\n"
end
end
document art-on
Enter ART debugging mode. In ART debugging mode, SIGSEGV signals are ignored
by gdb unless they are not handled by ART itself. A breakpoint is
set to stop the program when an unexpected SIGSEGV signal is
encountered.
To switch ART debugging mode off, use "art-off"
end
define art-off
if $art_debug_enabled == 1
# restore SIGSEGV to its default
handle SIGSEGV print stop pass
# delete our breakpoint
delete $art_bpnum
set $art_debug_enabled = 0
printf "ART debugging mode is disabled.\n"
end
end
document art-off
Leave ART debugging mode. Signal handling is restored to default settings.
Use the command "art-on" to enable ART debugging mode.
end
# switch on ART debugging
art-on