public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/14959] New: Software watchpoint deleted when we have a call to @plt function
@ 2012-12-14  8:12 karthikthecool at gmail dot com
  2012-12-14  8:13 ` [Bug gdb/14959] " karthikthecool at gmail dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: karthikthecool at gmail dot com @ 2012-12-14  8:12 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14959

             Bug #: 14959
           Summary: Software watchpoint deleted when we have a call to
                    @plt function
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: critical
          Priority: P2
         Component: gdb
        AssignedTo: unassigned@sourceware.org
        ReportedBy: karthikthecool@gmail.com
    Classification: Unclassified


Hi All,
I was trying to debug the following program in GDB -

#include <stdio.h>
int global = 0;

void func2()
{
  global = 0;
  printf("global = %d  \n",global);
}

int main()
{
  int q = 0;
  func2();
  q = 1;
  return 0;
}

When we try to set a software watchpoint on q and execute the program. The
watchpoint gets deleted as soon as a call to printf is made.

Debugging session snippet - 

(gdb) b main 
Breakpoint 1 at 0x8048427: file test.c, line 13.
(gdb) r
Starting program: /home/kv.bhat/OpenSourceProject/a.out 

Breakpoint 1, main () at test.c:13
13      int q = 0;
(gdb) set can-use-hw-watchpoints 0
(gdb) watch q
Watchpoint 2: q
(gdb) n
Watchpoint 2: q

Old value = -1208201228
New value = 0
main () at test.c:14
14      func2();
(gdb) c
Continuing.

Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
0xb7fedbdb in ?? () from /lib/ld-linux.so.2
(gdb) c
Continuing.
global = 0  

Program exited normally.
(gdb) Quit


Call to prtinf@plt function is resulting in watch point getting deleted -

Dump of assembler code for function func2:
   0x080483e4 <+0>:    push   %ebp
   0x080483e5 <+1>:    mov    %esp,%ebp
   0x080483e7 <+3>:    push   %ebx
   0x080483e8 <+4>:    sub    $0x14,%esp
   0x080483eb <+7>:    call   0x8048443 <__i686.get_pc_thunk.bx>
   0x080483f0 <+12>:    add    $0x1c04,%ebx
   0x080483f6 <+18>:    movl   $0x0,0x28(%ebx)
   0x08048400 <+28>:    mov    0x28(%ebx),%edx
   0x08048406 <+34>:    lea    -0x1ad4(%ebx),%eax
   0x0804840c <+40>:    mov    %edx,0x4(%esp)
   0x08048410 <+44>:    mov    %eax,(%esp)
=> 0x08048413 <+47>:    call   0x8048300 <printf@plt>
   0x08048418 <+52>:    add    $0x14,%esp
   0x0804841b <+55>:    pop    %ebx
   0x0804841c <+56>:    pop    %ebp
   0x0804841d <+57>:    ret    
End of assembler dump.
(gdb) ni

Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
0xb7fedbdb in ?? () from /lib/ld-linux.so.2

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/14959] Software watchpoint deleted when we have a call to @plt function
  2012-12-14  8:12 [Bug gdb/14959] New: Software watchpoint deleted when we have a call to @plt function karthikthecool at gmail dot com
@ 2012-12-14  8:13 ` karthikthecool at gmail dot com
  2012-12-14  9:21 ` qiyao at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: karthikthecool at gmail dot com @ 2012-12-14  8:13 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14959

--- Comment #1 from Karthik <karthikthecool at gmail dot com> 2012-12-14 08:13:54 UTC ---
As we can see from dis-assembly problem occurs when we use -fPIC to compiled
the code.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/14959] Software watchpoint deleted when we have a call to @plt function
  2012-12-14  8:12 [Bug gdb/14959] New: Software watchpoint deleted when we have a call to @plt function karthikthecool at gmail dot com
  2012-12-14  8:13 ` [Bug gdb/14959] " karthikthecool at gmail dot com
@ 2012-12-14  9:21 ` qiyao at gcc dot gnu.org
  2013-03-24 15:02 ` SztfG at yandex dot ru
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: qiyao at gcc dot gnu.org @ 2012-12-14  9:21 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14959

Yao Qi <qiyao at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |qiyao at gcc dot gnu.org

--- Comment #2 from Yao Qi <qiyao at gcc dot gnu.org> 2012-12-14 09:21:57 UTC ---
Thanks for reporting this issue, and I can reproduce it in my box.

As far as I can see, this problem is caused by doing single steps (to emulate
the watchpoint without hardware support) to watch a local variable across a
complicated functions call (such as plt resolver here).

When software watchpoint is use, GDB will execute program one instruction per
one time, and check whether the variable is changed.  If the watchponit is for
a local variable, GDB will also check whether program is running out of the
"valid scope" of this local variable.  In this case, when program is running
through plt resolver, GDB is unable to know whether the current pc is still
within the "valid scope" of this local variable, so GDB removes this
watchpoint.

I run out of ideas on how to fix it.  Maybe someone else have.

P.S. in other places of GDB, we reply on a 'step resume breakpoint' to step
through plt resolver, instead of doing many single-steps in it.  However, we
can' do this in this case, because GDB has to single step every instruction in
order not to miss memory changes.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/14959] Software watchpoint deleted when we have a call to @plt function
  2012-12-14  8:12 [Bug gdb/14959] New: Software watchpoint deleted when we have a call to @plt function karthikthecool at gmail dot com
  2012-12-14  8:13 ` [Bug gdb/14959] " karthikthecool at gmail dot com
  2012-12-14  9:21 ` qiyao at gcc dot gnu.org
@ 2013-03-24 15:02 ` SztfG at yandex dot ru
  2013-03-24 15:02 ` SztfG at yandex dot ru
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: SztfG at yandex dot ru @ 2013-03-24 15:02 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14959

SztfG at yandex dot ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jan.kratochvil at redhat
                   |                            |dot com, SztfG at yandex
                   |                            |dot ru

--- Comment #3 from SztfG at yandex dot ru 2013-03-24 15:02:27 UTC ---
I think, GDB have an array which contain pointers to places with software
breakpoint. And before executing instruction, that "read from" or "write to"
memory, GDB should check, does it write or read to this software break places

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/14959] Software watchpoint deleted when we have a call to @plt function
  2012-12-14  8:12 [Bug gdb/14959] New: Software watchpoint deleted when we have a call to @plt function karthikthecool at gmail dot com
                   ` (2 preceding siblings ...)
  2013-03-24 15:02 ` SztfG at yandex dot ru
@ 2013-03-24 15:02 ` SztfG at yandex dot ru
  2013-03-24 15:04 ` SztfG at yandex dot ru
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: SztfG at yandex dot ru @ 2013-03-24 15:02 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14959

--- Comment #4 from SztfG at yandex dot ru 2013-03-24 15:02:52 UTC ---
I think, GDB have an array which contain pointers to places with software
breakpoint. And before executing instruction, that "read from" or "write to"
memory, GDB should check, does it write or read to this software break places

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/14959] Software watchpoint deleted when we have a call to @plt function
  2012-12-14  8:12 [Bug gdb/14959] New: Software watchpoint deleted when we have a call to @plt function karthikthecool at gmail dot com
                   ` (3 preceding siblings ...)
  2013-03-24 15:02 ` SztfG at yandex dot ru
@ 2013-03-24 15:04 ` SztfG at yandex dot ru
  2013-03-24 15:21 ` jan.kratochvil at redhat dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: SztfG at yandex dot ru @ 2013-03-24 15:04 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14959

--- Comment #5 from SztfG at yandex dot ru 2013-03-24 15:04:25 UTC ---
Sorry for double posting. Also
http://sourceware.org/bugzilla/show_bug.cgi?id=15299

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/14959] Software watchpoint deleted when we have a call to @plt function
  2012-12-14  8:12 [Bug gdb/14959] New: Software watchpoint deleted when we have a call to @plt function karthikthecool at gmail dot com
                   ` (4 preceding siblings ...)
  2013-03-24 15:04 ` SztfG at yandex dot ru
@ 2013-03-24 15:21 ` jan.kratochvil at redhat dot com
  2013-03-25 12:23 ` SztfG at yandex dot ru
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jan.kratochvil at redhat dot com @ 2013-03-24 15:21 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14959

--- Comment #6 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2013-03-24 15:21:32 UTC ---
(In reply to comment #3)
> And before executing instruction, that "read from" or "write to"
> memory, GDB should check, does it write or read to this software break places

GDB (almost) never decodes instructions (only 'record' does).  It brings in the
problem to keep GDB up to date with all the instruction extensions (AVX2 etc.).


(In reply to comment #5)
> Sorry for double posting. Also
> http://sourceware.org/bugzilla/show_bug.cgi?id=15299

I do not see how it is related.


But this Bug is rather a problem of the libraries.  Recent GNU ld and also gold
provide unwind information even for the plt frames.  GDB could workaround it
somehow but I do not see any need for it nowadays.

Fedora 17 x86_64:

GNU gdb (GDB) 7.6.50.20130322-cvs
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/jkratoch/t/sbp...done.
(gdb) b main
Breakpoint 1 at 0x40055b: file sbp.c, line 12.
(gdb) r
Starting program: /home/jkratoch/t/sbp 

Breakpoint 1, main () at sbp.c:12
12      int q = 0;
(gdb) set can-use-hw-watchpoints 0
(gdb) watch q
Watchpoint 2: q
(gdb) n
13      func2();
(gdb) c
Continuing.
global = 0  
Watchpoint 2: q

Old value = 0
New value = 1
main () at sbp.c:15
15      return 0;
(gdb)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/14959] Software watchpoint deleted when we have a call to @plt function
  2012-12-14  8:12 [Bug gdb/14959] New: Software watchpoint deleted when we have a call to @plt function karthikthecool at gmail dot com
                   ` (5 preceding siblings ...)
  2013-03-24 15:21 ` jan.kratochvil at redhat dot com
@ 2013-03-25 12:23 ` SztfG at yandex dot ru
  2013-03-25 12:30 ` jan.kratochvil at redhat dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: SztfG at yandex dot ru @ 2013-03-25 12:23 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14959

--- Comment #7 from SztfG at yandex dot ru 2013-03-25 12:23:56 UTC ---
(In reply to comment #6)
> I do not see how it is related..
>
>
>But this Bug is rather a problem of the libraries.  Recent GNU ld and also gold
>provide unwind information even for the plt frames.  GDB could workaround it
>somehow but I do not see any need for it nowadays.

Maybe this is related http://sourceware.org/bugzilla/show_bug.cgi?id=7116 ?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/14959] Software watchpoint deleted when we have a call to @plt function
  2012-12-14  8:12 [Bug gdb/14959] New: Software watchpoint deleted when we have a call to @plt function karthikthecool at gmail dot com
                   ` (6 preceding siblings ...)
  2013-03-25 12:23 ` SztfG at yandex dot ru
@ 2013-03-25 12:30 ` jan.kratochvil at redhat dot com
  2023-12-31 15:43 ` ssbssa at sourceware dot org
  2024-01-01  5:57 ` jan at jankratochvil dot net
  9 siblings, 0 replies; 11+ messages in thread
From: jan.kratochvil at redhat dot com @ 2013-03-25 12:30 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14959

--- Comment #8 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2013-03-25 12:30:53 UTC ---
This is related (it was PR 12570):
[PATCH] Unwind info for PLT on i?86/x86_64
http://sourceware.org/ml/binutils/2011-06/msg00225.html

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/14959] Software watchpoint deleted when we have a call to @plt function
  2012-12-14  8:12 [Bug gdb/14959] New: Software watchpoint deleted when we have a call to @plt function karthikthecool at gmail dot com
                   ` (7 preceding siblings ...)
  2013-03-25 12:30 ` jan.kratochvil at redhat dot com
@ 2023-12-31 15:43 ` ssbssa at sourceware dot org
  2024-01-01  5:57 ` jan at jankratochvil dot net
  9 siblings, 0 replies; 11+ messages in thread
From: ssbssa at sourceware dot org @ 2023-12-31 15:43 UTC (permalink / raw)
  To: gdb-prs

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

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ssbssa at sourceware dot org

--- Comment #9 from Hannes Domani <ssbssa at sourceware dot org> ---
(In reply to Jan Kratochvil from comment #8)
> This is related (it was PR 12570):
> [PATCH] Unwind info for PLT on i?86/x86_64
> http://sourceware.org/ml/binutils/2011-06/msg00225.html

Since PR12570 was closed, can this one be closed as well?

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/14959] Software watchpoint deleted when we have a call to @plt function
  2012-12-14  8:12 [Bug gdb/14959] New: Software watchpoint deleted when we have a call to @plt function karthikthecool at gmail dot com
                   ` (8 preceding siblings ...)
  2023-12-31 15:43 ` ssbssa at sourceware dot org
@ 2024-01-01  5:57 ` jan at jankratochvil dot net
  9 siblings, 0 replies; 11+ messages in thread
From: jan at jankratochvil dot net @ 2024-01-01  5:57 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #10 from Jan Kratochvil <jan at jankratochvil dot net> ---
If it fixed the Comment #0... I haven't tried myself.

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-01-01  5:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-14  8:12 [Bug gdb/14959] New: Software watchpoint deleted when we have a call to @plt function karthikthecool at gmail dot com
2012-12-14  8:13 ` [Bug gdb/14959] " karthikthecool at gmail dot com
2012-12-14  9:21 ` qiyao at gcc dot gnu.org
2013-03-24 15:02 ` SztfG at yandex dot ru
2013-03-24 15:02 ` SztfG at yandex dot ru
2013-03-24 15:04 ` SztfG at yandex dot ru
2013-03-24 15:21 ` jan.kratochvil at redhat dot com
2013-03-25 12:23 ` SztfG at yandex dot ru
2013-03-25 12:30 ` jan.kratochvil at redhat dot com
2023-12-31 15:43 ` ssbssa at sourceware dot org
2024-01-01  5:57 ` jan at jankratochvil dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).