Bug 17811 - Stabs special "$t" support for this.
Summary: Stabs special "$t" support for this.
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: unknown
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-07 23:04 UTC by Pierre Muller
Modified: 2018-03-31 12:20 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Test sourc in C++ language (144 bytes, text/plain)
2015-01-07 23:04 UTC, Pierre Muller
Details
Pascal equivalent source (219 bytes, text/plain)
2015-01-07 23:11 UTC, Pierre Muller
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre Muller 2015-01-07 23:04:05 UTC
Created attachment 8054 [details]
Test sourc in C++ language

Current parsing of "$t" local parameter for
hidden this variable in C++ or pascal is partially broken.

  The problem is that the special handling in current GDB
misses too set the language for this special symbol.
  This results in the fact that the hidden parameter is
not display correctly in stack trace.

  fpc -gs -Mobjfpc test-class-pascal.pas

$ gdb ./test-class-pascal.exe
GNU gdb (GDB) 7.6.1
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 "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from e:\pas\test\test-class-pascal.exe...done.
(gdb) b TA__CHECK
Breakpoint 1 at 0x40154c: file test-class-pascal.pas, line 23.
(gdb) r
Starting program: e:\pas\test/./test-class-pascal.exe
[New Thread 7108.0x1b80]

Breakpoint 1, TA__CHECK (B=0x1523870, this=<error reading variable>)
    at test-class-pascal.pas:23
23        check:=(x < b.x);
(gdb)

  This problem can be reproduced in C++,
but only after some post-handling of generated assembler.
The reason is that recent GCC generate "this:p" stab entries
for "this" hidden variable.

gcc -gstabs+ --save-temps -o testclass test-class.cc

# Using sed to convert this into $t to show the pproblem:
$ sed -i "s:this:\$t:" test-class.s

# Compiling modified assembler
$ gcc -o test-class-mod test-class.s

$ gdb ./test-class-mod
GNU gdb (GDB) 7.6.1
# Same with recent Git trunk 
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 "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from e:\pas\test\test-class-mod.exe...done.
(gdb) b A::check(A)
Breakpoint 1 at 0x4016c5: file test-class.cc, line 16.
(gdb) r
Starting program: e:\pas\test/./test-class-mod.exe
[New Thread 6028.0x1b68]

Breakpoint 1, A::check (this=<error reading variable>, b=...)
    at test-class.cc:16
16        return x < y;
(gdb)
Comment 1 Pierre Muller 2015-01-07 23:11:01 UTC
Created attachment 8055 [details]
Pascal equivalent source

Using free pascal compiler
fpc -gs -Mobjfpc test-class-pascal.pas
and
gdb ./test-class-pascal
with
b TA__CHECK
shows the same problem
that "this" variable is not displayed correctly 
in stack frame.

Note that the problem does not appear elsewhere:
(gdb) p this
works correctly.
Comment 2 Pierre Muller 2015-01-07 23:15:00 UTC
Proposed patch:

2015-01-07  Pierre Muller  <muller@sourceware.org>

       * stabsread.c (define_symbol): Set language for C++ special symbols.

diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 212c7fa..ec883ba 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -675,6 +675,8 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
       SYMBOL_LINE (sym) = 0;   /* unknown */
     }

+  SYMBOL_SET_LANGUAGE (sym, current_subfile->language,
+                      &objfile->objfile_obstack);
   if (is_cplus_marker (string[0]))
     {
       /* Special GNU C++ names.  */
@@ -710,8 +712,6 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
   else
     {
     normal:
-      SYMBOL_SET_LANGUAGE (sym, current_subfile->language,
-                          &objfile->objfile_obstack);
       if (SYMBOL_LANGUAGE (sym) == language_cplus)
        {
          char *name = alloca (p - string + 1);
Comment 3 cvs-commit@gcc.gnu.org 2015-01-08 08:03:56 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  025ac41482555f6273dee37988734a9f88633dbc (commit)
      from  acc018ac031c9e03e012d7d2f3871bfe6b16168d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=025ac41482555f6273dee37988734a9f88633dbc

commit 025ac41482555f6273dee37988734a9f88633dbc
Author: Pierre Muller <muller@ics.u-strasbg.fr>
Date:   Thu Jan 8 08:53:26 2015 +0100

    	Set language for C++ special symbols.
    
    The special handling of C++ special symbol
    generates symbols that have no language.
    Those symbols cannot be displayed correctly in the backtrace stack.
    
    See
    https://sourceware.org/bugzilla/show_bug.cgi?id=17811
    for details and examples in C++ and pascal language.
    
    The patch below fixes this issue, by
    setting language of new symbol before
    special handling of special C++ symbols.
    
    2015-01-07  Pierre Muller  <muller@sourceware.org>
    
    	PR symtab/17811
    	* stabsread.c (define_symbol): Set language for C++ special symbols.

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog   |    5 +++++
 gdb/stabsread.c |    5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)
Comment 4 cvs-commit@gcc.gnu.org 2015-01-11 16:22:51 UTC
The users/hjl/linux/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=025ac41482555f6273dee37988734a9f88633dbc

commit 025ac41482555f6273dee37988734a9f88633dbc
Author: Pierre Muller <muller@ics.u-strasbg.fr>
Date:   Thu Jan 8 08:53:26 2015 +0100

    	Set language for C++ special symbols.
    
    The special handling of C++ special symbol
    generates symbols that have no language.
    Those symbols cannot be displayed correctly in the backtrace stack.
    
    See
    https://sourceware.org/bugzilla/show_bug.cgi?id=17811
    for details and examples in C++ and pascal language.
    
    The patch below fixes this issue, by
    setting language of new symbol before
    special handling of special C++ symbols.
    
    2015-01-07  Pierre Muller  <muller@sourceware.org>
    
    	PR symtab/17811
    	* stabsread.c (define_symbol): Set language for C++ special symbols.
Comment 5 Tom Tromey 2018-03-29 18:19:41 UTC
This looks like it was fixed a couple of years ago.