Bug 250414 - gdb info args wrong for main
Summary: gdb info args wrong for main
Status: CLOSED DUPLICATE of bug 228744
Alias: None
Product: Fedora
Classification: Fedora
Component: gdb   
(Show other bugs)
Version: 7
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Jan Kratochvil
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-08-01 13:57 UTC by Luciano Rocha
Modified: 2007-11-30 22:12 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-08-01 14:01:30 UTC
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 13:57 UTC, Luciano Rocha
no flags Details
gdb session for test case (1.74 KB, text/plain)
2007-08-01 13:59 UTC, Luciano Rocha
no flags Details

Description Luciano Rocha 2007-08-01 13:57:58 UTC
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 13:57:59 UTC
Created attachment 160412 [details]
test case

Comment 2 Luciano Rocha 2007-08-01 13:59:08 UTC
Created attachment 160414 [details]
gdb session for test case

Comment 3 Jan Kratochvil 2007-08-01 14:01:30 UTC

*** 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.