public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/37616]  New: Lines with 'break', 'goto', and 'continue' are not available for debugging.
@ 2008-09-22 17:16 seppo at totalviewtech dot com
  2008-09-22 19:40 ` [Bug debug/37616] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: seppo at totalviewtech dot com @ 2008-09-22 17:16 UTC (permalink / raw)
  To: gcc-bugs

Lines with 'break', 'goto', and 'continue' are not available for
debugging.

On GCC compilers, one can not set a breakpoint on lines with 'goto', 'break',
or
'continue' statements. This is incorrect, since these lines contain
user statements. Also, for example IBM XLC compilers on AIX 6.1 have
these lines available for setting breakpoints when debugging.

This fails both when using gdb and TotalView debugger.

The root problem seems to be that the GCC DWARF explicitly tells the
debugger to skip the lines in question.


> uname -a
Linux rhel52-x8664.totalviewtech.com 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:15
EDT 2008 x86_64 x86_64 x86_64 GNU/Linux
> cat /etc/*-rel*
cat: /etc/lsb-release.d: Is a directory
Red Hat Enterprise Linux Server release 5.2 (Tikanga)
> rpm -q glibc
glibc-2.5-24
glibc-2.5-24

g++ -g -O0 -v -o a_g_gcc.out e24018.cxx

gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)


totalview ./a_g_gcc.out

=> looking at the source code pane, we see that lines #12 (continue),
#14 (goto), and #16 (break) are not available for setting breakpoints.


How to reproduce using gdb:

> gdb a_g_gcc.out
GNU gdb Red Hat Linux (6.5-37.el5rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or 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.
This GDB was configured as "x86_64-redhat-linux-gnu"...Using host libthread_db
library "/lib64/libthread_db.so.1".

(gdb) break 12
Breakpoint 1 at 0x40071b: file e24018.cxx, line 12.
(gdb) run
Starting program: /nfs/netapp0/user/home/seppo/Bugs/Bug_11496/a_g_gcc.out 

Breakpoint 1, main () at e24018.cxx:13
13          if (jj == 7)
(gdb) list
8
9         for (jj = 0; jj < 10; jj++)
10        {
11          if (jj == 5)
12            continue;
13          if (jj == 7)
14            goto exit;
15          if (jj == 9)
16            break;
17          mm = jj;
(gdb) print jj
$1 = 0
(gdb) cont
Continuing.

Breakpoint 1, main () at e24018.cxx:13
13          if (jj == 7)
(gdb) print jj
$2 = 1
(gdb) 

=> notice how the debugger stopped at line #13, although the breakpoint
was set at line #12. Also the stopping happened at the wrong point in
execution, since jj=0 (and not jj=5, as the user wanted).

XXXXXXXXXXX Analysis:


 readelf -wl ./a_g_gcc.out > ! readelf_gcc.txt

...
  Set File Name to entry 1 in the File Name Table
  Advance Line by -71 to 5
  Special opcode 173: advance Address by 12 to 0x400704 and Line by 0 to 5
  Special opcode 121: advance Address by 8 to 0x40070c and Line by 4 to 9
  Special opcode 133: advance Address by 9 to 0x400715 and Line by 2 to 11
  Special opcode 91: advance Address by 6 to 0x40071b and Line by 2 to 13
  Special opcode 91: advance Address by 6 to 0x400721 and Line by 2 to 15
  Special opcode 91: advance Address by 6 to 0x400727 and Line by 2 to 17
  Advance Line by -8 to 9

=> notice how lines #12, 14, and #16 are skipped  in DWARF


XXXXXXXXXXXXX reproducer
#include <iostream>

using namespace std;

int main()
{
int jj, mm;

  for (jj = 0; jj < 10; jj++)
  {
    if (jj == 5)
      continue;
    if (jj == 7)
      goto exit;
    if (jj == 9)
      break;
    mm = jj;
  }

exit:
  printf("About to exit\n");

  return(0);
}
XXXXXXXXXXXXXX


-- 
           Summary: Lines with 'break', 'goto', and 'continue' are not
                    available for debugging.
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: seppo at totalviewtech dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37616


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

* [Bug debug/37616] Lines with 'break', 'goto', and 'continue' are not available for debugging.
  2008-09-22 17:16 [Bug debug/37616] New: Lines with 'break', 'goto', and 'continue' are not available for debugging seppo at totalviewtech dot com
@ 2008-09-22 19:40 ` pinskia at gcc dot gnu dot org
  2008-09-22 19:46 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-09-22 19:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-09-22 19:39 -------
Related to PR 29609.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37616


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

* [Bug debug/37616] Lines with 'break', 'goto', and 'continue' are not available for debugging.
  2008-09-22 17:16 [Bug debug/37616] New: Lines with 'break', 'goto', and 'continue' are not available for debugging seppo at totalviewtech dot com
  2008-09-22 19:40 ` [Bug debug/37616] " pinskia at gcc dot gnu dot org
@ 2008-09-22 19:46 ` pinskia at gcc dot gnu dot org
  2008-10-03  8:56 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-09-22 19:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-09-22 19:44 -------
Also related to PR 36690.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37616


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

* [Bug debug/37616] Lines with 'break', 'goto', and 'continue' are not available for debugging.
  2008-09-22 17:16 [Bug debug/37616] New: Lines with 'break', 'goto', and 'continue' are not available for debugging seppo at totalviewtech dot com
  2008-09-22 19:40 ` [Bug debug/37616] " pinskia at gcc dot gnu dot org
  2008-09-22 19:46 ` pinskia at gcc dot gnu dot org
@ 2008-10-03  8:56 ` jakub at gcc dot gnu dot org
  2008-10-07 18:51 ` jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-10-03  8:56 UTC (permalink / raw)
  To: gcc-bugs



-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2008-
                   |                            |10/msg00017.html
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-10-03 08:55:35
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37616


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

* [Bug debug/37616] Lines with 'break', 'goto', and 'continue' are not available for debugging.
  2008-09-22 17:16 [Bug debug/37616] New: Lines with 'break', 'goto', and 'continue' are not available for debugging seppo at totalviewtech dot com
                   ` (2 preceding siblings ...)
  2008-10-03  8:56 ` jakub at gcc dot gnu dot org
@ 2008-10-07 18:51 ` jakub at gcc dot gnu dot org
  2008-10-07 19:02 ` jakub at gcc dot gnu dot org
  2008-11-21 23:49 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-10-07 18:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jakub at gcc dot gnu dot org  2008-10-07 18:50 -------
Subject: Bug 37616

Author: jakub
Date: Tue Oct  7 18:48:40 2008
New Revision: 140948

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140948
Log:
        PR debug/29609
        PR debug/36690
        PR debug/37616
        * basic-block.h (struct edge_def): Add goto_block field.
        * cfglayout.c (fixup_reorder_chain): Ensure that there is at least
        one insn with locus corresponding to edge's goto_locus if !optimize.
        * profile.c (branch_prob): Copy edge's goto_block.
        * cfgrtl.c (force_nonfallthru_and_redirect): Use goto_locus for
        emitted jumps.
        (cfg_layout_merge_blocks): Emit a nop with edge's goto_locus
        locator in between the merged basic blocks if !optimize and needed.
        * cfgexpand.c (expand_gimple_cond): Convert goto_block and
        goto_locus into RTL locator.  For unconditional jump use that
        locator for the jump insn.
        (expand_gimple_cond): Convert goto_block and goto_locus into
        RTL locator for all remaining edges.  For unconditional jump
        use that locator for the jump insn.
        * cfgcleanup.c (try_forward_edges): Avoid the optimization if
        there is more than one edge or insn locator along the forwarding
        edges and !optimize.  If there is just one, set e->goto_locus.
        * tree-cfg.c (make_cond_expr_edges, make_goto_expr_edges): Set also
        edge's goto_block.
        (move_block_to_fn): Adjust edge's goto_block.

        * gcc.dg/debug/pr29609-1.c: New test.
        * gcc.dg/debug/pr29609-2.c: New test.
        * gcc.dg/debug/pr36690-1.c: New test.
        * gcc.dg/debug/pr36690-2.c: New test.
        * gcc.dg/debug/pr36690-3.c: New test.
        * gcc.dg/debug/pr37616.c: New test.
        * gcc.dg/debug/dwarf2/pr29609-1.c: New test.
        * gcc.dg/debug/dwarf2/pr29609-2.c: New test.
        * gcc.dg/debug/dwarf2/pr36690-1.c: New test.
        * gcc.dg/debug/dwarf2/pr36690-2.c: New test.
        * gcc.dg/debug/dwarf2/pr36690-3.c: New test.
        * gcc.dg/debug/dwarf2/pr37616.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/debug/dwarf2/pr29609-1.c
    trunk/gcc/testsuite/gcc.dg/debug/dwarf2/pr29609-2.c
    trunk/gcc/testsuite/gcc.dg/debug/dwarf2/pr36690-1.c
    trunk/gcc/testsuite/gcc.dg/debug/dwarf2/pr36690-2.c
    trunk/gcc/testsuite/gcc.dg/debug/dwarf2/pr36690-3.c
    trunk/gcc/testsuite/gcc.dg/debug/dwarf2/pr37616.c
    trunk/gcc/testsuite/gcc.dg/debug/pr29609-1.c
    trunk/gcc/testsuite/gcc.dg/debug/pr29609-2.c
    trunk/gcc/testsuite/gcc.dg/debug/pr36690-1.c
    trunk/gcc/testsuite/gcc.dg/debug/pr36690-2.c
    trunk/gcc/testsuite/gcc.dg/debug/pr36690-3.c
    trunk/gcc/testsuite/gcc.dg/debug/pr37616.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/basic-block.h
    trunk/gcc/cfgcleanup.c
    trunk/gcc/cfgexpand.c
    trunk/gcc/cfglayout.c
    trunk/gcc/cfgrtl.c
    trunk/gcc/profile.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-cfg.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37616


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

* [Bug debug/37616] Lines with 'break', 'goto', and 'continue' are not available for debugging.
  2008-09-22 17:16 [Bug debug/37616] New: Lines with 'break', 'goto', and 'continue' are not available for debugging seppo at totalviewtech dot com
                   ` (3 preceding siblings ...)
  2008-10-07 18:51 ` jakub at gcc dot gnu dot org
@ 2008-10-07 19:02 ` jakub at gcc dot gnu dot org
  2008-11-21 23:49 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-10-07 19:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2008-10-07 19:01 -------
Fixed.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37616


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

* [Bug debug/37616] Lines with 'break', 'goto', and 'continue' are not available for debugging.
  2008-09-22 17:16 [Bug debug/37616] New: Lines with 'break', 'goto', and 'continue' are not available for debugging seppo at totalviewtech dot com
                   ` (4 preceding siblings ...)
  2008-10-07 19:02 ` jakub at gcc dot gnu dot org
@ 2008-11-21 23:49 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-11-21 23:49 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.4.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37616


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

end of thread, other threads:[~2008-11-21 23:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-22 17:16 [Bug debug/37616] New: Lines with 'break', 'goto', and 'continue' are not available for debugging seppo at totalviewtech dot com
2008-09-22 19:40 ` [Bug debug/37616] " pinskia at gcc dot gnu dot org
2008-09-22 19:46 ` pinskia at gcc dot gnu dot org
2008-10-03  8:56 ` jakub at gcc dot gnu dot org
2008-10-07 18:51 ` jakub at gcc dot gnu dot org
2008-10-07 19:02 ` jakub at gcc dot gnu dot org
2008-11-21 23:49 ` pinskia at gcc dot gnu dot org

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).