Debian bug report logs - #660 GDB gets address of structure member wrong in memory breakpoint Package: gdb ; Reported by: iwj10@cus.cam.ac.uk (Ian Jackson); 218 days old . ----------------------------------------------------------------------- Message received at debian-bugs: From chiark.chu.cam.ac.uk!ian Thu Oct 19 11:39:58 1995 Return-Path: Received: from pixar.com by mongo.pixar.com with smtp (Smail3.1.28.1 #15) id m0t5zsj-000B7cC; Thu, 19 Oct 95 11:39 PDT Received: from artemis.chu.cam.ac.uk by pixar.com with SMTP id AA11619 (5.67b/IDA-1.5 for debian-bugs-pipe@mongo.pixar.com); Thu, 19 Oct 1995 11:36:51 -0700 Received: from chiark.chu.cam.ac.uk by artemis.chu.cam.ac.uk with smtp (Smail3.1.29.1 #33) id m0t60sA-0007uBC; Thu, 19 Oct 95 19:43 GMT Received: by chiark.chu.cam.ac.uk id m0t5zpf-0002YFC (Debian /\oo/\ Smail3.1.29.1 #29.33); Thu, 19 Oct 95 19:36 BST Message-Id: Date: Thu, 19 Oct 95 19:36 BST From: Ian Jackson To: sr1@irz301.inf.tu-dresden.de (Sven Rudolph) Cc: Debian bugs submission address Subject: Re: Bug#660: GDB gets address of structure member wrong in memory breakpoint In-Reply-To: <199510190118.CAA08031@irz101.inf.tu-dresden.de> References: <199510190118.CAA08031@irz101.inf.tu-dresden.de> Sven Rudolph writes in email to me: > > Package: gdb > > Version: 4.12 > > > > As you can see below, when setting a memory breakpoint on a structure > > member GDB uses the address of the start of the structure by mistake. > > Applying *& to the member (to take its address and then dereference > > it) gives correct results. > > (typescript deleted) > > You used commands that don't even exist in the current version of gdb, > so i cannot reproduce this problem. I'm not a gdb expert, so please > try to reproduce this problem on a current gdb (or close the bug) . These commands have equivalents in gdb 4.14-1. However, the equivalents don't appear to work for me at all. See the transcript below. Please can we keep this bug open until (a) the memory watchpoints, which are a useful feature, work and (b) we see that the original bug is fixed. Ian. -chiark:~/junk> cat t.c struct foo { int a,b; }; void fong(struct foo *p, int x) { p->b=x; } int main(int argc, char **argv) { struct foo f; f.a= 2; f.b= 3; fong(&f,4); f.b=5; fong(&f,6); } -chiark:~/junk> gcc -g t.c -chiark:~/junk> gdb a.out 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.14 (i486-debian-linux), Copyright 1995 Free Software Foundation, Inc... (gdb) break main Breakpoint 1 at 0x1093: file t.c, line 7. (gdb) run Starting program: /u/ian/junk/a.out Breakpoint 1, main (argc=1, argv=0xbffff858) at t.c:7 7 f.a= 2; (gdb) step 8 f.b= 3; (gdb) step 9 fong(&f,4); (gdb) print f $1 = {a = 2, b = 3} (gdb) watch f.b Hardware watchpoint 2: f.b (gdb) watch f.a Hardware watchpoint 3: f.a (gdb) watch *&f.b Hardware watchpoint 4: *&f.b (gdb) info watchpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x00001093 in main at t.c:7 breakpoint already hit 1 time 2 hw watchpoint keep y f.b 3 hw watchpoint keep y f.a 4 hw watchpoint keep y *&f.b (gdb) cont Continuing. warning: Hardware watchpoint 3: Could not insert watchpoint warning: Hardware watchpoint 4: Could not insert watchpoint ptrace: Unknown error -1. Cannot insert breakpoints. The same program may be running in another process. (gdb) quit The program is running. Quit anyway (and kill it)? (y or n) y -chiark:~/junk> ----------------------------------------------------------------------- Acknowledgement sent to Ian Jackson : Extra info received and forwarded. Full text available. ----------------------------------------------------------------------- Information forwarded to debian-devel@pixar.com : Bug#660 ; Package gdb . Full text available. ----------------------------------------------------------------------- Message received at debian-bugs: From cus.cam.ac.uk!iwj10 Mon Mar 27 07:15:04 1995 Return-Path: Received: from pixar.com by mongo.pixar.com with smtp (Smail3.1.28.1 #15) id m0rtGVT-0006USC; Mon, 27 Mar 95 07:15 PST Received: from bootes.cus.cam.ac.uk by pixar.com with SMTP id AA14255 (5.65c/IDA-1.4.4 for ); Mon, 27 Mar 1995 07:09:41 -0800 Received: by bootes.cus.cam.ac.uk (Smail-3.1.29.0 #30) id m0rtFaj-000BzvC; Mon, 27 Mar 95 15:16 BST Received: by chiark (Smail3.1.28.1 #3) id m0rtE8u-0002gOZ; Mon, 27 Mar 95 13:43 BST Message-Id: Date: Mon, 27 Mar 95 13:43 BST From: iwj10@cus.cam.ac.uk (Ian Jackson) To: Debian bugs submission address Subject: GDB gets address of structure member wrong in memory breakpoint Package: gdb Version: 4.12 As you can see below, when setting a memory breakpoint on a structure member GDB uses the address of the start of the structure by mistake. Applying *& to the member (to take its address and then dereference it) gives correct results. chiark:~/junk> cat t.c struct foo { int a,b; }; void fong(struct foo *p, int x) { p->b=x; } int main(int argc, char **argv) { struct foo f; f.a= 2; f.b= 3; fong(&f,4); f.b=5; fong(&f,6); } chiark:~/junk> gcc -g t.c chiark:~/junk> /new/usr/bin/gdb a.out 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.12 (i486-debian-linux), Copyright 1994 Free Software Foundation, Inc... (gdb) break main Breakpoint 1 at 0x6f: file t.c, line 7. (gdb) run Starting program: /u/ian/junk/a.out Breakpoint 1, main (argc=1, argv=0xbffff978) at t.c:7 7 f.a= 2; (gdb) step 8 f.b= 3; (gdb) step 9 fong(&f,4); (gdb) print f $1 = {a = 2, b = 3} (gdb) abreak f.b Memorypoint 2: f.b (gdb) abreak f.a Memorypoint 3: f.a (gdb) abreak *&f.b Memorypoint 4: *&f.b (gdb) info memory Num Type Disp Enb Address What 2 memorypoint keep y 0xbffff95c r/w 4 f.b 3 memorypoint keep y 0xbffff95c r/w 4 f.a 4 memorypoint keep y 0xbffff960 r/w 4 *&f.b (gdb) cont Continuing. Memory breakpoint 4 on *&f.b at 0xbffff960 with length 4: accessed. 3 void fong(struct foo *p, int x) { p->b=x; } (gdb) disable 4 (gdb) cont Continuing. Memory breakpoint 2 on f.b at 0xbffff95c with length 4: accessed. 0x224 exit.c:38: No such file or directory. (gdb) where #0 0x224 in exit (status=-1073743524) at exit.c:38 (gdb) quit The program is running. Quit anyway (and kill it)? (y or n) y chiark:~/junk> gcc -v Reading specs from /usr/lib/gcc-lib/i486-linux/2.5.8/specs gcc version 2.5.8 chiark:~/junk> gcc -c -g t.c chiark:~/junk> nm -a t.o 00000000 - 00 0003 SLINE 00000003 - 00 0003 SLINE 0000000c - 00 0003 SLINE 00000010 - 00 0005 SLINE 0000001b - 00 0006 SLINE 0000001b - 00 0007 SLINE 00000022 - 00 0008 SLINE 00000029 - 00 0009 SLINE 00000037 - 00 000a SLINE 0000003e - 00 000b SLINE 0000004c - 00 000c SLINE 0000004c - 00 000c SLINE 0000001b - 00 0000 LBRAC 0000004c - 00 0000 RBRAC 00000000 - 00 0000 SO /u/ian/junk/ 00000000 t ___gnu_compiled_c U ___main 00000000 T _fong 00000010 T _main 00000008 - 00 0005 PSYM argc:p1 0000000c - 00 0005 PSYM argv:p22=*23=*2 00000000 - 00 0000 LSYM char:t2=r2;0;127; 00000000 - 00 0000 LSYM complex double:t17=r17;8;0; 00000000 - 00 0000 LSYM complex float:t16=r16;4;0; 00000000 - 00 0000 LSYM complex int:t15=s8real:1,0,32;imag:1,32,32;; 00000000 - 00 0000 LSYM complex long double:t18=r18;12;0; 00000000 - 00 0000 LSYM double:t13=r1;8;0; fffffff8 - 00 0006 LSYM f:20 00000000 - 00 0000 LSYM float:t12=r1;4;0; 00000000 - 00 0003 FUN fong:F19 00000000 - 00 0000 LSYM foo:T20=s8a:1,0,32;b:1,32,32;; 00000000 t gcc2_compiled. 00000000 - 00 0000 LSYM int:t1=r1;-2147483648;2147483647; 00000000 - 00 0000 LSYM long double:t14=r1;12;0; 00000000 - 00 0000 LSYM long int:t3=r1;-2147483648;2147483647; 00000000 - 00 0000 LSYM long long int:t6=r1;01000000000000000000000;0777777777777777777777; 00000000 - 00 0000 LSYM long long unsigned int:t7=r1;0000000000000;01777777777777777777777; 00000000 - 00 0000 LSYM long unsigned int:t5=r1;0;-1; 00000010 - 00 0005 FUN main:F1 00000008 - 00 0003 PSYM p:p21=*20 00000000 - 00 0000 LSYM short int:t8=r1;-32768;32767; 00000000 - 00 0000 LSYM short unsigned int:t9=r1;0;65535; 00000000 - 00 0000 LSYM signed char:t10=r1;-128;127; 00000000 - 00 0000 SO t.c 00000000 - 00 0000 LSYM unsigned char:t11=r1;0;255; 00000000 - 00 0000 LSYM unsigned int:t4=r1;0;-1; 00000000 - 00 0000 LSYM void:t19=19 0000000c - 00 0003 PSYM x:p1 chiark:~/junk> gzip -9 Q=B\"`WV2/6S30!3'7YJD2=L@(75@8`$$`ZAM?.!;B00IL*>ZQ+ M?`/O>LA4XA+>3T)^)'%;XF<2OY3XH\2YQ()K$OL2/Y7XE<2?)/XF\2^),TL+ M+DC\0.(]B8\E?B[Q&^2T="YW(1GCI,0YM&\Q_GJHCI%?(+,S_!(RB_D:UKP8 MY:8Y?T<]$>NU#)<@_MG^">?4_2=\-G2?,[? M(;,Y4TFVAV68XF^S@OP.-3;#*O(/M*S.&G++<:CE!)VNZS7J6V!95LL?1H+E M0'Z8=VT_WQ[Z>WD8;#G@^@-C0"H]8FY24M`*NEHJZ&:$F@G.KMTS!K32HZ9B M$HJ*%_BM*SQ1_5_BT.^[+;]1%Z$%%JJ8FR3,CWN+9[R+%B7N(+ER#_J-'?#7H#D:;SSU2I5M)-]HR\\>IE\1&E8E$M8H3PB/41A9<@ M5!QE$3QOR99=$CWGKJ@'VYTFFL]]\2'8 MEO1PBOW`K:-4KI`R-(/`>$@5G,2>C[$CS6`UL0JPAW$/H[M&EY+*+:K`@=$E F8'5LUV<_,K?L@5%@]UH.\Z+=QWB*\2K>T#0P#^`OH--.$L,%``#* ` end ----------------------------------------------------------------------- Acknowledgement sent to iwj10@cus.cam.ac.uk (Ian Jackson) : New bug report received and forwarded. Full text available. ----------------------------------------------------------------------- Report forwarded to debian-devel@pixar.com : Bug#660 ; Package gdb ; Resent-Message-ID: . Full text available. ----------------------------------------------------------------------- Ian Jackson / iwj10@thor.cam.ac.uk , with the debian-bugs tracking mechanism This page last modified 07:43:01 GMT Wed 01 Nov