public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/31745] New: [gdb/symtab] Can't print pre-defined macros with binaries built with clang -save-temps
Date: Thu, 16 May 2024 10:34:39 +0000	[thread overview]
Message-ID: <bug-31745-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 31745
           Summary: [gdb/symtab] Can't print pre-defined macros with
                    binaries built with clang -save-temps
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Consider a hello world compiled with clang:
...
$ clang-15 -gdwarf-5 -g3 -fdebug-macro ~/data/hello.c
...

Printing a pre-defined macro works fine (thanks to commit e7e7469e7a3 "gdb: Fix
issue with Clang CLI macros", the fix for PR29034):
...
$ gdb -q -batch a.out -ex start -ex "p __DBL_MAX__"
Temporary breakpoint 1 at 0x6af: file /home/vries/data/hello.c, line 6.

Temporary breakpoint 1, main () at /home/vries/data/hello.c:6
6         printf ("hello\n");
$1 = 1.7976931348623157e+308
...

However, if we add -save-temps:
...
$ clang-15 -gdwarf-5 -g3 -fdebug-macro ~/data/hello.c -save-temps
hello.s:4:2: warning: inconsistent use of MD5 checksums
        .file   1 "/home/vries" "data/hello.c"
        ^
...
we get:
...
$ gdb -q -batch a.out -ex start -ex "p __DBL_MAX__"
Temporary breakpoint 1 at 0x6af: file /home/vries/data/hello.c, line 6.

Temporary breakpoint 1, main () at /home/vries/data/hello.c:6
6         printf ("hello\n");
No symbol "__DBL_MAX__" in current context.
...

It's possible something is wrong with the debug info, so let's try to see what
lldb does:
...
$ lldb -b a.out -o "b main" -o run -o "print __DBL_MAX__"
(lldb) target create "a.out"
Current executable set to '/home/vries/gcc/a.out' (x86_64).
(lldb) b main
Breakpoint 1: where = a.out`main + 15 at hello.c:6:3, address =
0x00000000000006af
(lldb) run
Process 10477 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00005555555546af a.out`main at hello.c:6:3
   3    int
   4    main (void)
   5    {
-> 6      printf ("hello\n");
   7      return 0;
   8    }

Process 10477 launched: '/home/vries/gcc/a.out' (x86_64)
(lldb) print __DBL_MAX__
(double) $0 = 1.7976931348623157E+308
...

It has no problems getting the info, which would suggest that gdb could be
fixed as well.

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

             reply	other threads:[~2024-05-16 10:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16 10:34 vries at gcc dot gnu.org [this message]
2024-05-16 12:08 ` [Bug symtab/31745] " vries at gcc dot gnu.org
2024-05-17 11:16 ` [Bug macros/31745] [gdb/macros] " vries at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-31745-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).