public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30315] New: GDB not showing variable that is supposed to be there
@ 2023-04-05 13:39 hluaw at connect dot ust.hk
  2023-04-05 14:36 ` [Bug gdb/30315] " tromey at sourceware dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: hluaw at connect dot ust.hk @ 2023-04-05 13:39 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 30315
           Summary: GDB not showing variable that is supposed to be there
           Product: gdb
           Version: 13.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: hluaw at connect dot ust.hk
  Target Milestone: ---

Given the following code:

#include "stdint.h"
#include "string.h"
#include <stdio.h>
int a, b;
char* c;
static int func_1() {
  int i = 0;
  for (; i < 4; i++)
    ;
  for (; a <= 4;) {
    uint16_t d;
    b = 0;
    return b;
    { int i; }
  }
  return b;
}
int main() {
  func_1();
  printf(c);
}

Compiled with gcc 12.2.0 and -O1 -g

The DWARF says that i persists until func_1 exits

Breakpoint 1, func_1 () at r.c:10
10        for (; a <= 4;) {
(gdb) info addr i
Symbol "i" is multi-location:
  Range 0x40112a-0x40112a: the constant 0
  Range 0x40112a-0x40112a: the constant 1
  Range 0x40112a-0x40112a: the constant 2
  Range 0x40112a-0x40112a: the constant 3
  Range 0x40112a-0x40113d: the constant 4
.
(gdb) p i
$1 = 4

But GDB says i is <optimized out> prematurely at line 12 with $pc = 0x401133
still in the range of func_1

(gdb) p i
$2 = <optimized out>
(gdb) p $pc
$3 = (void (*)()) 0x401133 <main+13>
(gdb)

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

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

end of thread, other threads:[~2024-01-20 16:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-05 13:39 [Bug gdb/30315] New: GDB not showing variable that is supposed to be there hluaw at connect dot ust.hk
2023-04-05 14:36 ` [Bug gdb/30315] " tromey at sourceware dot org
2024-01-20 16:19 ` ssbssa at sourceware dot org
2024-01-20 16:34 ` ssbssa at sourceware 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).