* [PATCH] Add option to control checking of inner frames when doing a backtrace
@ 2012-10-02 17:58 Joshua Watt
2012-10-03 9:29 ` Abid, Hafiz
2012-10-03 13:57 ` Joel Brobecker
0 siblings, 2 replies; 7+ messages in thread
From: Joshua Watt @ 2012-10-02 17:58 UTC (permalink / raw)
To: gdb-patches
Please note: this is the first patch I have ever submitted for GDB, so
please let
me know if there are any problems. -- Joshua Watt
This patch allows the user to turn off the checking for inner frames
when performing
a backtrace using the command:
set backtrace check-inner off
This is useful if a thread is switching execution to run on another
stack, as this will
often cause the inner frame condition to fail.
diff -U 5 -Nar gdb-7.5.50.20121002-orig/gdb/frame.c
gdb-7.5.50.20121002/gdb/frame.c
--- gdb-7.5.50.20121002-orig/gdb/frame.c 2012-09-17 02:15:48 -0500
+++ gdb-7.5.50.20121002/gdb/frame.c 2012-10-02 12:25:47 -0500
@@ -205,10 +205,20 @@
_("An upper bound on the number "
"of backtrace levels is %s.\n"),
value);
}
+static unsigned int backtrace_check_inner = TRUE;
+static void
+show_backtrace_check_inner (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("Whether backtraces should check for inner "
+ "frames is %s.\n"),
+ value);
+}
+
static void
fprint_field (struct ui_file *file, const char *name, int p, CORE_ADDR addr)
{
if (p)
@@ -1670,11 +1680,12 @@
/* Check that this frame's ID isn't inner to (younger, below, next)
the next frame. This happens when a frame unwind goes backwards.
This check is valid only if this frame and the next frame are NORMAL.
See the comment at frame_id_inner for details. */
- if (get_frame_type (this_frame) == NORMAL_FRAME
+ if (backtrace_check_inner
+ && get_frame_type (this_frame) == NORMAL_FRAME
&& this_frame->next->unwind->type == NORMAL_FRAME
&& frame_id_inner (get_frame_arch (this_frame->next), this_id,
get_frame_id (this_frame->next)))
{
CORE_ADDR this_pc_in_block;
@@ -2504,10 +2515,25 @@
NULL,
show_backtrace_limit,
&set_backtrace_cmdlist,
&show_backtrace_cmdlist);
+ add_setshow_boolean_cmd ("check-inner", class_obscure,
+ &backtrace_check_inner, _("\
+Sets whether backtraces will check if a frame is inner to the previous frame"),
+ _("\
+Shows whether backtraces will check if a frame is inner to the
previous frame"),
+ _("\
+Normally frames are laid out in a specific order on the stack. This
controls\n\
+whether GDB will validate that the frames are in the correct order. Frames\n\
+can commonly be out of order if a thread switches to a different
stack during\n\
+execution"),
+ NULL,
+ show_backtrace_check_inner,
+ &set_backtrace_cmdlist,
+ &show_backtrace_cmdlist);
+
/* Debug this files internals. */
add_setshow_zuinteger_cmd ("frame", class_maintenance, &frame_debug, _("\
Set frame debugging."), _("\
Show frame debugging."), _("\
When non-zero, frame specific internal debugging is enabled."),
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] Add option to control checking of inner frames when doing a backtrace
2012-10-02 17:58 [PATCH] Add option to control checking of inner frames when doing a backtrace Joshua Watt
@ 2012-10-03 9:29 ` Abid, Hafiz
2012-10-03 14:03 ` Joshua Watt
2012-10-03 13:57 ` Joel Brobecker
1 sibling, 1 reply; 7+ messages in thread
From: Abid, Hafiz @ 2012-10-03 9:29 UTC (permalink / raw)
To: Joshua Watt, gdb-patches
Hi,
You may need copyright assignment. Also the patch needs change log entry. See some of my comments inline.
> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] On Behalf Of Joshua Watt
> Sent: Tuesday, October 02, 2012 6:59 PM
> To: gdb-patches@sourceware.org
> Subject: [PATCH] Add option to control checking of inner frames when
> doing a backtrace
>
> Please note: this is the first patch I have ever submitted for GDB, so
> please let
> me know if there are any problems. -- Joshua Watt
>
>
> This patch allows the user to turn off the checking for inner frames
> when performing
> a backtrace using the command:
>
> set backtrace check-inner off
>
> This is useful if a thread is switching execution to run on another
> stack, as this will
> often cause the inner frame condition to fail.
I don't understand the motivation. Can you please explain a bit more.
>
> diff -U 5 -Nar gdb-7.5.50.20121002-orig/gdb/frame.c
> gdb-7.5.50.20121002/gdb/frame.c
> --- gdb-7.5.50.20121002-orig/gdb/frame.c 2012-09-17 02:15:48 -0500
> +++ gdb-7.5.50.20121002/gdb/frame.c 2012-10-02 12:25:47 -0500
> @@ -205,10 +205,20 @@
> _("An upper bound on the number "
> "of backtrace levels is %s.\n"),
> value);
> }
>
> +static unsigned int backtrace_check_inner = TRUE;
> +static void
> +show_backtrace_check_inner (struct ui_file *file, int from_tty,
> + struct cmd_list_element *c, const char *value)
> +{
> + fprintf_filtered (file, _("Whether backtraces should check for inner
> "
> + "frames is %s.\n"),
> + value);
> +}
> +
>
> static void
> fprint_field (struct ui_file *file, const char *name, int p, CORE_ADDR
> addr)
> {
> if (p)
> @@ -1670,11 +1680,12 @@
>
> /* Check that this frame's ID isn't inner to (younger, below, next)
> the next frame. This happens when a frame unwind goes backwards.
> This check is valid only if this frame and the next frame are
> NORMAL.
> See the comment at frame_id_inner for details. */
> - if (get_frame_type (this_frame) == NORMAL_FRAME
> + if (backtrace_check_inner
> + && get_frame_type (this_frame) == NORMAL_FRAME
> && this_frame->next->unwind->type == NORMAL_FRAME
> && frame_id_inner (get_frame_arch (this_frame->next), this_id,
> get_frame_id (this_frame->next)))
> {
> CORE_ADDR this_pc_in_block;
> @@ -2504,10 +2515,25 @@
> NULL,
> show_backtrace_limit,
> &set_backtrace_cmdlist,
> &show_backtrace_cmdlist);
>
> + add_setshow_boolean_cmd ("check-inner", class_obscure,
> + &backtrace_check_inner, _("\
> +Sets whether backtraces will check if a frame is inner to the previous
> frame"),
> + _("\
> +Shows whether backtraces will check if a frame is inner to the
> previous frame"),
> + _("\
> +Normally frames are laid out in a specific order on the stack. This
> controls\n\
> +whether GDB will validate that the frames are in the correct order.
> Frames\n\
> +can commonly be out of order if a thread switches to a different
> stack during\n\
> +execution"),
> + NULL,
> + show_backtrace_check_inner,
> + &set_backtrace_cmdlist,
> + &show_backtrace_cmdlist);
> +
> /* Debug this files internals. */
> add_setshow_zuinteger_cmd ("frame", class_maintenance, &frame_debug,
> _("\
> Set frame debugging."), _("\
> Show frame debugging."), _("\
> When non-zero, frame specific internal debugging is enabled."),
This command will need documentation(see gdb/doc/gdb.texinfo in GDB source base).
Regards,
Abid
--
Hafiz Abid Qadeer
Mentor Graphics
hafiz_abid@mentor.com
+44 161 926 1630
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add option to control checking of inner frames when doing a backtrace
2012-10-02 17:58 [PATCH] Add option to control checking of inner frames when doing a backtrace Joshua Watt
2012-10-03 9:29 ` Abid, Hafiz
@ 2012-10-03 13:57 ` Joel Brobecker
2012-10-05 21:10 ` Joshua Watt
2012-10-06 18:34 ` Jan Kratochvil
1 sibling, 2 replies; 7+ messages in thread
From: Joel Brobecker @ 2012-10-03 13:57 UTC (permalink / raw)
To: Joshua Watt; +Cc: gdb-patches
Hi Joshua,
> Please note: this is the first patch I have ever submitted for GDB, so
> please let me know if there are any problems. -- Joshua Watt
Thanks for sending in a patch. I suggest you read through the
gdb/CONTRIBUTE file. It should answer most of the questions.
But I still think that it's just better overall to dump the check
rather than providing yet another obscure switch which, normally,
would require us to test that it actually works as expected.
Just for your future contributions, I am including some little notes
below, that should help you conform to our project's development style
better next time... We're mostly following the GNU Coding Style with
some project-specific additions.
And one last thing: New commands and settings should be documented
in the gdb/NEWS files as well as the GDB manual (gdb/doc/gdb.texinfo).
========================================================================
Aside from missing a ChangeLog entry, GDB's coding style also
require that every global variable and function be documented.
For instance:
> +static unsigned int backtrace_check_inner = TRUE;
There should be a comment before backtrace_check_inner's definition:
/* Bla bla bla. */
static unsigned int backtrace_check_inner = TRUE;
And while looking at this, we typically use int, and zero/nonzero
values for this type of usage. If you look at add_setshow_boolean_cmd,
you'll see that the value passed is an int*.
Similarly:
> +static void
> +show_backtrace_check_inner (struct ui_file *file, int from_tty,
> + struct cmd_list_element *c, const char *value)
And there should also be a comment before show_backtrace_check_inner.
For functions, we add an empty line between documentation and function.
Another small nit: The last line needs to be aligned with the rest
of the arguments (using tabs, and then optionally spaces):
show_backtrace_check_inner (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
--
Joel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add option to control checking of inner frames when doing a backtrace
2012-10-03 9:29 ` Abid, Hafiz
@ 2012-10-03 14:03 ` Joshua Watt
0 siblings, 0 replies; 7+ messages in thread
From: Joshua Watt @ 2012-10-03 14:03 UTC (permalink / raw)
To: Abid, Hafiz; +Cc: gdb-patches
>> This patch allows the user to turn off the checking for inner frames
>> when performing
>> a backtrace using the command:
>>
>> set backtrace check-inner off
>>
>> This is useful if a thread is switching execution to run on another
>> stack, as this will
>> often cause the inner frame condition to fail.
>
> I don't understand the motivation. Can you please explain a bit more.
See: http://sourceware.org/ml/gdb/2012-10/msg00001.html for the
discussion that lead to this patch.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add option to control checking of inner frames when doing a backtrace
2012-10-03 13:57 ` Joel Brobecker
@ 2012-10-05 21:10 ` Joshua Watt
2012-10-06 18:34 ` Jan Kratochvil
1 sibling, 0 replies; 7+ messages in thread
From: Joshua Watt @ 2012-10-05 21:10 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
> But I still think that it's just better overall to dump the check
> rather than providing yet another obscure switch which, normally,
> would require us to test that it actually works as expected.
>
That would be fine with me. I can submit a different patch that does that.
It wasn't clear to me from the previous discussions whether that was for
sure what we wanted to do.
--
Joshua Watt
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add option to control checking of inner frames when doing a backtrace
2012-10-03 13:57 ` Joel Brobecker
2012-10-05 21:10 ` Joshua Watt
@ 2012-10-06 18:34 ` Jan Kratochvil
2012-10-07 5:52 ` Jan Kratochvil
1 sibling, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2012-10-06 18:34 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Joshua Watt, gdb-patches
On Wed, 03 Oct 2012 15:56:55 +0200, Joel Brobecker wrote:
> But I still think that it's just better overall to dump the check
> rather than providing yet another obscure switch which, normally,
> would require us to test that it actually works as expected.
I agree a switch is wrong, GDB should support the detection of inferior
alternate stack ABI. The way how the alternate stack works in this OS/ABI has
not been disclosed here yet.
Here is a testcase to verify the GDB useful feature of avoiding infinite
backtrace loops is preserved. Sure this is an artificial testcase but various
stack corruptions happen in real world which would be no longer caught early
causing more confusion by displaying frames which make no sense:
After the intended removal of the detection:
(gdb) bt
#0 f (i=1) at gdb.arch/amd64-inner-frame.c:33
#1 0x00000000004005ea in f (i=0) at gdb.arch/amd64-inner-frame.c:30
#2 0x00000000004005ea in f (i=1) at gdb.arch/amd64-inner-frame.c:30
#3 0x00000000004005ea in f (i=0) at gdb.arch/amd64-inner-frame.c:30
#4 0x00000000004005ea in f (i=1) at gdb.arch/amd64-inner-frame.c:30
[...]
#41 0x00000000004005ea in f (i=0) at gdb.arch/amd64-inner-frame.c:30
#42 0x00000000004005ea in f (i=1) at gdb.arch/amd64-inner-frame.c:30
---Type <return> to continue, or q <return> to quit---
Current GDB:
(gdb) bt
#0 f (i=1) at gdb.arch/amd64-inner-frame.c:33
#1 0x00000000004005ea in f (i=0) at gdb.arch/amd64-inner-frame.c:30
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Google says 217,000 results for this detection:
https://www.google.com/search?hl=en&lr=lang_en&num=100&q=%22previous%20frame%20inner%20to%20this%20frame%20corrupt%20stack%22
I understand some may be the problem why you want to disable it but
I believe most of the cases is a correct detection the unwind no
longer makes sense.
Red Hat Bugzilla 180:
https://bugzilla.redhat.com/buglist.cgi?query_format=advanced&list_id=641972&longdesc=previous%20frame%20inner%20to%20this%20frame&longdesc_type=substr
ing
Those are not all - I have no idea which portion - as there is a Red
Hat Bugzilla policy dumps/backtraces should be attached and not put
into comments to keep the comments search useful.
Regards,
Jan
gdb/testsuite/
2012-10-06 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.arch/amd64-inner-frame.S: New file.
* gdb.arch/amd64-inner-frame.c: New file.
* gdb.arch/amd64-inner-frame.exp: New file.
diff --git a/gdb/testsuite/gdb.arch/amd64-inner-frame.S b/gdb/testsuite/gdb.arch/amd64-inner-frame.S
new file mode 100644
index 0000000..767e60d
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-inner-frame.S
@@ -0,0 +1,509 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2012 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This file is compiled from gdb.arch/amd64-inner-frame.c
+ using -g -dA -S. */
+
+ .file "amd64-inner-frame.c"
+ .text
+.Ltext0:
+ .local v
+ .comm v,4,4
+ .type f, @function
+f:
+.LFB0:
+ .file 1 "gdb.arch/amd64-inner-frame.c"
+ # gdb.arch/amd64-inner-frame.c:26
+ .loc 1 26 0
+ .cfi_startproc
+# BLOCK 2 seq:0
+# PRED: ENTRY (fallthru)
+ pushq %rbp
+.LCFI0:
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+.LCFI1:
+ .cfi_def_cfa_register 6
+ subq $32, %rsp
+ movl %edi, -20(%rbp)
+ # gdb.arch/amd64-inner-frame.c:27
+ .loc 1 27 0
+ movl $16, %eax
+ subq $1, %rax
+ addq $16, %rax
+ movq $16, -32(%rbp)
+ movl $0, %edx
+ divq -32(%rbp)
+ imulq $16, %rax, %rax
+ subq %rax, %rsp
+ movq %rsp, %rax
+ addq $15, %rax
+ shrq $4, %rax
+ salq $4, %rax
+ movq %rax, -8(%rbp)
+ # gdb.arch/amd64-inner-frame.c:28
+ .loc 1 28 0
+ movq -8(%rbp), %rax
+ movq %rax, -16(%rbp)
+ # gdb.arch/amd64-inner-frame.c:29
+ .loc 1 29 0
+ cmpl $0, -20(%rbp)
+# SUCC: 3 (fallthru) 4
+ je .L2
+# BLOCK 3 seq:1
+# PRED: 2 (fallthru)
+ # gdb.arch/amd64-inner-frame.c:30
+ .loc 1 30 0
+ movl -20(%rbp), %eax
+ subl $1, %eax
+ movl %eax, %edi
+# SUCC: 4 (fallthru)
+ call f
+# BLOCK 4 seq:2
+# PRED: 2 3 (fallthru)
+.L2:
+ # gdb.arch/amd64-inner-frame.c:31
+ .loc 1 31 0
+ cmpl $1, -20(%rbp)
+# SUCC: 5 (fallthru) 6
+ jne .L3
+# BLOCK 5 seq:3
+# PRED: 4 (fallthru)
+ # gdb.arch/amd64-inner-frame.c:32
+ .loc 1 32 0
+ leaq -16(%rbp), %rax
+ subq $48, %rax
+# SUCC: 6 (fallthru)
+ movq %rax, 0(%rbp)
+# BLOCK 6 seq:4
+# PRED: 4 5 (fallthru)
+.L3:
+ # gdb.arch/amd64-inner-frame.c:33
+ .loc 1 33 0
+ movl v(%rip), %eax
+ addl $1, %eax
+ movl %eax, v(%rip)
+ # gdb.arch/amd64-inner-frame.c:34
+ .loc 1 34 0
+ leave
+.LCFI2:
+ .cfi_def_cfa 7, 8
+# SUCC: EXIT [100.0%]
+ ret
+ .cfi_endproc
+.LFE0:
+ .size f, .-f
+ .globl main
+ .type main, @function
+main:
+.LFB1:
+ # gdb.arch/amd64-inner-frame.c:38
+ .loc 1 38 0
+ .cfi_startproc
+# BLOCK 2 seq:0
+# PRED: ENTRY (fallthru)
+ pushq %rbp
+.LCFI3:
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+.LCFI4:
+ .cfi_def_cfa_register 6
+ # gdb.arch/amd64-inner-frame.c:39
+ .loc 1 39 0
+ movl $2, %edi
+ call f
+ # gdb.arch/amd64-inner-frame.c:40
+ .loc 1 40 0
+ movl $0, %eax
+ # gdb.arch/amd64-inner-frame.c:41
+ .loc 1 41 0
+ popq %rbp
+.LCFI5:
+ .cfi_def_cfa 7, 8
+# SUCC: EXIT [100.0%]
+ ret
+ .cfi_endproc
+.LFE1:
+ .size main, .-main
+.Letext0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .long 0x100 # Length of Compilation Unit Info
+ .value 0x2 # DWARF version number
+ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section
+ .byte 0x8 # Pointer Size (in bytes)
+ .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit)
+ .long .LASF9 # DW_AT_producer: "GNU C 4.7.3 20121006 (prerelease)"
+ .byte 0x1 # DW_AT_language
+ .long .LASF10 # DW_AT_name: "gdb.arch/amd64-inner-frame.c"
+ .long .LASF11 # DW_AT_comp_dir: ""
+ .quad .Ltext0 # DW_AT_low_pc
+ .quad .Letext0 # DW_AT_high_pc
+ .long .Ldebug_line0 # DW_AT_stmt_list
+ .uleb128 0x2 # (DIE (0x2d) DW_TAG_base_type)
+ .byte 0x8 # DW_AT_byte_size
+ .byte 0x7 # DW_AT_encoding
+ .long .LASF0 # DW_AT_name: "long unsigned int"
+ .uleb128 0x2 # (DIE (0x34) DW_TAG_base_type)
+ .byte 0x8 # DW_AT_byte_size
+ .byte 0x5 # DW_AT_encoding
+ .long .LASF1 # DW_AT_name: "long int"
+ .uleb128 0x3 # (DIE (0x3b) DW_TAG_base_type)
+ .byte 0x4 # DW_AT_byte_size
+ .byte 0x5 # DW_AT_encoding
+ .ascii "int\0" # DW_AT_name
+ .uleb128 0x2 # (DIE (0x42) DW_TAG_base_type)
+ .byte 0x1 # DW_AT_byte_size
+ .byte 0x8 # DW_AT_encoding
+ .long .LASF2 # DW_AT_name: "unsigned char"
+ .uleb128 0x2 # (DIE (0x49) DW_TAG_base_type)
+ .byte 0x2 # DW_AT_byte_size
+ .byte 0x7 # DW_AT_encoding
+ .long .LASF3 # DW_AT_name: "short unsigned int"
+ .uleb128 0x2 # (DIE (0x50) DW_TAG_base_type)
+ .byte 0x4 # DW_AT_byte_size
+ .byte 0x7 # DW_AT_encoding
+ .long .LASF4 # DW_AT_name: "unsigned int"
+ .uleb128 0x2 # (DIE (0x57) DW_TAG_base_type)
+ .byte 0x1 # DW_AT_byte_size
+ .byte 0x6 # DW_AT_encoding
+ .long .LASF5 # DW_AT_name: "signed char"
+ .uleb128 0x2 # (DIE (0x5e) DW_TAG_base_type)
+ .byte 0x2 # DW_AT_byte_size
+ .byte 0x5 # DW_AT_encoding
+ .long .LASF6 # DW_AT_name: "short int"
+ .uleb128 0x2 # (DIE (0x65) DW_TAG_base_type)
+ .byte 0x8 # DW_AT_byte_size
+ .byte 0x7 # DW_AT_encoding
+ .long .LASF7 # DW_AT_name: "sizetype"
+ .uleb128 0x4 # (DIE (0x6c) DW_TAG_pointer_type)
+ .byte 0x8 # DW_AT_byte_size
+ .uleb128 0x2 # (DIE (0x6e) DW_TAG_base_type)
+ .byte 0x1 # DW_AT_byte_size
+ .byte 0x6 # DW_AT_encoding
+ .long .LASF8 # DW_AT_name: "char"
+ .uleb128 0x5 # (DIE (0x75) DW_TAG_subprogram)
+ .ascii "f\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-inner-frame.c)
+ .byte 0x19 # DW_AT_decl_line
+ .byte 0x1 # DW_AT_prototyped
+ .quad .LFB0 # DW_AT_low_pc
+ .quad .LFE0 # DW_AT_high_pc
+ .long .LLST0 # DW_AT_frame_base
+ .byte 0x1 # DW_AT_GNU_all_tail_call_sites
+ .long 0xb9 # DW_AT_sibling
+ .uleb128 0x6 # (DIE (0x94) DW_TAG_formal_parameter)
+ .ascii "i\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-inner-frame.c)
+ .byte 0x19 # DW_AT_decl_line
+ .long 0x3b # DW_AT_type
+ .byte 0x2 # DW_AT_location
+ .byte 0x91 # DW_OP_fbreg
+ .sleb128 -36
+ .uleb128 0x7 # (DIE (0xa0) DW_TAG_variable)
+ .ascii "l\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-inner-frame.c)
+ .byte 0x1b # DW_AT_decl_line
+ .long 0x6c # DW_AT_type
+ .byte 0x2 # DW_AT_location
+ .byte 0x91 # DW_OP_fbreg
+ .sleb128 -24
+ .uleb128 0x7 # (DIE (0xac) DW_TAG_variable)
+ .ascii "a\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-inner-frame.c)
+ .byte 0x1c # DW_AT_decl_line
+ .long 0xb9 # DW_AT_type
+ .byte 0x2 # DW_AT_location
+ .byte 0x91 # DW_OP_fbreg
+ .sleb128 -32
+ .byte 0 # end of children of DIE 0x75
+ .uleb128 0x8 # (DIE (0xb9) DW_TAG_array_type)
+ .long 0x6c # DW_AT_type
+ .long 0xc9 # DW_AT_sibling
+ .uleb128 0x9 # (DIE (0xc2) DW_TAG_subrange_type)
+ .long 0x65 # DW_AT_type
+ .byte 0 # DW_AT_upper_bound
+ .byte 0 # end of children of DIE 0xb9
+ .uleb128 0xa # (DIE (0xc9) DW_TAG_subprogram)
+ .byte 0x1 # DW_AT_external
+ .long .LASF12 # DW_AT_name: "main"
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-inner-frame.c)
+ .byte 0x25 # DW_AT_decl_line
+ .byte 0x1 # DW_AT_prototyped
+ .long 0x3b # DW_AT_type
+ .quad .LFB1 # DW_AT_low_pc
+ .quad .LFE1 # DW_AT_high_pc
+ .long .LLST1 # DW_AT_frame_base
+ .byte 0x1 # DW_AT_GNU_all_tail_call_sites
+ .uleb128 0x7 # (DIE (0xeb) DW_TAG_variable)
+ .ascii "v\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-inner-frame.c)
+ .byte 0x16 # DW_AT_decl_line
+ .long 0xfe # DW_AT_type
+ .byte 0x9 # DW_AT_location
+ .byte 0x3 # DW_OP_addr
+ .quad v
+ .uleb128 0xb # (DIE (0xfe) DW_TAG_volatile_type)
+ .long 0x3b # DW_AT_type
+ .byte 0 # end of children of DIE 0xb
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .uleb128 0x1 # (abbrev code)
+ .uleb128 0x11 # (TAG: DW_TAG_compile_unit)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x25 # (DW_AT_producer)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x13 # (DW_AT_language)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x1b # (DW_AT_comp_dir)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x10 # (DW_AT_stmt_list)
+ .uleb128 0x6 # (DW_FORM_data4)
+ .byte 0
+ .byte 0
+ .uleb128 0x2 # (abbrev code)
+ .uleb128 0x24 # (TAG: DW_TAG_base_type)
+ .byte 0 # DW_children_no
+ .uleb128 0xb # (DW_AT_byte_size)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3e # (DW_AT_encoding)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .byte 0
+ .byte 0
+ .uleb128 0x3 # (abbrev code)
+ .uleb128 0x24 # (TAG: DW_TAG_base_type)
+ .byte 0 # DW_children_no
+ .uleb128 0xb # (DW_AT_byte_size)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3e # (DW_AT_encoding)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .byte 0
+ .byte 0
+ .uleb128 0x4 # (abbrev code)
+ .uleb128 0xf # (TAG: DW_TAG_pointer_type)
+ .byte 0 # DW_children_no
+ .uleb128 0xb # (DW_AT_byte_size)
+ .uleb128 0xb # (DW_FORM_data1)
+ .byte 0
+ .byte 0
+ .uleb128 0x5 # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x27 # (DW_AT_prototyped)
+ .uleb128 0xc # (DW_FORM_flag)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x40 # (DW_AT_frame_base)
+ .uleb128 0x6 # (DW_FORM_data4)
+ .uleb128 0x2116 # (DW_AT_GNU_all_tail_call_sites)
+ .uleb128 0xc # (DW_FORM_flag)
+ .uleb128 0x1 # (DW_AT_sibling)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x6 # (abbrev code)
+ .uleb128 0x5 # (TAG: DW_TAG_formal_parameter)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0xa # (DW_FORM_block1)
+ .byte 0
+ .byte 0
+ .uleb128 0x7 # (abbrev code)
+ .uleb128 0x34 # (TAG: DW_TAG_variable)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0xa # (DW_FORM_block1)
+ .byte 0
+ .byte 0
+ .uleb128 0x8 # (abbrev code)
+ .uleb128 0x1 # (TAG: DW_TAG_array_type)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x1 # (DW_AT_sibling)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x9 # (abbrev code)
+ .uleb128 0x21 # (TAG: DW_TAG_subrange_type)
+ .byte 0 # DW_children_no
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x2f # (DW_AT_upper_bound)
+ .uleb128 0xb # (DW_FORM_data1)
+ .byte 0
+ .byte 0
+ .uleb128 0xa # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0 # DW_children_no
+ .uleb128 0x3f # (DW_AT_external)
+ .uleb128 0xc # (DW_FORM_flag)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x27 # (DW_AT_prototyped)
+ .uleb128 0xc # (DW_FORM_flag)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x40 # (DW_AT_frame_base)
+ .uleb128 0x6 # (DW_FORM_data4)
+ .uleb128 0x2116 # (DW_AT_GNU_all_tail_call_sites)
+ .uleb128 0xc # (DW_FORM_flag)
+ .byte 0
+ .byte 0
+ .uleb128 0xb # (abbrev code)
+ .uleb128 0x35 # (TAG: DW_TAG_volatile_type)
+ .byte 0 # DW_children_no
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .byte 0
+ .section .debug_loc,"",@progbits
+.Ldebug_loc0:
+.LLST0:
+ .quad .LFB0-.Ltext0 # Location list begin address (*.LLST0)
+ .quad .LCFI0-.Ltext0 # Location list end address (*.LLST0)
+ .value 0x2 # Location expression size
+ .byte 0x77 # DW_OP_breg7
+ .sleb128 8
+ .quad .LCFI0-.Ltext0 # Location list begin address (*.LLST0)
+ .quad .LCFI1-.Ltext0 # Location list end address (*.LLST0)
+ .value 0x2 # Location expression size
+ .byte 0x77 # DW_OP_breg7
+ .sleb128 16
+ .quad .LCFI1-.Ltext0 # Location list begin address (*.LLST0)
+ .quad .LCFI2-.Ltext0 # Location list end address (*.LLST0)
+ .value 0x2 # Location expression size
+ .byte 0x76 # DW_OP_breg6
+ .sleb128 16
+ .quad .LCFI2-.Ltext0 # Location list begin address (*.LLST0)
+ .quad .LFE0-.Ltext0 # Location list end address (*.LLST0)
+ .value 0x2 # Location expression size
+ .byte 0x77 # DW_OP_breg7
+ .sleb128 8
+ .quad 0 # Location list terminator begin (*.LLST0)
+ .quad 0 # Location list terminator end (*.LLST0)
+.LLST1:
+ .quad .LFB1-.Ltext0 # Location list begin address (*.LLST1)
+ .quad .LCFI3-.Ltext0 # Location list end address (*.LLST1)
+ .value 0x2 # Location expression size
+ .byte 0x77 # DW_OP_breg7
+ .sleb128 8
+ .quad .LCFI3-.Ltext0 # Location list begin address (*.LLST1)
+ .quad .LCFI4-.Ltext0 # Location list end address (*.LLST1)
+ .value 0x2 # Location expression size
+ .byte 0x77 # DW_OP_breg7
+ .sleb128 16
+ .quad .LCFI4-.Ltext0 # Location list begin address (*.LLST1)
+ .quad .LCFI5-.Ltext0 # Location list end address (*.LLST1)
+ .value 0x2 # Location expression size
+ .byte 0x76 # DW_OP_breg6
+ .sleb128 16
+ .quad .LCFI5-.Ltext0 # Location list begin address (*.LLST1)
+ .quad .LFE1-.Ltext0 # Location list end address (*.LLST1)
+ .value 0x2 # Location expression size
+ .byte 0x77 # DW_OP_breg7
+ .sleb128 8
+ .quad 0 # Location list terminator begin (*.LLST1)
+ .quad 0 # Location list terminator end (*.LLST1)
+ .section .debug_aranges,"",@progbits
+ .long 0x2c # Length of Address Ranges Info
+ .value 0x2 # DWARF Version
+ .long .Ldebug_info0 # Offset of Compilation Unit Info
+ .byte 0x8 # Size of Address
+ .byte 0 # Size of Segment Descriptor
+ .value 0 # Pad to 16 byte boundary
+ .value 0
+ .quad .Ltext0 # Address
+ .quad .Letext0-.Ltext0 # Length
+ .quad 0
+ .quad 0
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .section .debug_str,"MS",@progbits,1
+.LASF4:
+ .string "unsigned int"
+.LASF0:
+ .string "long unsigned int"
+.LASF11:
+ .string ""
+.LASF8:
+ .string "char"
+.LASF2:
+ .string "unsigned char"
+.LASF12:
+ .string "main"
+.LASF1:
+ .string "long int"
+.LASF3:
+ .string "short unsigned int"
+.LASF5:
+ .string "signed char"
+.LASF10:
+ .string "gdb.arch/amd64-inner-frame.c"
+.LASF9:
+ .string "GNU C 4.7.3 20121006 (prerelease)"
+.LASF6:
+ .string "short int"
+.LASF7:
+ .string "sizetype"
+ .ident "GCC: (GNU) 4.7.3 20121006 (prerelease)"
+ .section .note.GNU-stack,"",@progbits
diff --git a/gdb/testsuite/gdb.arch/amd64-inner-frame.c b/gdb/testsuite/gdb.arch/amd64-inner-frame.c
new file mode 100644
index 0000000..dfe3847
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-inner-frame.c
@@ -0,0 +1,41 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2012 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <alloca.h>
+#include <stddef.h>
+#include <stdio.h>
+
+static volatile int v;
+
+static void
+f (int i)
+{
+ void *l = alloca (1);
+ void *a[1] = { l };
+ if (i)
+ f (i - 1);
+ if (i == 1)
+ a[2] = &a[-6];
+ v++; /* break-here */
+}
+
+int
+main (void)
+{
+ f (2);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-inner-frame.exp b/gdb/testsuite/gdb.arch/amd64-inner-frame.exp
new file mode 100644
index 0000000..ed087b4
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-inner-frame.exp
@@ -0,0 +1,50 @@
+# Copyright (C) 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set opts {}
+standard_testfile .S
+
+if [info exists COMPILE] {
+ # make check RUNTESTFLAGS="gdb.arch/amd64-inner-frame.exp COMPILE=1"
+ standard_testfile
+ lappend opts debug
+} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
+ verbose "Skipping ${testfile}."
+ return
+}
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $opts] } {
+ return -1
+}
+
+if ![runto_main] {
+ return -1
+}
+
+set srcfile $testfile.c
+gdb_test "break $srcfile:[gdb_get_line_number "break-here"] if i == 1" \
+ "Breakpoint \[0-9\]* at .*: file .*, line $decimal."
+
+gdb_continue_to_breakpoint "break-here" ".* break-here .*"
+
+set test "backtrace"
+gdb_test_multiple $test $test {
+ -re "\r\n#2 " {
+ fail $test
+ }
+ -re "\r\nBacktrace stopped: previous frame inner to this frame \\(corrupt stack\\?\\)\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add option to control checking of inner frames when doing a backtrace
2012-10-06 18:34 ` Jan Kratochvil
@ 2012-10-07 5:52 ` Jan Kratochvil
0 siblings, 0 replies; 7+ messages in thread
From: Jan Kratochvil @ 2012-10-07 5:52 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Joshua Watt, gdb-patches
Hi,
just a slightly improved patch.
Jan
gdb/testsuite/
2012-10-07 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.arch/amd64-inner-frame.S: New file.
* gdb.arch/amd64-inner-frame.c: New file.
* gdb.arch/amd64-inner-frame.exp: New file.
diff --git a/gdb/testsuite/gdb.arch/amd64-inner-frame.S b/gdb/testsuite/gdb.arch/amd64-inner-frame.S
new file mode 100644
index 0000000..d11a058
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-inner-frame.S
@@ -0,0 +1,503 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2012 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This file is compiled from gdb.arch/amd64-inner-frame.c
+ using -g -dA -S. */
+
+ .file "amd64-inner-frame.c"
+ .text
+.Ltext0:
+ .local v
+ .comm v,4,4
+ .type f, @function
+f:
+.LFB0:
+ .file 1 "gdb.arch/amd64-inner-frame.c"
+ # gdb.arch/amd64-inner-frame.c:26
+ .loc 1 26 0
+ .cfi_startproc
+# BLOCK 2 seq:0
+# PRED: ENTRY (fallthru)
+ pushq %rbp
+.LCFI0:
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+.LCFI1:
+ .cfi_def_cfa_register 6
+ subq $32, %rsp
+ movl %edi, -20(%rbp)
+ # gdb.arch/amd64-inner-frame.c:27
+ .loc 1 27 0
+ movl $16, %eax
+ subq $1, %rax
+ addq $16, %rax
+ movq $16, -32(%rbp)
+ movl $0, %edx
+ divq -32(%rbp)
+ imulq $16, %rax, %rax
+ subq %rax, %rsp
+ movq %rsp, %rax
+ addq $15, %rax
+ shrq $4, %rax
+ salq $4, %rax
+ movq %rax, -8(%rbp)
+ # gdb.arch/amd64-inner-frame.c:28
+ .loc 1 28 0
+ movq -8(%rbp), %rax
+ movq %rax, -16(%rbp)
+ # gdb.arch/amd64-inner-frame.c:29
+ .loc 1 29 0
+ cmpl $2, -20(%rbp)
+# SUCC: 3 (fallthru) 4
+ jne .L2
+# BLOCK 3 seq:1
+# PRED: 2 (fallthru)
+ # gdb.arch/amd64-inner-frame.c:30
+ .loc 1 30 0
+ leaq -16(%rbp), %rax
+ addq $16, %rax
+ movq %rax, 64(%rbp)
+# SUCC: 5 [100.0%]
+ jmp .L3
+# BLOCK 4 seq:2
+# PRED: 2
+.L2:
+ # gdb.arch/amd64-inner-frame.c:32
+ .loc 1 32 0
+ movl -20(%rbp), %eax
+ addl $1, %eax
+ movl %eax, %edi
+# SUCC: 5 (fallthru)
+ call f
+# BLOCK 5 seq:3
+# PRED: 4 (fallthru) 3 [100.0%]
+.L3:
+ # gdb.arch/amd64-inner-frame.c:33
+ .loc 1 33 0
+ movl v(%rip), %eax
+ addl $1, %eax
+ movl %eax, v(%rip)
+ # gdb.arch/amd64-inner-frame.c:34
+ .loc 1 34 0
+ leave
+.LCFI2:
+ .cfi_def_cfa 7, 8
+# SUCC: EXIT [100.0%]
+ ret
+ .cfi_endproc
+.LFE0:
+ .size f, .-f
+ .globl main
+ .type main, @function
+main:
+.LFB1:
+ # gdb.arch/amd64-inner-frame.c:38
+ .loc 1 38 0
+ .cfi_startproc
+# BLOCK 2 seq:0
+# PRED: ENTRY (fallthru)
+ pushq %rbp
+.LCFI3:
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+.LCFI4:
+ .cfi_def_cfa_register 6
+ # gdb.arch/amd64-inner-frame.c:39
+ .loc 1 39 0
+ movl $0, %edi
+ call f
+ # gdb.arch/amd64-inner-frame.c:40
+ .loc 1 40 0
+ movl $0, %eax
+ # gdb.arch/amd64-inner-frame.c:41
+ .loc 1 41 0
+ popq %rbp
+.LCFI5:
+ .cfi_def_cfa 7, 8
+# SUCC: EXIT [100.0%]
+ ret
+ .cfi_endproc
+.LFE1:
+ .size main, .-main
+.Letext0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .long 0x100 # Length of Compilation Unit Info
+ .value 0x2 # DWARF version number
+ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section
+ .byte 0x8 # Pointer Size (in bytes)
+ .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit)
+ .long .LASF9 # DW_AT_producer: "GNU C 4.7.3 20121007 (prerelease)"
+ .byte 0x1 # DW_AT_language
+ .long .LASF10 # DW_AT_name: "gdb.arch/amd64-inner-frame.c"
+ .long .LASF11 # DW_AT_comp_dir: ""
+ .quad .Ltext0 # DW_AT_low_pc
+ .quad .Letext0 # DW_AT_high_pc
+ .long .Ldebug_line0 # DW_AT_stmt_list
+ .uleb128 0x2 # (DIE (0x2d) DW_TAG_base_type)
+ .byte 0x8 # DW_AT_byte_size
+ .byte 0x7 # DW_AT_encoding
+ .long .LASF0 # DW_AT_name: "long unsigned int"
+ .uleb128 0x2 # (DIE (0x34) DW_TAG_base_type)
+ .byte 0x8 # DW_AT_byte_size
+ .byte 0x5 # DW_AT_encoding
+ .long .LASF1 # DW_AT_name: "long int"
+ .uleb128 0x3 # (DIE (0x3b) DW_TAG_base_type)
+ .byte 0x4 # DW_AT_byte_size
+ .byte 0x5 # DW_AT_encoding
+ .ascii "int\0" # DW_AT_name
+ .uleb128 0x2 # (DIE (0x42) DW_TAG_base_type)
+ .byte 0x1 # DW_AT_byte_size
+ .byte 0x8 # DW_AT_encoding
+ .long .LASF2 # DW_AT_name: "unsigned char"
+ .uleb128 0x2 # (DIE (0x49) DW_TAG_base_type)
+ .byte 0x2 # DW_AT_byte_size
+ .byte 0x7 # DW_AT_encoding
+ .long .LASF3 # DW_AT_name: "short unsigned int"
+ .uleb128 0x2 # (DIE (0x50) DW_TAG_base_type)
+ .byte 0x4 # DW_AT_byte_size
+ .byte 0x7 # DW_AT_encoding
+ .long .LASF4 # DW_AT_name: "unsigned int"
+ .uleb128 0x2 # (DIE (0x57) DW_TAG_base_type)
+ .byte 0x1 # DW_AT_byte_size
+ .byte 0x6 # DW_AT_encoding
+ .long .LASF5 # DW_AT_name: "signed char"
+ .uleb128 0x2 # (DIE (0x5e) DW_TAG_base_type)
+ .byte 0x2 # DW_AT_byte_size
+ .byte 0x5 # DW_AT_encoding
+ .long .LASF6 # DW_AT_name: "short int"
+ .uleb128 0x2 # (DIE (0x65) DW_TAG_base_type)
+ .byte 0x8 # DW_AT_byte_size
+ .byte 0x7 # DW_AT_encoding
+ .long .LASF7 # DW_AT_name: "sizetype"
+ .uleb128 0x4 # (DIE (0x6c) DW_TAG_pointer_type)
+ .byte 0x8 # DW_AT_byte_size
+ .uleb128 0x2 # (DIE (0x6e) DW_TAG_base_type)
+ .byte 0x1 # DW_AT_byte_size
+ .byte 0x6 # DW_AT_encoding
+ .long .LASF8 # DW_AT_name: "char"
+ .uleb128 0x5 # (DIE (0x75) DW_TAG_subprogram)
+ .ascii "f\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-inner-frame.c)
+ .byte 0x19 # DW_AT_decl_line
+ .byte 0x1 # DW_AT_prototyped
+ .quad .LFB0 # DW_AT_low_pc
+ .quad .LFE0 # DW_AT_high_pc
+ .long .LLST0 # DW_AT_frame_base
+ .byte 0x1 # DW_AT_GNU_all_tail_call_sites
+ .long 0xb9 # DW_AT_sibling
+ .uleb128 0x6 # (DIE (0x94) DW_TAG_formal_parameter)
+ .ascii "i\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-inner-frame.c)
+ .byte 0x19 # DW_AT_decl_line
+ .long 0x3b # DW_AT_type
+ .byte 0x2 # DW_AT_location
+ .byte 0x91 # DW_OP_fbreg
+ .sleb128 -36
+ .uleb128 0x7 # (DIE (0xa0) DW_TAG_variable)
+ .ascii "l\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-inner-frame.c)
+ .byte 0x1b # DW_AT_decl_line
+ .long 0x6c # DW_AT_type
+ .byte 0x2 # DW_AT_location
+ .byte 0x91 # DW_OP_fbreg
+ .sleb128 -24
+ .uleb128 0x7 # (DIE (0xac) DW_TAG_variable)
+ .ascii "a\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-inner-frame.c)
+ .byte 0x1c # DW_AT_decl_line
+ .long 0xb9 # DW_AT_type
+ .byte 0x2 # DW_AT_location
+ .byte 0x91 # DW_OP_fbreg
+ .sleb128 -32
+ .byte 0 # end of children of DIE 0x75
+ .uleb128 0x8 # (DIE (0xb9) DW_TAG_array_type)
+ .long 0x6c # DW_AT_type
+ .long 0xc9 # DW_AT_sibling
+ .uleb128 0x9 # (DIE (0xc2) DW_TAG_subrange_type)
+ .long 0x65 # DW_AT_type
+ .byte 0 # DW_AT_upper_bound
+ .byte 0 # end of children of DIE 0xb9
+ .uleb128 0xa # (DIE (0xc9) DW_TAG_subprogram)
+ .byte 0x1 # DW_AT_external
+ .long .LASF12 # DW_AT_name: "main"
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-inner-frame.c)
+ .byte 0x25 # DW_AT_decl_line
+ .byte 0x1 # DW_AT_prototyped
+ .long 0x3b # DW_AT_type
+ .quad .LFB1 # DW_AT_low_pc
+ .quad .LFE1 # DW_AT_high_pc
+ .long .LLST1 # DW_AT_frame_base
+ .byte 0x1 # DW_AT_GNU_all_tail_call_sites
+ .uleb128 0x7 # (DIE (0xeb) DW_TAG_variable)
+ .ascii "v\0" # DW_AT_name
+ .byte 0x1 # DW_AT_decl_file (gdb.arch/amd64-inner-frame.c)
+ .byte 0x16 # DW_AT_decl_line
+ .long 0xfe # DW_AT_type
+ .byte 0x9 # DW_AT_location
+ .byte 0x3 # DW_OP_addr
+ .quad v
+ .uleb128 0xb # (DIE (0xfe) DW_TAG_volatile_type)
+ .long 0x3b # DW_AT_type
+ .byte 0 # end of children of DIE 0xb
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .uleb128 0x1 # (abbrev code)
+ .uleb128 0x11 # (TAG: DW_TAG_compile_unit)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x25 # (DW_AT_producer)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x13 # (DW_AT_language)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x1b # (DW_AT_comp_dir)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x10 # (DW_AT_stmt_list)
+ .uleb128 0x6 # (DW_FORM_data4)
+ .byte 0
+ .byte 0
+ .uleb128 0x2 # (abbrev code)
+ .uleb128 0x24 # (TAG: DW_TAG_base_type)
+ .byte 0 # DW_children_no
+ .uleb128 0xb # (DW_AT_byte_size)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3e # (DW_AT_encoding)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .byte 0
+ .byte 0
+ .uleb128 0x3 # (abbrev code)
+ .uleb128 0x24 # (TAG: DW_TAG_base_type)
+ .byte 0 # DW_children_no
+ .uleb128 0xb # (DW_AT_byte_size)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3e # (DW_AT_encoding)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .byte 0
+ .byte 0
+ .uleb128 0x4 # (abbrev code)
+ .uleb128 0xf # (TAG: DW_TAG_pointer_type)
+ .byte 0 # DW_children_no
+ .uleb128 0xb # (DW_AT_byte_size)
+ .uleb128 0xb # (DW_FORM_data1)
+ .byte 0
+ .byte 0
+ .uleb128 0x5 # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x27 # (DW_AT_prototyped)
+ .uleb128 0xc # (DW_FORM_flag)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x40 # (DW_AT_frame_base)
+ .uleb128 0x6 # (DW_FORM_data4)
+ .uleb128 0x2116 # (DW_AT_GNU_all_tail_call_sites)
+ .uleb128 0xc # (DW_FORM_flag)
+ .uleb128 0x1 # (DW_AT_sibling)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x6 # (abbrev code)
+ .uleb128 0x5 # (TAG: DW_TAG_formal_parameter)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0xa # (DW_FORM_block1)
+ .byte 0
+ .byte 0
+ .uleb128 0x7 # (abbrev code)
+ .uleb128 0x34 # (TAG: DW_TAG_variable)
+ .byte 0 # DW_children_no
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0x8 # (DW_FORM_string)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x2 # (DW_AT_location)
+ .uleb128 0xa # (DW_FORM_block1)
+ .byte 0
+ .byte 0
+ .uleb128 0x8 # (abbrev code)
+ .uleb128 0x1 # (TAG: DW_TAG_array_type)
+ .byte 0x1 # DW_children_yes
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x1 # (DW_AT_sibling)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .uleb128 0x9 # (abbrev code)
+ .uleb128 0x21 # (TAG: DW_TAG_subrange_type)
+ .byte 0 # DW_children_no
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x2f # (DW_AT_upper_bound)
+ .uleb128 0xb # (DW_FORM_data1)
+ .byte 0
+ .byte 0
+ .uleb128 0xa # (abbrev code)
+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
+ .byte 0 # DW_children_no
+ .uleb128 0x3f # (DW_AT_external)
+ .uleb128 0xc # (DW_FORM_flag)
+ .uleb128 0x3 # (DW_AT_name)
+ .uleb128 0xe # (DW_FORM_strp)
+ .uleb128 0x3a # (DW_AT_decl_file)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x3b # (DW_AT_decl_line)
+ .uleb128 0xb # (DW_FORM_data1)
+ .uleb128 0x27 # (DW_AT_prototyped)
+ .uleb128 0xc # (DW_FORM_flag)
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .uleb128 0x11 # (DW_AT_low_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x12 # (DW_AT_high_pc)
+ .uleb128 0x1 # (DW_FORM_addr)
+ .uleb128 0x40 # (DW_AT_frame_base)
+ .uleb128 0x6 # (DW_FORM_data4)
+ .uleb128 0x2116 # (DW_AT_GNU_all_tail_call_sites)
+ .uleb128 0xc # (DW_FORM_flag)
+ .byte 0
+ .byte 0
+ .uleb128 0xb # (abbrev code)
+ .uleb128 0x35 # (TAG: DW_TAG_volatile_type)
+ .byte 0 # DW_children_no
+ .uleb128 0x49 # (DW_AT_type)
+ .uleb128 0x13 # (DW_FORM_ref4)
+ .byte 0
+ .byte 0
+ .byte 0
+ .section .debug_loc,"",@progbits
+.Ldebug_loc0:
+.LLST0:
+ .quad .LFB0-.Ltext0 # Location list begin address (*.LLST0)
+ .quad .LCFI0-.Ltext0 # Location list end address (*.LLST0)
+ .value 0x2 # Location expression size
+ .byte 0x77 # DW_OP_breg7
+ .sleb128 8
+ .quad .LCFI0-.Ltext0 # Location list begin address (*.LLST0)
+ .quad .LCFI1-.Ltext0 # Location list end address (*.LLST0)
+ .value 0x2 # Location expression size
+ .byte 0x77 # DW_OP_breg7
+ .sleb128 16
+ .quad .LCFI1-.Ltext0 # Location list begin address (*.LLST0)
+ .quad .LCFI2-.Ltext0 # Location list end address (*.LLST0)
+ .value 0x2 # Location expression size
+ .byte 0x76 # DW_OP_breg6
+ .sleb128 16
+ .quad .LCFI2-.Ltext0 # Location list begin address (*.LLST0)
+ .quad .LFE0-.Ltext0 # Location list end address (*.LLST0)
+ .value 0x2 # Location expression size
+ .byte 0x77 # DW_OP_breg7
+ .sleb128 8
+ .quad 0 # Location list terminator begin (*.LLST0)
+ .quad 0 # Location list terminator end (*.LLST0)
+.LLST1:
+ .quad .LFB1-.Ltext0 # Location list begin address (*.LLST1)
+ .quad .LCFI3-.Ltext0 # Location list end address (*.LLST1)
+ .value 0x2 # Location expression size
+ .byte 0x77 # DW_OP_breg7
+ .sleb128 8
+ .quad .LCFI3-.Ltext0 # Location list begin address (*.LLST1)
+ .quad .LCFI4-.Ltext0 # Location list end address (*.LLST1)
+ .value 0x2 # Location expression size
+ .byte 0x77 # DW_OP_breg7
+ .sleb128 16
+ .quad .LCFI4-.Ltext0 # Location list begin address (*.LLST1)
+ .quad .LCFI5-.Ltext0 # Location list end address (*.LLST1)
+ .value 0x2 # Location expression size
+ .byte 0x76 # DW_OP_breg6
+ .sleb128 16
+ .quad .LCFI5-.Ltext0 # Location list begin address (*.LLST1)
+ .quad .LFE1-.Ltext0 # Location list end address (*.LLST1)
+ .value 0x2 # Location expression size
+ .byte 0x77 # DW_OP_breg7
+ .sleb128 8
+ .quad 0 # Location list terminator begin (*.LLST1)
+ .quad 0 # Location list terminator end (*.LLST1)
+ .section .debug_aranges,"",@progbits
+ .long 0x2c # Length of Address Ranges Info
+ .value 0x2 # DWARF Version
+ .long .Ldebug_info0 # Offset of Compilation Unit Info
+ .byte 0x8 # Size of Address
+ .byte 0 # Size of Segment Descriptor
+ .value 0 # Pad to 16 byte boundary
+ .value 0
+ .quad .Ltext0 # Address
+ .quad .Letext0-.Ltext0 # Length
+ .quad 0
+ .quad 0
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .section .debug_str,"MS",@progbits,1
+.LASF4:
+ .string "unsigned int"
+.LASF0:
+ .string "long unsigned int"
+.LASF11:
+ .string ""
+.LASF8:
+ .string "char"
+.LASF2:
+ .string "unsigned char"
+.LASF12:
+ .string "main"
+.LASF1:
+ .string "long int"
+.LASF3:
+ .string "short unsigned int"
+.LASF5:
+ .string "signed char"
+.LASF10:
+ .string "gdb.arch/amd64-inner-frame.c"
+.LASF9:
+ .string "GNU C 4.7.3 20121007 (prerelease)"
+.LASF6:
+ .string "short int"
+.LASF7:
+ .string "sizetype"
+ .ident "GCC: (GNU) 4.7.3 20121007 (prerelease)"
+ .section .note.GNU-stack,"",@progbits
diff --git a/gdb/testsuite/gdb.arch/amd64-inner-frame.c b/gdb/testsuite/gdb.arch/amd64-inner-frame.c
new file mode 100644
index 0000000..5726fb6
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-inner-frame.c
@@ -0,0 +1,41 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2012 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <alloca.h>
+#include <stddef.h>
+#include <stdio.h>
+
+static volatile int v;
+
+static void
+f (int i)
+{
+ void *l = alloca (1);
+ void *a[1] = { l };
+ if (i == 2)
+ a[10] = &a[2];
+ else
+ f (i + 1);
+ v++; /* break-here */
+}
+
+int
+main (void)
+{
+ f (0);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-inner-frame.exp b/gdb/testsuite/gdb.arch/amd64-inner-frame.exp
new file mode 100644
index 0000000..f9aab7d
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-inner-frame.exp
@@ -0,0 +1,48 @@
+# Copyright (C) 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set opts {}
+standard_testfile .S
+
+if [info exists COMPILE] {
+ # make check RUNTESTFLAGS="gdb.arch/amd64-inner-frame.exp COMPILE=1"
+ standard_testfile
+ lappend opts debug
+} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
+ verbose "Skipping ${testfile}."
+ return
+}
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $opts] } {
+ return -1
+}
+
+if ![runto_main] {
+ return -1
+}
+
+set srcfile $testfile.c
+gdb_breakpoint [gdb_get_line_number "break-here"]
+gdb_continue_to_breakpoint "break-here" ".* break-here .*"
+
+set test "backtrace"
+gdb_test_multiple $test $test {
+ -re "\r\n#3 " {
+ fail $test
+ }
+ -re "\r\nBacktrace stopped: previous frame inner to this frame \\(corrupt stack\\?\\)\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-10-07 5:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-02 17:58 [PATCH] Add option to control checking of inner frames when doing a backtrace Joshua Watt
2012-10-03 9:29 ` Abid, Hafiz
2012-10-03 14:03 ` Joshua Watt
2012-10-03 13:57 ` Joel Brobecker
2012-10-05 21:10 ` Joshua Watt
2012-10-06 18:34 ` Jan Kratochvil
2012-10-07 5:52 ` Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox