From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1216 invoked by alias); 8 Jul 2011 09:08:07 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 1186 invoked by uid 9674); 8 Jul 2011 09:08:06 -0000 Date: Fri, 08 Jul 2011 09:08:00 -0000 Message-ID: <20110708090806.1170.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-jankratochvil-entryval: testcase fix X-Git-Refname: refs/heads/archer-jankratochvil-entryval X-Git-Reftype: branch X-Git-Oldrev: 58008bce85b849c3b7e3adc3c110427366a57e63 X-Git-Newrev: 591bc655e05e37da562bb3906aa2cc9f06c51880 X-SW-Source: 2011-q3/txt/msg00008.txt.bz2 List-Id: The branch, archer-jankratochvil-entryval has been updated via 591bc655e05e37da562bb3906aa2cc9f06c51880 (commit) via 377581325fe34211f6fb2d4ad7e602375451c7bb (commit) via 89a62ce225e5cb4dc6c9cd68973c7083b89cbfb1 (commit) via 132fae2d603f6c3890f697d61adee85d1d27e592 (commit) from 58008bce85b849c3b7e3adc3c110427366a57e63 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 591bc655e05e37da562bb3906aa2cc9f06c51880 Author: Jan Kratochvil Date: Fri Jul 8 11:07:51 2011 +0200 testcase fix commit 377581325fe34211f6fb2d4ad7e602375451c7bb Author: Jan Kratochvil Date: Fri Jul 8 10:59:03 2011 +0200 no debug commit 89a62ce225e5cb4dc6c9cd68973c7083b89cbfb1 Author: Jan Kratochvil Date: Fri Jul 8 10:58:32 2011 +0200 fix callers/callees commit 132fae2d603f6c3890f697d61adee85d1d27e592 Author: Jan Kratochvil Date: Fri Jul 8 10:31:58 2011 +0200 +tailcall_debug testcase ambiguous tailcalls ----------------------------------------------------------------------- Summary of changes: gdb/dwarf2-frame-tailcall.c | 12 +- gdb/dwarf2loc.c | 87 +++- gdb/testsuite/gdb.arch/amd64-entry-value.c | 40 ++ gdb/testsuite/gdb.arch/amd64-entry-value.exp | 34 +- gdb/testsuite/gdb.arch/amd64-entry-value.s | 667 +++++++++++++++++++++++--- 5 files changed, 758 insertions(+), 82 deletions(-) First 500 lines of diff: diff --git a/gdb/dwarf2-frame-tailcall.c b/gdb/dwarf2-frame-tailcall.c index b1254bb..9a198c5 100644 --- a/gdb/dwarf2-frame-tailcall.c +++ b/gdb/dwarf2-frame-tailcall.c @@ -191,16 +191,16 @@ pretend_pc (struct frame_info *this_frame, struct tailcall_cache *cache) next_levels++; gdb_assert (next_levels >= 0); - if (next_levels < chain->callers) + if (next_levels < chain->callees) return chain->addr[chain->length - next_levels - 1]; - next_levels -= chain->callers; + next_levels -= chain->callees; /* Otherwise CHAIN->CALLEES are already covered by CHAIN->CALLERS. */ - if (chain->callers != chain->length) + if (chain->callees != chain->length) { - if (next_levels < chain->callees); - return chain->addr[chain->callees - next_levels - 1]; - next_levels -= chain->callees; + if (next_levels < chain->callers) + return chain->addr[chain->callers - next_levels - 1]; + next_levels -= chain->callers; } gdb_assert (next_levels == 0); diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 0ddf00e..112c5e5 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -42,6 +42,8 @@ #include "gdb_string.h" #include "gdb_assert.h" +#include "command.h" +#include "gdbcmd.h" extern int dwarf2_always_disassemble; @@ -312,6 +314,14 @@ dwarf_expr_get_base_type (struct dwarf_expr_context *ctx, size_t die_offset) return dwarf2_get_die_type (die_offset, debaton->per_cu); } +static int tailcall_debug = 0; +static void +show_tailcall_debug (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("Tail call frames debugging is %s.\n"), value); +} + /* Find DW_TAG_GNU_call_site's DW_AT_GNU_call_site_target address. CALLER_FRAME can be NULL if it is not known. */ @@ -510,11 +520,28 @@ free_call_site_stuffp_vecp (void *arg) } } +static void +tailcall_dump_addr (struct gdbarch *gdbarch, CORE_ADDR addr) +{ + struct block *block; + struct symbol *func = NULL; + + fprintf_unfiltered (gdb_stdlog, " %s", paddress (gdbarch, addr)); + + block = block_for_pc (addr - 1); + if (block) + func = block_linkage_function (block); + + if (func) + fprintf_unfiltered (gdb_stdlog, "(%s)", SYMBOL_PRINT_NAME (func)); +} + /* Return 1 for no remaining possibility to provide a meaningful result, return 0 otherwise. */ static int -chain_candidate (struct call_site_chain **resultp, VEC (CORE_ADDR) *chain) +chain_candidate (struct gdbarch *gdbarch, struct call_site_chain **resultp, + VEC (CORE_ADDR) *chain) { struct call_site_chain *result = *resultp; long length = VEC_length (CORE_ADDR, chain); @@ -529,23 +556,52 @@ chain_candidate (struct call_site_chain **resultp, VEC (CORE_ADDR) *chain) memcpy (result->addr, VEC_address (CORE_ADDR, chain), sizeof (*result->addr) * length); *resultp = result; + if (tailcall_debug) + { + fprintf_unfiltered (gdb_stdlog, "tailcall: initial:"); + for (idx = 0; idx < length; idx++) + tailcall_dump_addr (gdbarch, result->addr[idx]); + fputc_unfiltered ('\n', gdb_stdlog); + } return 0; } + if (tailcall_debug) + { + fprintf_unfiltered (gdb_stdlog, "tailcall: compare:"); + for (idx = 0; idx < length; idx++) + tailcall_dump_addr (gdbarch, VEC_index (CORE_ADDR, chain, idx)); + fputc_unfiltered ('\n', gdb_stdlog); + } + callers = min (result->callers, length); for (idx = 0; idx < callers; idx++) if (result->addr[idx] != VEC_index (CORE_ADDR, chain, idx)) - break; - if (idx < callers) - result->callers = idx; + { + result->callers = idx; + break; + } callees = min (result->callees, length); for (idx = 0; idx < callees; idx++) if (result->addr[result->length - 1 - idx] != VEC_index (CORE_ADDR, chain, length - 1 - idx)) - break; - if (idx < callees) - result->callees = idx; + { + result->callees = idx; + break; + } + + if (tailcall_debug) + { + fprintf_unfiltered (gdb_stdlog, "tailcall: reduced:"); + for (idx = 0; idx < result->callers; idx++) + tailcall_dump_addr (gdbarch, result->addr[idx]); + fputs_unfiltered (" |", gdb_stdlog); + for (idx = 0; idx < result->callees; idx++) + tailcall_dump_addr (gdbarch, result->addr[result->length + - result->callees + idx]); + fputc_unfiltered ('\n', gdb_stdlog); + } if (result->callers == 0 && result->callees == 0) { @@ -556,7 +612,6 @@ chain_candidate (struct call_site_chain **resultp, VEC (CORE_ADDR) *chain) return 1; } - gdb_assert (length < result->length); gdb_assert (result->callers + result->callees < result->length); return 0; @@ -617,7 +672,7 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc, if (target_func_addr == callee_func_pc) { - if (chain_candidate (&retval, chain)) + if (chain_candidate (gdbarch, &retval, chain)) { do_cleanups (old_chain); return NULL; @@ -3547,3 +3602,17 @@ const struct symbol_computed_ops dwarf2_loclist_funcs = { loclist_describe_location, loclist_tracepoint_var_ref }; + +void +_initialize_dwarf2loc (void) +{ + add_setshow_zinteger_cmd ("tailcall", class_maintenance, + &tailcall_debug, + _("Set tail call frames debugging."), + _("Show tail call frames debugging."), + _("When non-zero, the process of determining tail " + "call frames will be printed."), + NULL, + show_tailcall_debug, + &setdebuglist, &showdebuglist); +} diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value.c b/gdb/testsuite/gdb.arch/amd64-entry-value.c index 2e9eed2..22ffd2c 100644 --- a/gdb/testsuite/gdb.arch/amd64-entry-value.c +++ b/gdb/testsuite/gdb.arch/amd64-entry-value.c @@ -50,6 +50,45 @@ b (int i) c (i + 2); } +static void __attribute__((noinline, noclone)) +amb_z (int i) +{ + d (i + 7); +} + +static void __attribute__((noinline, noclone)) +amb_y (int i) +{ + amb_z (i + 6); +} + +static void __attribute__((noinline, noclone)) +amb_x (int i) +{ + amb_y (i + 5); +} + +static void __attribute__((noinline, noclone)) +amb (int i) +{ + if (i < 0) + amb_x (i + 3); + else + amb_x (i + 4); +} + +static void __attribute__((noinline, noclone)) +amb_b (int i) +{ + amb (i + 2); +} + +static void __attribute__((noinline, noclone)) +amb_a (int i) +{ + amb_b (i + 1); +} + int main (void) { @@ -58,5 +97,6 @@ main (void) a (1); else b (5); + amb_a (100); return 0; } diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value.exp b/gdb/testsuite/gdb.arch/amd64-entry-value.exp index edf38f8..954209e 100644 --- a/gdb/testsuite/gdb.arch/amd64-entry-value.exp +++ b/gdb/testsuite/gdb.arch/amd64-entry-value.exp @@ -32,26 +32,44 @@ gdb_breakpoint "breakhere" # Test @entry values. -gdb_continue_to_breakpoint "breakhere" +gdb_continue_to_breakpoint "entry: breakhere" # (gdb) bt full # #0 d (i=31) at gdb.arch/amd64-entry-value.c:33 # i@entry = 30 # #1 0x00000000004003da in main () at gdb.arch/amd64-entry-value.c:56 # No locals. -gdb_test "bt full" "^bt full\r\n#0 +d *\\(i=31\\) \[^\r\n\]*\r\n\[ \t\]*i@entry = 30\r\n#1 +0x\[0-9a-f\]+ in main .*" -gdb_test "p i" " = 31" -gdb_test "p i@entry" " = 30" +gdb_test "bt full" "^bt full\r\n#0 +d *\\(i=31\\) \[^\r\n\]*\r\n\[ \t\]*i@entry = 30\r\n#1 +0x\[0-9a-f\]+ in main .*" \ + "entry: bt full" +gdb_test "p i" " = 31" "entry: p i" +gdb_test "p i@entry" " = 30" "entry: p i@entry" # Test virtual tail call frames. -gdb_continue_to_breakpoint "breakhere" +gdb_continue_to_breakpoint "tailcall: breakhere" # #0 d (i=71) at gdb.arch/amd64-entry-value.c:33 # #1 0x0000000000400527 in c (i=7) at gdb.arch/amd64-entry-value.c:38 # #2 0x0000000000400545 in b (i=5) at gdb.arch/amd64-entry-value.c:50 # #3 0x00000000004003ee in main () at gdb.arch/amd64-entry-value.c:60 -gdb_test "bt" "^bt\r\n#0 +d *\\(i=71\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in c \\(i=7\\) \[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in b \\(i=5\\) \[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in main \[^\r\n\]*" -gdb_test "p i" " = 71" -gdb_test "p i@entry" " = 70" +gdb_test "bt" "^bt\r\n#0 +d *\\(i=71\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in c \\(i=7\\) \[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in b \\(i=5\\) \[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in main \[^\r\n\]*" \ + "tailcall: bt" +gdb_test "p i" " = 71" "tailcall: p i" +gdb_test "p i@entry" " = 70" "tailcall: p i@entry" + + +# Test partial-ambiguous virtual tail call frames chain. + +gdb_continue_to_breakpoint "ambiguous: breakhere" + +# #0 d (i=) at gdb.arch/amd64-entry-value.c:33 +# #1 0x0000000000400555 in amb_z (i=) at gdb.arch/amd64-entry-value.c:56 +# #2 0x0000000000400565 in amb_y (i=) at gdb.arch/amd64-entry-value.c:62 +# #3 0x0000000000400575 in amb_x (i=) at gdb.arch/amd64-entry-value.c:68 +# --- here is missing a frame for ambiguous PC in amb (). +# #4 0x0000000000400595 in amb_b (i=101) at gdb.arch/amd64-entry-value.c:83 +# #5 0x00000000004005a5 in amb_a (i=100) at gdb.arch/amd64-entry-value.c:89 +# #6 0x00000000004003f8 in main () at gdb.arch/amd64-entry-value.c:100 +gdb_test "bt" "^bt\r\n#0 +d \\(i=\\)\[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in amb_z \\(i=\\)\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in amb_y \\(i=\\)\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in amb_x \\(i=\\)\[^\r\n\]*\r\n#4 +0x\[0-9a-f\]+ in amb_b \\(i=101\\)\[^\r\n\]*\r\n#5 +0x\[0-9a-f\]+ in amb_a \\(i=100\\)\[^\r\n\]*\r\n#6 +0x\[0-9a-f\]+ in main \\(\\)\[^\r\n\]*" \ + "ambiguous: bt" diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value.s b/gdb/testsuite/gdb.arch/amd64-entry-value.s index 3f2320a..24a645c 100644 --- a/gdb/testsuite/gdb.arch/amd64-entry-value.s +++ b/gdb/testsuite/gdb.arch/amd64-entry-value.s @@ -18,7 +18,7 @@ /* This file is compiled form gdb.arch/amd64-entry-value.c using -g -dA -S -O2. */ - .file "entry-value.c" + .file "amd64-entry-value.c" .text .Ltext0: .p2align 4,,15 @@ -140,57 +140,199 @@ b: .cfi_endproc .LFE4: .size b, .-b - .section .text.startup,"ax",@progbits .p2align 4,,15 - .globl main - .type main, @function -main: + .type amb_z, @function +amb_z: .LFB5: # gdb.arch/amd64-entry-value.c:55 .loc 1 55 0 .cfi_startproc +.LVL14: # BLOCK 2 freq:10000 seq:0 # PRED: ENTRY [100.0%] (fallthru) # gdb.arch/amd64-entry-value.c:56 .loc 1 56 0 + addl $7, %edi +.LVL15: + jmp d +.LVL16: +# SUCC: EXIT [100.0%] (ab,sibcall) + .cfi_endproc +.LFE5: + .size amb_z, .-amb_z + .p2align 4,,15 + .type amb_y, @function +amb_y: +.LFB6: + # gdb.arch/amd64-entry-value.c:61 + .loc 1 61 0 + .cfi_startproc +.LVL17: +# BLOCK 2 freq:10000 seq:0 +# PRED: ENTRY [100.0%] (fallthru) + # gdb.arch/amd64-entry-value.c:62 + .loc 1 62 0 + addl $6, %edi +.LVL18: + jmp amb_z +.LVL19: +# SUCC: EXIT [100.0%] (ab,sibcall) + .cfi_endproc +.LFE6: + .size amb_y, .-amb_y + .p2align 4,,15 + .type amb_x, @function +amb_x: +.LFB7: + # gdb.arch/amd64-entry-value.c:67 + .loc 1 67 0 + .cfi_startproc +.LVL20: +# BLOCK 2 freq:10000 seq:0 +# PRED: ENTRY [100.0%] (fallthru) + # gdb.arch/amd64-entry-value.c:68 + .loc 1 68 0 + addl $5, %edi +.LVL21: + jmp amb_y +.LVL22: +# SUCC: EXIT [100.0%] (ab,sibcall) + .cfi_endproc +.LFE7: + .size amb_x, .-amb_x + .p2align 4,,15 + .type amb, @function +amb: +.LFB8: + # gdb.arch/amd64-entry-value.c:73 + .loc 1 73 0 + .cfi_startproc +.LVL23: +# BLOCK 2 freq:10000 seq:0 +# PRED: ENTRY [100.0%] (fallthru) + # gdb.arch/amd64-entry-value.c:74 + .loc 1 74 0 + testl %edi, %edi +# SUCC: 4 [19.1%] (can_fallthru) 3 [80.9%] (fallthru,can_fallthru) + js .L12 +# BLOCK 3 freq:8088 seq:1 +# PRED: 2 [80.9%] (fallthru,can_fallthru) + # gdb.arch/amd64-entry-value.c:77 + .loc 1 77 0 + addl $4, %edi +.LVL24: + jmp amb_x +.LVL25: +# SUCC: EXIT [100.0%] (ab,sibcall) +# BLOCK 4 freq:1912 seq:2 +# PRED: 2 [19.1%] (can_fallthru) +.L12: + # gdb.arch/amd64-entry-value.c:75 + .loc 1 75 0 + addl $3, %edi +.LVL26: + jmp amb_x +.LVL27: +# SUCC: EXIT [100.0%] (ab,sibcall) + .cfi_endproc +.LFE8: + .size amb, .-amb + .p2align 4,,15 + .type amb_b, @function +amb_b: +.LFB9: + # gdb.arch/amd64-entry-value.c:82 + .loc 1 82 0 + .cfi_startproc +.LVL28: +# BLOCK 2 freq:10000 seq:0 +# PRED: ENTRY [100.0%] (fallthru) + # gdb.arch/amd64-entry-value.c:83 + .loc 1 83 0 + addl $2, %edi +.LVL29: + jmp amb +.LVL30: +# SUCC: EXIT [100.0%] (ab,sibcall) + .cfi_endproc +.LFE9: + .size amb_b, .-amb_b + .p2align 4,,15 + .type amb_a, @function +amb_a: +.LFB10: + # gdb.arch/amd64-entry-value.c:88 + .loc 1 88 0 + .cfi_startproc +.LVL31: +# BLOCK 2 freq:10000 seq:0 +# PRED: ENTRY [100.0%] (fallthru) + # gdb.arch/amd64-entry-value.c:89 + .loc 1 89 0 + addl $1, %edi +.LVL32: + jmp amb_b +.LVL33: +# SUCC: EXIT [100.0%] (ab,sibcall) + .cfi_endproc +.LFE10: + .size amb_a, .-amb_a + .section .text.startup,"ax",@progbits + .p2align 4,,15 + .globl main + .type main, @function +main: +.LFB11: + # gdb.arch/amd64-entry-value.c:94 + .loc 1 94 0 + .cfi_startproc +# BLOCK 2 freq:10000 seq:0 +# PRED: ENTRY [100.0%] (fallthru) + # gdb.arch/amd64-entry-value.c:95 + .loc 1 95 0 movl $30, %edi call d -.LVL14: - # gdb.arch/amd64-entry-value.c:57 - .loc 1 57 0 +.LVL34: + # gdb.arch/amd64-entry-value.c:96 + .loc 1 96 0 movl v(%rip), %eax testl %eax, %eax # SUCC: 5 [39.0%] (can_fallthru) 3 [61.0%] (fallthru,can_fallthru) - jne .L10 + jne .L18 # BLOCK 3 freq:6100 seq:1 # PRED: 2 [61.0%] (fallthru,can_fallthru) - # gdb.arch/amd64-entry-value.c:60 - .loc 1 60 0 + # gdb.arch/amd64-entry-value.c:99 + .loc 1 99 0 movl $5, %edi call b # SUCC: 4 [100.0%] (fallthru,can_fallthru) -.LVL15: +.LVL35: # BLOCK 4 freq:10000 seq:2 # PRED: 3 [100.0%] (fallthru,can_fallthru) 5 [100.0%] -.L8: - # gdb.arch/amd64-entry-value.c:62 - .loc 1 62 0 +.L17: + # gdb.arch/amd64-entry-value.c:100 + .loc 1 100 0 + movl $100, %edi + call amb_a +.LVL36: + # gdb.arch/amd64-entry-value.c:102 hooks/post-receive -- Repository for Project Archer.