Extend test gdb.python/py-recurse-unwind.exp
This patch modifies the unwinder (sniffer) defined in py-recurse-unwind.py so that, depending upon the value of one of its class variables, it will take different paths through the code, testing different functionality. The original test attempted to obtain the value of an undefined symbol. This somewhat expanded test checks to see if 'pc' can be read via gdb.PendingFrame.read_register() and also via gdb.parse_and_eval(). gdb/testsuite/ChangeLog: * gdb.python/py-recurse-unwind.c (main): Add loop. * gdb.python/py-recurse-unwind.py (TestUnwinder): Add calls to read_register() and gdb.parse_and_eval(). Make each code call a separate case that can be individually tested. * gdb.python/py-recurse-unwind.exp (cont_and_backtrace): New proc. Call cont_and_backtrace for each of the code paths that we want to test in the unwinder.
This commit is contained in:
parent
4cb771f214
commit
1a2f3d7ff1
4 changed files with 76 additions and 26 deletions
|
@ -1,3 +1,13 @@
|
|||
2016-11-16 Kevin Buettner <kevinb@redhat.com>
|
||||
|
||||
* gdb.python/py-recurse-unwind.c (main): Add loop.
|
||||
* gdb.python/py-recurse-unwind.py (TestUnwinder): Add calls
|
||||
to read_register() and gdb.parse_and_eval(). Make each code
|
||||
call a separate case that can be individually tested.
|
||||
* gdb.python/py-recurse-unwind.exp (cont_and_backtrace): New
|
||||
proc. Call cont_and_backtrace for each of the code paths that
|
||||
we want to test in the unwinder.
|
||||
|
||||
2016-11-15 Andreas Arnez <arnez@linux.vnet.ibm.com>
|
||||
|
||||
* gdb.dwarf2/bitfield-parent-optimized-out.exp: Fix DWARF code for
|
||||
|
|
|
@ -37,6 +37,10 @@ aaa (int arg)
|
|||
int
|
||||
main ()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
aaa (123);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -45,13 +45,23 @@ if ![runto_main] then {
|
|||
return 0
|
||||
}
|
||||
|
||||
|
||||
proc cont_and_backtrace { tst } {
|
||||
|
||||
with_test_prefix $tst {
|
||||
gdb_breakpoint "ccc"
|
||||
|
||||
gdb_continue_to_breakpoint "ccc"
|
||||
# We're testing different code paths within the unwinder's sniffer.
|
||||
# Set the current path to be tested here.
|
||||
gdb_test_no_output "python TestUnwinder.set_test(\"$tst\")" \
|
||||
"set code path within python unwinder to $tst"
|
||||
|
||||
# If the unwinder is active, the usage count will increment while
|
||||
# running to the breakpoint. Reset it prior to doing the backtrace.
|
||||
gdb_test_no_output "python TestUnwinder.reset_count()"
|
||||
gdb_test_no_output "python TestUnwinder.reset_count()" \
|
||||
"reset count"
|
||||
|
||||
gdb_continue_to_breakpoint "ccc"
|
||||
|
||||
# The python based unwinder should be called a number of times while
|
||||
# generating the backtrace, but its sniffer always returns None. So
|
||||
|
@ -70,4 +80,11 @@ gdb_test_sequence "bt" "backtrace" {
|
|||
|
||||
# Test that the python-based unwinder / sniffer was actually called
|
||||
# during generation of the backtrace.
|
||||
gdb_test "python print(TestUnwinder.count > 0)" "True"
|
||||
gdb_test "python print(TestUnwinder.count > 0)" "True" \
|
||||
"python unwinder called"
|
||||
}
|
||||
}
|
||||
|
||||
cont_and_backtrace "check_undefined_symbol"
|
||||
cont_and_backtrace "check_user_reg_pc"
|
||||
cont_and_backtrace "check_pae_pc"
|
||||
|
|
|
@ -40,13 +40,18 @@ class TestUnwinder(Unwinder):
|
|||
def inc_count (cls):
|
||||
cls.count += 1
|
||||
|
||||
test = 'check_undefined_symbol'
|
||||
|
||||
@classmethod
|
||||
def set_test (cls, test) :
|
||||
cls.test = test
|
||||
|
||||
def __init__(self):
|
||||
Unwinder.__init__(self, "test unwinder")
|
||||
self.recurse_level = 0
|
||||
|
||||
def __call__(self, pending_frame):
|
||||
|
||||
|
||||
if self.recurse_level > 0:
|
||||
gdb.write("TestUnwinder: Recursion detected - returning early.\n")
|
||||
return None
|
||||
|
@ -54,6 +59,20 @@ class TestUnwinder(Unwinder):
|
|||
self.recurse_level += 1
|
||||
TestUnwinder.inc_count()
|
||||
|
||||
if TestUnwinder.test == 'check_user_reg_pc' :
|
||||
|
||||
pc = pending_frame.read_register('pc')
|
||||
pc_as_int = int(pc.cast(gdb.lookup_type('int')))
|
||||
# gdb.write("In unwinder: pc=%x\n" % pc_as_int)
|
||||
|
||||
elif TestUnwinder.test == 'check_pae_pc' :
|
||||
|
||||
pc = gdb.parse_and_eval('$pc')
|
||||
pc_as_int = int(pc.cast(gdb.lookup_type('int')))
|
||||
# gdb.write("In unwinder: pc=%x\n" % pc_as_int)
|
||||
|
||||
elif TestUnwinder.test == 'check_undefined_symbol' :
|
||||
|
||||
try:
|
||||
val = gdb.parse_and_eval("undefined_symbol")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue