Bug 250414 - gdb info args wrong for main
gdb info args wrong for main
Status: CLOSED DUPLICATE of bug 228744
Product: Fedora
Classification: Fedora
Component: gdb (Show other bugs)
7
All Linux
low Severity low
: ---
: ---
Assigned To: Jan Kratochvil
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-08-01 09:57 EDT by Luciano Rocha
Modified: 2007-11-30 17:12 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-08-01 10:01:30 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
test case (265 bytes, text/x-csrc)
2007-08-01 09:57 EDT, Luciano Rocha
no flags Details
gdb session for test case (1.74 KB, text/plain)
2007-08-01 09:59 EDT, Luciano Rocha
no flags Details

  None (edit)
Description Luciano Rocha 2007-08-01 09:57:58 EDT
Description of problem:
gdb loses information about args for main() if only one statement refers to them.

Example:

int main(int argc, char *argv[])
{
        int fd;

        fd = open(argv[1], O_RDONLY);
        return 0;
}

/usr/bin/gcc -ggdb3 -Wall -O0 test2.c  -o test2
gdb test2
(gdb) b main
Breakpoint 1 at 0x80483b5: file test2.c, line 13.
(gdb) r asdf

Breakpoint 1, main (argc=2, argv=0xbff05ad4) at test2.c:13
13              fd = open(argv[1], O_RDONLY);
(gdb) info arg
argc = 2
argv = (char **) 0xbff05ad4
(gdb) n
15              return 0;
(gdb) info arg
argc = Cannot access memory at address 0xffffffc8


Now, with another fd = open(argv[1], O_RDONLY) (or printf(.., argc, argv[0])):
(gdb) b main
Breakpoint 1 at 0x80483b8: file test2.c, line 13.
(gdb) r asdf

Breakpoint 1, main (argc=2, argv=0xbfb9cf64) at test2.c:13
13              fd = open(argv[1], O_RDONLY);
(gdb) info arg
argc = 2
argv = (char **) 0xbfb9cf64
(gdb) n
14              fd = open(argv[1], O_RDONLY);
(gdb) info arg
argc = 2
argv = (char **) 0xbfb9cf64
(gdb) n
16              return 0;
(gdb) info arg
argc = 2
argv = (char **) 0xbfb9cf64

Version-Release number of selected component (if applicable):
gdb-6.6-15.fc7: GNU gdb Red Hat Linux (6.6-15.fc7rh)
gcc-4.1.2-12: gcc (GCC) 4.1.2 20070502 (Red Hat 4.1.2-12)
glibc-2.6-4

How reproducible:
Always, with combinations of -g, -g3, -ggdb, -ggdb3, -O0, -O1 and -O2.

Additional info:
The original test and its gdb session will be added as attachments.

The original program had a single use of argc/argv:
sinit(argv[0]), that called openlog(arg, ...).
Comment 1 Luciano Rocha 2007-08-01 09:57:59 EDT
Created attachment 160412 [details]
test case
Comment 2 Luciano Rocha 2007-08-01 09:59:08 EDT
Created attachment 160414 [details]
gdb session for test case
Comment 3 Jan Kratochvil 2007-08-01 10:01:30 EDT

*** This bug has been marked as a duplicate of 228744 ***

Note You need to log in before you can comment on or make changes to this bug.