This is the mail archive of the gdb@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]

watchpoint and function epilogue



Hi all,


When generating Dwarf debug_frame information with my compiler, I discovered a regression in the recurse.exp test of gdb.base.
The test puts a watchpoint on local variable b and at some time expects it to be deleted when going out of function scope.


The recurse function contains:
static int recurse (int a)
{
  int b = 0;

  if (a == 1)
    return 1;

L1:  b = a;
L2:  b *= recurse (a - 1);
L3:  return b;
}

In the test, the watchpoint is created when a==5.
In my case, it triggers 3 times: on lines L1, L2 and L3.

In detail, my Dwarf debug_info for 'b' is
<2><  908>	DW_TAG_variable
		DW_AT_name                  b
		DW_AT_type                  <948>
		DW_AT_location              DW_OP_fbreg -8

The code generated for L3 looks like:
l1: save 'b' into the return-value register
l2: restore SP and RA
l3: return

The debug_frame information says that until l2 (included) SP has been updated for the current frame and that RA is saved in the stack.
When reaching l3, it says that RA is restored and that the CFA offset changes back to the value it had at function entry.


My analysis is that after executing l2, in break.c:watchpoint_check() the location of 'b' is evaluated, and as SP has changed, so has 'b'.
This occurs because watchpoint_check() thinks within_current_scope is true.
Well... we are still in the same function, but as SP has been restored, we are not really in the same scope. However, CFA is still unchanged of course.



So what is your advice in order to deal with this situation? I guess that if the compiler is modified not to generate the instruction that restores the CFA_offset, it will work again. Is there any other possibility?


Thanks,


Christophe.




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