Hy,

I have a problem using watchpoints with gdb, 
probably a problem with internal blocks (sorry for the guess :-)

I'm using the C programm:

--- C program ---- (gdb2.c)
int procedure()
{
  int faults = 0;
  {
    int a = 3;
    int b = 14;
    if (a != b) faults++;
  }
  return faults;
  
}

int main() 
{
  procedure();
  exit(0);
}
---- end c program ---

compiled with gcc:


---- shell:
< rif22: ~/tmp > gcc -v       
Reading specs from /pub/gcc/2.95.2/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/specs
gcc version 2.95.2 19991024 (release)
< rif22: ~/tmp > gcc -Wall -g gdb2.c -o gdbtest
---- end


then I make the following gdb-session: for getting an internal error


--- shell:
< rif22: ~/tmp > gdb -v
GDB 4.16 (sparc-sun-solaris2.6), Copyright 1996 Free Software Foundation, Inc.

< rif22: ~/tmp > gdb gdbtest
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.16 (sparc-sun-solaris2.6), Copyright 1996 Free Software Foundation, Inc...
(gdb) break procedure
Breakpoint 1 at 0x10950: file gdb2.c, line 3.
(gdb) r
Starting program: /home/tholenst/tmp/gdbtest 

Breakpoint 1, procedure () at gdb2.c:3
3         int faults = 0;
(gdb) watch faults
Watchpoint 2: faults
(gdb) c
Continuing.
Watchpoint 2: faults

Old value = 0
New value = 1
procedure () at gdb2.c:10
10        return faults;
(gdb) c
Continuing.
Watchpoint 2 deleted because the program has left the block in
which its expression is valid.

gdb internal error: Memory corruption
Quit
< rif22: ~/tmp > 
------ end shell 


Some more information:


--- shell:
< rif22: ~/tmp > uname -a
SunOS rif22 5.6 Generic_105181-19 sun4u sparc SUNW,Ultra-5_10
--- end shell

gcc -Wall -g gdb2.c -S gives:

--- assembler output:
        .file   "gdb2.c"
.stabs "/home/tholenst/tmp/",100,0,0,.LLtext0
.stabs "gdb2.c",100,0,0,.LLtext0
.section        ".text"
.LLtext0:
        .stabs  "gcc2_compiled.", 0x3c, 0, 0, 0
.stabs "int:t(0,1)=r(0,1);0020000000000;0017777777777;",128,0,0,0
.stabs "char:t(0,2)=r(0,2);0;127;",128,0,0,0
.stabs "long int:t(0,3)=r(0,1);0020000000000;0017777777777;",128,0,0,0
.stabs "unsigned int:t(0,4)=r(0,1);0000000000000;0037777777777;",128,0,0,0
.stabs "long unsigned int:t(0,5)=r(0,1);0000000000000;0037777777777;",128,0,0,0
.stabs "long long 
int:t(0,6)=r(0,1);01000000000000000000000;0777777777777777777777;",128,0,0,0
.stabs "long long unsigned 
int:t(0,7)=r(0,1);0000000000000;01777777777777777777777;",128,0,0,0
.stabs "short int:t(0,8)=r(0,8);-32768;32767;",128,0,0,0
.stabs "short unsigned int:t(0,9)=r(0,9);0;65535;",128,0,0,0
.stabs "signed char:t(0,10)=r(0,10);-128;127;",128,0,0,0
.stabs "unsigned char:t(0,11)=r(0,11);0;255;",128,0,0,0
.stabs "float:t(0,12)=r(0,1);4;0;",128,0,0,0
.stabs "double:t(0,13)=r(0,1);8;0;",128,0,0,0
.stabs "long double:t(0,14)=r(0,1);16;0;",128,0,0,0
.stabs "complex int:t(0,15)=s8real:(0,1),0,32;imag:(0,1),32,32;;",128,0,0,0
.stabs "complex float:t(0,16)=r(0,16);4;0;",128,0,0,0
.stabs "complex double:t(0,17)=r(0,17);8;0;",128,0,0,0
.stabs "complex long double:t(0,18)=r(0,18);16;0;",128,0,0,0
.stabs "void:t(0,19)=(0,19)",128,0,0,0
        .align 4
.stabs "procedure:F(0,1)",36,0,2,procedure
        .global procedure
        .type    procedure,#function
        .proc   04
procedure:
.stabn 68,0,2,.LLM1-procedure
.LLM1:
        !#PROLOGUE# 0
        save    %sp, -128, %sp
        !#PROLOGUE# 1
.stabn 68,0,3,.LLM2-procedure
.LLM2:
.LLBB2:
        st      %g0, [%fp-20]
.stabn 68,0,6,.LLM3-procedure
.LLM3:
.LLBB3:
        mov     3, %o0
        st      %o0, [%fp-24]
.stabn 68,0,7,.LLM4-procedure
.LLM4:
        mov     14, %o0
        st      %o0, [%fp-28]
.stabn 68,0,8,.LLM5-procedure
.LLM5:
        ld      [%fp-24], %o0
        ld      [%fp-28], %o1
        cmp     %o0, %o1
        be      .LL3
        nop
        ld      [%fp-20], %o0
        add     %o0, 1, %o1
        st      %o1, [%fp-20]
.LL3:
.stabn 68,0,9,.LLM6-procedure
.LLM6:
.LLBE3:
.stabn 68,0,10,.LLM7-procedure
.LLM7:
        ld      [%fp-20], %o0
        mov     %o0, %i0
        b       .LL2
         nop
.stabn 68,0,12,.LLM8-procedure
.LLM8:
.LLBE2:
.stabn 68,0,12,.LLM9-procedure
.LLM9:
.LL2:
        ret
        restore
.LLfe1:
        .size    procedure,.LLfe1-procedure
.stabs "faults:(0,1)",128,0,3,-20
.stabn 192,0,0,.LLBB2-procedure
.stabs "a:(0,1)",128,0,6,-24
.stabs "b:(0,1)",128,0,7,-28
.stabn 192,0,0,.LLBB3-procedure
.stabn 224,0,0,.LLBE3-procedure
.stabn 224,0,0,.LLBE2-procedure
.LLscope0:
.stabs "",36,0,0,.LLscope0-procedure
        .align 4
.stabs "main:F(0,1)",36,0,15,main
        .global main
        .type    main,#function
        .proc   04
main:
.stabn 68,0,15,.LLM10-main
.LLM10:
        !#PROLOGUE# 0
        save    %sp, -112, %sp
        !#PROLOGUE# 1
.stabn 68,0,16,.LLM11-main
.LLM11:
        call    procedure, 0
         nop
.stabn 68,0,17,.LLM12-main
.LLM12:
        mov     0, %o0
        call    exit, 0
         nop
.stabn 68,0,18,.LLM13-main
.LLM13:
.LL4:
        ret
        restore
.LLfe2:
        .size    main,.LLfe2-main
.LLscope1:
.stabs "",36,0,0,.LLscope1-main
        .text
        .stabs "",100,0,0,Letext
Letext:
        .ident  "GCC: (GNU) 2.95.2 19991024 (release)"
--- end assembler output


Preprocessing is trivial:

--- shell:
< rif22: ~/tmp > gcc -Wall -g gdb2.c -E 
# 1 "gdb2.c"
int procedure()
{
  int faults = 0;
  
  {
    int a = 3;
    int b = 14;
    if (a != b) faults++;
  }
  return faults;
  
}

int main() 
{
  procedure();
  exit(0);
}
--- end shell


Greetings 
        Thomas

Reply via email to