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

--- Comment #6 from Tom de Vries <vries at gcc dot gnu.org> ---
Not sure yet whether this is the desired fix, but using this patch:
...
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c                                  
index bd45e0b0685..fbbbe9f2d2a 100644                                           
--- a/gcc/dwarf2out.c                                                           
+++ b/gcc/dwarf2out.c                                                           
@@ -22162,6 +22162,8 @@ gen_formal_parameter_die (tree node, tree origin, bool
emit_name_p,         

       else if (emit_name_p)
        add_name_and_src_coords_attributes (parm_die, node);
       if (origin == NULL
+         || (!decl_by_reference_p (node)
+             && decl_by_reference_p (origin))
          || (! DECL_ABSTRACT_P (node_or_origin)
              && variably_modified_type_p (TREE_TYPE (node_or_origin),
                                           decl_function_context
...

I get:
...
> ./install/bin/gdb ./a.out -batch -ex "b foo::foo" -ex "r" -ex "what dir_hint" 
> -ex "info addr dir_hint" -ex "p dir_hint" -ex "p dir_hint.c_str()" -ex c
Breakpoint 1 at 0x4012ee: file bla.C, line 9.

Breakpoint 1, foo::foo (this=0x7fffffffdb3f, dir_hint=...) at bla.C:9
9           std::cout << dir_hint << "\n";
type = std::__cxx11::string & restrict
Symbol "dir_hint" is a complex DWARF expression:
     0: DW_OP_fbreg -32
.
$1 = (std::__cxx11::string & restrict) @0x7fffffffdb70: {static npos =
18446744073709551615, _M_dataplus = {<std::allocator<char>> =
{<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p
= 0x416e90 "This is just a string"}, _M_string_length = 21, {_M_local_buf =
"\025\000\000\000\000\000\000\000\360\020@\000\000\000\000",
_M_allocated_capacity = 21}}
$2 = 0x416e90 "This is just a string"
This is just a string
[Inferior 1 (process 6355) exited normally]
...

Reply via email to