Bug 250414

Summary: gdb info args wrong for main
Product: [Fedora] Fedora Reporter: Luciano Rocha <lfrocha+rhbugzilla>
Component: gdbAssignee: Jan Kratochvil <jan.kratochvil>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: 7   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
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: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
test case
none
gdb session for test case none

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