This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Argument pointers, dwarf and prologue analysis
How about full assembly and debug info for some case we get wrong? At
least three frames where the middle one uses its arguments after the
call site, so we have a non-leaf function to look at.
ok, here we go:
tausq@hiauly3:~$ cat dwarfbug.c
void foo(int a, int b, int c, int d, int e)
{
a = a;
}
void bar(int a, int b, int c)
{
b = b;
foo(5, 6, 7, 8, 9);
a = a;
}
int main(int argc, char **argv)
{
bar(1,2,3);
return 0;
}
tausq@hiauly3:~$ gcc -g -o dwarfbug dwarfbug.c
tausq@hiauly3:~$ src/build64/gdb/gdb ./dwarfbug
GNU gdb 6.3.50.20051115-cvs
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "hppa64-hp-hpux11.11"...
(gdb) b foo
Breakpoint 1 at 0x4000000000002418: file dwarfbug.c, line 4.
(gdb) run
Starting program: /home/tausq/dwarfbug
Breakpoint 1, foo (a=5, b=6, c=7, d=8, e=9) at dwarfbug.c:4
4 }
(gdb) bt
#0 foo (a=5, b=6, c=7, d=8, e=9) at dwarfbug.c:4
#1 0x4000000000002474 in bar (a=5, b=6, c=7) at dwarfbug.c:9
#2 0x40000000000024d0 in main (argc=5, argv=0x6) at dwarfbug.c:15
(gdb) quit
The program is running. Exit anyway? (y or n) y
Assembly and readelf -wi output attached.
randolph
.LEVEL 2.0w
.file "dwarfbug.c"
.version "01.01"
.file 1 "dwarfbug.c"
.section .debug_abbrev,"",@progbits
L$debug_abbrev0000
.section .debug_info,"",@progbits
L$debug_info0000
.section .debug_line,"",@progbits
L$debug_line0000
.text
L$text0000
.align 8
.globl foo
.type foo, @function
L$FB0003
.loc 1 2 0
foo
.PROC
.CALLINFO FRAME=80,NO_CALLS,SAVE_SP,ENTRY_GR=3
.ENTRY
copy %r3,%r1
copy %r30,%r3
std,ma %r1,80(%r30)
std %r3,-8(%r30)
ldo -64(%r29),%r19
stw %r26,4(%r19)
stw %r25,12(%r19)
stw %r24,20(%r19)
stw %r23,28(%r19)
stw %r22,36(%r19)
.loc 1 4 0
ldo 64(%r3),%r30
ldd,mb -64(%r30),%r3
bve,n (%r2)
.EXIT
.PROCEND
L$FE0003
.size foo, .-foo
.align 8
.globl bar
.type bar, @function
L$FB0005
.loc 1 7 0
bar
.PROC
.CALLINFO FRAME=144,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=4
.ENTRY
std %r2,-16(%r30)
copy %r3,%r1
copy %r30,%r3
std,ma %r1,144(%r30)
std %r3,-8(%r30)
std %r4,16(%r3)
ldo -64(%r29),%r19
stw %r26,4(%r19)
stw %r25,12(%r19)
stw %r24,20(%r19)
.loc 1 9 0
ldi 5,%r26
ldi 6,%r25
ldi 7,%r24
ldi 8,%r23
ldi 9,%r22
ldo -48(%r30),%r29
copy %r27,%r4
b,l foo,%r2
nop
copy %r4,%r27
.loc 1 11 0
ldd -16(%r3),%r2
ldd 16(%r3),%r4
ldo 64(%r3),%r30
ldd,mb -64(%r30),%r3
bve,n (%r2)
.EXIT
.PROCEND
L$FE0005
.size bar, .-bar
.align 8
.globl main
.type main, @function
L$FB0007
.loc 1 14 0
main
.PROC
.CALLINFO FRAME=144,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=4
.ENTRY
std %r2,-16(%r30)
copy %r3,%r1
copy %r30,%r3
std,ma %r1,144(%r30)
std %r3,-8(%r30)
std %r4,16(%r3)
ldo -64(%r29),%r19
stw %r26,4(%r19)
std %r25,8(%r19)
.loc 1 15 0
ldi 1,%r26
ldi 2,%r25
ldi 3,%r24
ldo -48(%r30),%r29
copy %r27,%r4
b,l bar,%r2
nop
copy %r4,%r27
.loc 1 16 0
ldi 0,%r19
.loc 1 17 0
copy %r19,%r28
ldd -16(%r3),%r2
ldd 16(%r3),%r4
ldo 64(%r3),%r30
ldd,mb -64(%r30),%r3
bve,n (%r2)
.EXIT
.PROCEND
L$FE0007
.size main, .-main
L$etext0000
.section .debug_info
.word 0x155
.half 0x2
.word L$debug_abbrev0000
.byte 0x8
.uleb128 0x1
.word L$debug_line0000
.dword L$etext0000
.dword L$text0000
.stringz "dwarfbug.c"
.stringz "/home/tausq"
.stringz "GNU C 3.3.4 20040423 (prerelease)"
.byte 0x1
.uleb128 0x2
.word 0xb6
.byte 0x1
.stringz "foo"
.byte 0x1
.byte 0x2
.byte 0x1
.dword L$FB0003
.dword L$FE0003
.byte 0x1
.byte 0x53
.uleb128 0x3
.stringz "a"
.byte 0x1
.byte 0x1
.word 0xb6
.byte 0x2
.byte 0x83
.sleb128 4
.uleb128 0x3
.stringz "b"
.byte 0x1
.byte 0x1
.word 0xb6
.byte 0x2
.byte 0x83
.sleb128 12
.uleb128 0x3
.stringz "c"
.byte 0x1
.byte 0x1
.word 0xb6
.byte 0x2
.byte 0x83
.sleb128 20
.uleb128 0x3
.stringz "d"
.byte 0x1
.byte 0x1
.word 0xb6
.byte 0x2
.byte 0x83
.sleb128 28
.uleb128 0x3
.stringz "e"
.byte 0x1
.byte 0x1
.word 0xb6
.byte 0x2
.byte 0x83
.sleb128 36
.byte 0x0
.uleb128 0x4
.stringz "int"
.byte 0x4
.byte 0x5
.uleb128 0x2
.word 0x101
.byte 0x1
.stringz "bar"
.byte 0x1
.byte 0x7
.byte 0x1
.dword L$FB0005
.dword L$FE0005
.byte 0x1
.byte 0x53
.uleb128 0x3
.stringz "a"
.byte 0x1
.byte 0x6
.word 0xb6
.byte 0x2
.byte 0x83
.sleb128 4
.uleb128 0x3
.stringz "b"
.byte 0x1
.byte 0x6
.word 0xb6
.byte 0x2
.byte 0x83
.sleb128 12
.uleb128 0x3
.stringz "c"
.byte 0x1
.byte 0x6
.word 0xb6
.byte 0x2
.byte 0x83
.sleb128 20
.byte 0x0
.uleb128 0x5
.word 0x144
.byte 0x1
.stringz "main"
.byte 0x1
.byte 0xe
.byte 0x1
.word 0xb6
.dword L$FB0007
.dword L$FE0007
.byte 0x1
.byte 0x53
.uleb128 0x3
.stringz "argc"
.byte 0x1
.byte 0xd
.word 0xb6
.byte 0x2
.byte 0x83
.sleb128 4
.uleb128 0x3
.stringz "argv"
.byte 0x1
.byte 0xd
.word 0x144
.byte 0x2
.byte 0x83
.sleb128 8
.byte 0x0
.uleb128 0x6
.byte 0x8
.word 0x14a
.uleb128 0x6
.byte 0x8
.word 0x150
.uleb128 0x4
.stringz "char"
.byte 0x1
.byte 0x6
.byte 0x0
.section .debug_abbrev
.uleb128 0x1
.uleb128 0x11
.byte 0x1
.uleb128 0x10
.uleb128 0x6
.uleb128 0x12
.uleb128 0x1
.uleb128 0x11
.uleb128 0x1
.uleb128 0x3
.uleb128 0x8
.uleb128 0x1b
.uleb128 0x8
.uleb128 0x25
.uleb128 0x8
.uleb128 0x13
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0x2
.uleb128 0x2e
.byte 0x1
.uleb128 0x1
.uleb128 0x13
.uleb128 0x3f
.uleb128 0xc
.uleb128 0x3
.uleb128 0x8
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x27
.uleb128 0xc
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x1
.uleb128 0x40
.uleb128 0xa
.byte 0x0
.byte 0x0
.uleb128 0x3
.uleb128 0x5
.byte 0x0
.uleb128 0x3
.uleb128 0x8
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x2
.uleb128 0xa
.byte 0x0
.byte 0x0
.uleb128 0x4
.uleb128 0x24
.byte 0x0
.uleb128 0x3
.uleb128 0x8
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3e
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0x5
.uleb128 0x2e
.byte 0x1
.uleb128 0x1
.uleb128 0x13
.uleb128 0x3f
.uleb128 0xc
.uleb128 0x3
.uleb128 0x8
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x27
.uleb128 0xc
.uleb128 0x49
.uleb128 0x13
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x1
.uleb128 0x40
.uleb128 0xa
.byte 0x0
.byte 0x0
.uleb128 0x6
.uleb128 0xf
.byte 0x0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0x0
.byte 0x0
.byte 0x0
.section .debug_pubnames,"",@progbits
.word 0x27
.half 0x2
.word L$debug_info0000
.word 0x159
.word 0x5a
.stringz "foo"
.word 0xbd
.stringz "bar"
.word 0x101
.stringz "main"
.word 0x0
.section .debug_aranges,"",@progbits
.word 0x2c
.half 0x2
.word L$debug_info0000
.byte 0x8
.byte 0x0
.half 0x0
.half 0x0
.dword L$text0000
.dword L$etext0000-L$text0000
.dword 0x0
.dword 0x0
.ident "GCC: (GNU) 3.3.4 20040423 (prerelease)"
The section .debug_info contains:
Compilation Unit @ offset 0x0:
Length: 341
Version: 2
Abbrev Offset: 0
Pointer Size: 8
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
DW_AT_stmt_list : 0
DW_AT_high_pc : 0x40000000000024f0
DW_AT_low_pc : 0x40000000000023f0
DW_AT_name : dwarfbug.c
DW_AT_comp_dir : /home/tausq
DW_AT_producer : GNU C 3.3.4 20040423 (prerelease)
DW_AT_language : 1 (ANSI C)
<1><5a>: Abbrev Number: 2 (DW_TAG_subprogram)
DW_AT_sibling : <b6>
DW_AT_external : 1
DW_AT_name : foo
DW_AT_decl_file : 1
DW_AT_decl_line : 2
DW_AT_prototyped : 1
DW_AT_low_pc : 0x40000000000023f0
DW_AT_high_pc : 0x4000000000002424
DW_AT_frame_base : 1 byte block: 53 (DW_OP_reg3)
<2><79>: Abbrev Number: 3 (DW_TAG_formal_parameter)
DW_AT_name : a
DW_AT_decl_file : 1
DW_AT_decl_line : 1
DW_AT_type : <b6>
DW_AT_location : 2 byte block: 83 4 (DW_OP_breg19: 4)
<2><85>: Abbrev Number: 3 (DW_TAG_formal_parameter)
DW_AT_name : b
DW_AT_decl_file : 1
DW_AT_decl_line : 1
DW_AT_type : <b6>
DW_AT_location : 2 byte block: 83 c (DW_OP_breg19: 12)
<2><91>: Abbrev Number: 3 (DW_TAG_formal_parameter)
DW_AT_name : c
DW_AT_decl_file : 1
DW_AT_decl_line : 1
DW_AT_type : <b6>
DW_AT_location : 2 byte block: 83 14 (DW_OP_breg19: 20)
<2><9d>: Abbrev Number: 3 (DW_TAG_formal_parameter)
DW_AT_name : d
DW_AT_decl_file : 1
DW_AT_decl_line : 1
DW_AT_type : <b6>
DW_AT_location : 2 byte block: 83 1c (DW_OP_breg19: 28)
<2><a9>: Abbrev Number: 3 (DW_TAG_formal_parameter)
DW_AT_name : e
DW_AT_decl_file : 1
DW_AT_decl_line : 1
DW_AT_type : <b6>
DW_AT_location : 2 byte block: 83 24 (DW_OP_breg19: 36)
<1><b6>: Abbrev Number: 4 (DW_TAG_base_type)
DW_AT_name : int
DW_AT_byte_size : 4
DW_AT_encoding : 5 (signed)
<1><bd>: Abbrev Number: 2 (DW_TAG_subprogram)
DW_AT_sibling : <101>
DW_AT_external : 1
DW_AT_name : bar
DW_AT_decl_file : 1
DW_AT_decl_line : 7
DW_AT_prototyped : 1
DW_AT_low_pc : 0x4000000000002428
DW_AT_high_pc : 0x400000000000248c
DW_AT_frame_base : 1 byte block: 53 (DW_OP_reg3)
<2><dc>: Abbrev Number: 3 (DW_TAG_formal_parameter)
DW_AT_name : a
DW_AT_decl_file : 1
DW_AT_decl_line : 6
DW_AT_type : <b6>
DW_AT_location : 2 byte block: 83 4 (DW_OP_breg19: 4)
<2><e8>: Abbrev Number: 3 (DW_TAG_formal_parameter)
DW_AT_name : b
DW_AT_decl_file : 1
DW_AT_decl_line : 6
DW_AT_type : <b6>
DW_AT_location : 2 byte block: 83 c (DW_OP_breg19: 12)
<2><f4>: Abbrev Number: 3 (DW_TAG_formal_parameter)
DW_AT_name : c
DW_AT_decl_file : 1
DW_AT_decl_line : 6
DW_AT_type : <b6>
DW_AT_location : 2 byte block: 83 14 (DW_OP_breg19: 20)
<1><101>: Abbrev Number: 5 (DW_TAG_subprogram)
DW_AT_sibling : <144>
DW_AT_external : 1
DW_AT_name : main
DW_AT_decl_file : 1
DW_AT_decl_line : 14
DW_AT_prototyped : 1
DW_AT_type : <b6>
DW_AT_low_pc : 0x4000000000002490
DW_AT_high_pc : 0x40000000000024f0
DW_AT_frame_base : 1 byte block: 53 (DW_OP_reg3)
<2><125>: Abbrev Number: 3 (DW_TAG_formal_parameter)
DW_AT_name : argc
DW_AT_decl_file : 1
DW_AT_decl_line : 13
DW_AT_type : <b6>
DW_AT_location : 2 byte block: 83 4 (DW_OP_breg19: 4)
<2><134>: Abbrev Number: 3 (DW_TAG_formal_parameter)
DW_AT_name : argv
DW_AT_decl_file : 1
DW_AT_decl_line : 13
DW_AT_type : <144>
DW_AT_location : 2 byte block: 83 8 (DW_OP_breg19: 8)
<1><144>: Abbrev Number: 6 (DW_TAG_pointer_type)
DW_AT_byte_size : 8
DW_AT_type : <14a>
<1><14a>: Abbrev Number: 6 (DW_TAG_pointer_type)
DW_AT_byte_size : 8
DW_AT_type : <150>
<1><150>: Abbrev Number: 4 (DW_TAG_base_type)
DW_AT_name : char
DW_AT_byte_size : 1
DW_AT_encoding : 6 (signed char)