This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug breakpoints/16087] New: cannot step in catch block after exception is thrown


https://sourceware.org/bugzilla/show_bug.cgi?id=16087

            Bug ID: 16087
           Summary: cannot step in catch block after exception is thrown
           Product: gdb
           Version: 7.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: breakpoints
          Assignee: unassigned at sourceware dot org
          Reporter: toma.bilius at enea dot com

We're using a test application for ARM (cortex a9) compiled with GCC 4.6.3 and
thumb2. We use GDB 7.4 to debug the target. We have trouble stepping over the
code in a try/catch block. After setting a breakpoint on throw, it is hit but
when issuing a next command GDB will just resume execution.

Here's the initial c++ code:
               try
               {
                  throw 4711;             /* GDB Test (cplusplus.cpp,1) */
               }
               catch (int i)              /* GDB Test (cplusplus.cpp,2) */
               {
                  blue::fibonacci(5);     /* GDB Test (cplusplus.cpp,3) */
               }                          /* GDB Test (cplusplus.cpp,9) */

After disassembling we noticed that this code is split, having the actual catch
clause somewhere at the end of the function:

 try
               {
                  throw 4711;             /* GDB Test (cplusplus.cpp,1) */
  17b3ae:       f04f 0004       mov.w   r0, #4
  17b3b2:       f09c fba9       bl      217b08 <__cxa_allocate_exception>
  17b3b6:       4603            mov     r3, r0
  17b3b8:       f241 2267       movw    r2, #4711       ; 0x1267
  17b3bc:       601a            str     r2, [r3, #0]
  17b3be:       4618            mov     r0, r3
  17b3c0:       f64c 0118       movw    r1, #51224      ; 0xc818
  17b3c4:       f04f 0302       mov.w   r3, #2
  17b3c8:       623b            str     r3, [r7, #32]
  17b3ca:       f2c0 012c       movt    r1, #44 ; 0x2c
  17b3ce:       f04f 0200       mov.w   r2, #0
  17b3d2:       f09d fc45       bl      218c60 <__cxa_throw>

....

 try
               {
                  throw 4711;             /* GDB Test (cplusplus.cpp,1) */
               }
               catch (int i)              /* GDB Test (cplusplus.cpp,2) */
  17b530:       4618            mov     r0, r3
  17b532:       f09c fd59       bl      217fe8 <__cxa_begin_catch>
  17b536:       4603            mov     r3, r0
  17b538:       681b            ldr     r3, [r3, #0]
  17b53a:       677b            str     r3, [r7, #116]  ; 0x74
               {
                  blue::fibonacci(5);     /* GDB Test (cplusplus.cpp,3) */
  17b53c:       f04f 0005       mov.w   r0, #5
  17b540:       f7ff fcc2       bl      17aec8 <_ZN4blue9fibonacciEi>

On Powerpc GDB installs a second breakpoint on the "_Unwind_DebugHook"
function. Then, after stepping over this hook GDB will install another 3
breakpoints: one after the call to _cxa_throw in the first block, one on the
catch block in the second (which is of interest) and another breakpoint on
DebugHook. Thus at some point the breakpoint on fibonacci will be reached. On
ARM there is no DebugHook so the target will not know when to stop. The "next"
command will only issue a step through range 17b3ae-17b3d2. How can the GDB
stub on the target side reach the branch to the fibonacci function at 17b540?
Perhaps we need to install additional breakpoints like on PPC?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]