Test case to detect recursive unwinding in Python-based unwinders.
authorKevin Buettner <kevinb@redhat.com>
Mon, 22 Aug 2016 17:14:05 +0000 (10:14 -0700)
committerKevin Buettner <kevinb@redhat.com>
Wed, 24 Aug 2016 21:22:30 +0000 (14:22 -0700)
commitbb1fe4acb8927fc4d451402f3f5fc245144c987e
tree2dd0fdcd858fefa436a0277339ebc8f836678ae2
parent0a1ddfa6b67201bb06f51fb47b56096e81bec5c0
Test case to detect recursive unwinding in Python-based unwinders.

This test case verifies that GDB will not attempt to invoke a python
unwinder recursively.

At the moment, the behavior exhibited by GDB looks like this:

    (gdb) source py-recurse-unwind.py
    Python script imported
    (gdb) b ccc
    Breakpoint 1 at 0x4004bd: file py-recurse-unwind.c, line 23.
    (gdb) run
    Starting program: py-recurse-unwind
    TestUnwinder: Recursion detected - returning early.
    TestUnwinder: Recursion detected - returning early.
    TestUnwinder: Recursion detected - returning early.
    TestUnwinder: Recursion detected - returning early.

    Breakpoint 1, ccc (arg=<unavailable>) at py-recurse-unwind.c:23
    23      }
    (gdb) bt
    #-1 ccc (arg=<unavailable>) at py-recurse-unwind.c:23
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)

[I've shortened pathnames for easier reading.]

The desired / expected behavior looks like this:

    (gdb) source py-recurse-unwind.py
    Python script imported
    (gdb) b ccc
    Breakpoint 1 at 0x4004bd: file py-recurse-unwind.c, line 23.
    (gdb) run
    Starting program: py-recurse-unwind

    Breakpoint 1, ccc (arg=789) at py-recurse-unwind.c:23
    23      }
    (gdb) bt
    #0  ccc (arg=789) at py-recurse-unwind.c:23
    #1  0x00000000004004d5 in bbb (arg=456) at py-recurse-unwind.c:28
    #2  0x00000000004004ed in aaa (arg=123) at py-recurse-unwind.c:34
    #3  0x00000000004004fe in main () at py-recurse-unwind.c:40

Note that GDB's problems go well beyond the fact that it invokes the
unwinder recursively.  In the process it messes up some internal state
(the frame stash) leading to display of (only) the sentinel frame in
the backtrace.

gdb/testsuite/ChangeLog:

* gdb.python/py-recurse-unwind.c: New file.
* gdb.python/py-recurse-unwind.py: New file.
* gdb.python/py-recurse-unwind.exp: New file.
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-recurse-unwind.c [new file with mode: 0644]
gdb/testsuite/gdb.python/py-recurse-unwind.exp [new file with mode: 0644]
gdb/testsuite/gdb.python/py-recurse-unwind.py [new file with mode: 0644]
This page took 0.035006 seconds and 4 git commands to generate.