diff options
author | Felix Willgerodt <felix.willgerodt@intel.com> | 2024-08-16 09:54:17 +0200 |
---|---|---|
committer | Felix Willgerodt <felix.willgerodt@intel.com> | 2024-08-16 11:07:21 +0200 |
commit | bc737bc7fb7808d2915cc15cfba4b84b345940f1 (patch) | |
tree | 8c5daf0286b31fddd2fa4b5c6cd9b84290f5363e /gdb | |
parent | 50e19e6e6c4254cb12011afe1522ed9b1e98931d (diff) | |
download | gdb-bc737bc7fb7808d2915cc15cfba4b84b345940f1.zip gdb-bc737bc7fb7808d2915cc15cfba4b84b345940f1.tar.gz gdb-bc737bc7fb7808d2915cc15cfba4b84b345940f1.tar.bz2 |
gdb: Fix gdb.python/py-record-btrace.exp test
My previous patch
commit 8958aefd34200c8d2cd6e81bba32198468789c62 (HEAD)
Author: Felix Willgerodt <felix.willgerodt@intel.com>
Date: Mon Feb 25 15:30:29 2019 +0100
python: Add clear() to gdb.Record.
exposed a clear function for btrace data in python and added some tests
for it. That caused a regression (PR 32086) when recording with bts.
This is reproducible even without my patch, when adding
"maintenance btrace clear" to the test.
When comparing the instructions that get recorded in both cases, the traces
are almost identical, just that the first 3 instructions are missing.
Before clear:
(gdb) record instruction-history 1,100
1 0x0000555555555163 <main+12>: movl $0x0,-0x4(%rbp)
2 0x000055555555516a <main+19>: movl $0x0,-0x8(%rbp)
3 0x0000555555555171 <main+26>: jmp 0x555555555184 <main+45>
4 0x0000555555555184 <main+45>: cmpl $0x63,-0x4(%rbp)
5 0x0000555555555188 <main+49>: jle 0x555555555173 <main+28>
6 0x0000555555555173 <main+28>: mov -0x8(%rbp),%eax
7 0x0000555555555176 <main+31>: mov %eax,%edi
...
After clear:
(gdb) record instruction-history 1,100
1 0x0000555555555184 <main+45>: cmpl $0x63,-0x4(%rbp)
2 0x0000555555555188 <main+49>: jle 0x555555555173 <main+28>
3 0x0000555555555173 <main+28>: mov -0x8(%rbp),%eax
4 0x0000555555555176 <main+31>: mov %eax,%edi
...
The GDB manual describes this behaviour already:
maint btrace clear
Discard the branch trace data. The data will be fetched anew and
the branch trace will be recomputed when needed.
This implicitly truncates the branch trace to a single branch trace
buffer. When updating branch trace incrementally, the branch trace
available to GDB may be bigger than a single branch trace buffer.
The test with BTS is updating the recorded trace incrementally. After the
clear, the buffer of raw trace data available is not enough to recompute the
whole trace as it was before the clear(), and the first 3 instructions are
missing.
As increasing the buffer size for BTS didn't help, I propose to fix the test
by moving the testing of clear to the end of the test.
Approved-By: Tom de Vries <tdevries@suse.de>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32086
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/gdb.python/py-record-btrace.exp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp b/gdb/testsuite/gdb.python/py-record-btrace.exp index 0731af1..b035e14 100644 --- a/gdb/testsuite/gdb.python/py-record-btrace.exp +++ b/gdb/testsuite/gdb.python/py-record-btrace.exp @@ -144,10 +144,6 @@ with_test_prefix "instruction " { gdb_test "python print(i.decoded)" ".*" gdb_test "python print(i.size)" "$decimal" gdb_test "python print(i.is_speculative)" "False" - gdb_test_no_output "python r.clear()" - gdb_test "python insn = r.instruction_history" - gdb_test_no_output "python i = insn\[0\]" - gdb_test "python print(i.size)" "$decimal" "size after clear" } with_test_prefix "function call" { @@ -202,3 +198,14 @@ with_test_prefix "level" { gdb_test "python print(gdb.current_recording().function_call_history\[0\].level)" "1" gdb_test "python print(gdb.current_recording().function_call_history\[1\].level)" "0" } + +# Note: GDB can incrementally add to the recording from the raw trace data. +# After a clear(), GDB might not have all the raw trace data available in its +# buffer to recreate the full recording it had before the clear(). +# So, do this testing last to avoid disturbing subsequent tests. +with_test_prefix "clear" { + gdb_test_no_output "python r.clear()" + gdb_test "python insn = r.instruction_history" + gdb_test_no_output "python i = insn\[0\]" + gdb_test "python print(i.size)" "$decimal" +} |