https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82010

            Bug ID: 82010
           Summary: Inspecting a function parameter of "vec<basic_block,
                    va_gc> *&path" from gdb yields nonsense.
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aldyh at gcc dot gnu.org
  Target Milestone: ---

While debugging cc1, a function parameter of "vec<...> *&path" yields
garbabge when printing it from gdb:

(gdb) print path
$1 = Python Exception <class 'gdb.error'> Cannot convert value to long.:

whereas if you print the vector from the caller, gdb can see inside
the vector of basic blocks just fine:

(gdb) up
(gdb) print bb_path
$2 = 0x7fb8fca77000 = {<basic_block 0x7fb8fc93d270 (2)>}

Detailed steps follow:

$ cat a.c
void foo(int i)
{
  extern void bar ();
  if (i > 5)
    bar();
}

$ gdb cc1
GNU gdb (GDB) Fedora 8.0-22.fc26
Copyright (C) 2017 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-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Demangling of encoded C++/ObjC names when displaying symbols is on.
Really redefine built-in command "dump"? (y or n) [answered Y; input not from
terminal]
Reading symbols from cc1...done.
Breakpoint 1 at 0x1a657e2: file /source/gcc-pristine/gcc/diagnostic.c, line
1488.
Breakpoint 2 at 0x1a65559: file /source/gcc-pristine/gcc/diagnostic.c, line
1420.
Breakpoint 3 at 0x76cfd0
Breakpoint 4 at 0x76d0f0
[snip snip]
[snip snip]
Successfully loaded GDB hooks for GCC
(gdb) break fsm_find_control_statement_thread_paths
Breakpoint 5 at 0x118c4e3: file
/source/gcc-pristine/gcc/tree-ssa-threadbackward.c, line 678.
(gdb) run a.c -O2 -quiet
Starting program: /home/build/pristine/gcc/cc1 a.c -O2 -quiet

Breakpoint 5, fsm_find_control_statement_thread_paths (name=
    <ssa_name 0x7fb8fc93c990>, visited_bbs=0x283b0c0, Python Exception <class
'gdb.error'> Cannot convert value to long.: 
path=, 
    seen_loop_phi=false, speed_p=false)
    at /source/gcc-pristine/gcc/tree-ssa-threadbackward.c:678
678       if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name))
(gdb) print path
$1 = Python Exception <class 'gdb.error'> Cannot convert value to long.: 
(gdb) up
#1  0x000000000118ca93 in find_jump_threads_backwards (
    bb=<basic_block 0x7fb8fc93d270 (2)>, speed_p=false)
    at /source/gcc-pristine/gcc/tree-ssa-threadbackward.c:785
785       fsm_find_control_statement_thread_paths (name, visited_bbs, bb_path,
false,
(gdb) print bb_path
$2 = 0x7fb8fca77000 = {<basic_block 0x7fb8fc93d270 (2)>}

Reply via email to