Skip to content

Commit

Permalink
[NFC][trace][intel-pt] small test fixes
Browse files Browse the repository at this point in the history
These tests started failing after a change in the disassembler. The fix
is pretty simple though.
  • Loading branch information
walter-erquinigo committed Jun 2, 2021
1 parent 9f5d783 commit e65242e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 31 deletions.
3 changes: 2 additions & 1 deletion lldb/source/Target/Trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ DumpInstructionSymbolContext(Stream &s,
static void DumpInstructionDisassembly(Stream &s, InstructionSymbolInfo &insn) {
if (!insn.instruction)
return;
s.Printf(" ");
insn.instruction->Dump(&s, /*show_address*/ false, /*show_bytes*/ false,
/*max_opcode_byte_size*/ 0, &insn.exe_ctx, &insn.sc,
/*prev_sym_ctx*/ nullptr,
Expand Down Expand Up @@ -341,7 +342,7 @@ void Trace::DumpTraceInstructions(Thread &thread, Stream &s, size_t count,
DumpInstructionSymbolContext(s, prev_insn, *insn);

printInstructionIndex(index);
s.Printf("0x%016" PRIx64 " ", insn->load_address);
s.Printf("0x%016" PRIx64, insn->load_address);

if (!raw)
DumpInstructionDisassembly(s, *insn);
Expand Down
60 changes: 30 additions & 30 deletions lldb/test/API/commands/trace/TestTraceDumpInstructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def testErrorMessages(self):
error=True)

# We now check the output when there's a non-running target
self.expect("target create " +
self.expect("target create " +
os.path.join(self.getSourceDir(), "intelpt-trace", "a.out"))

self.expect("thread trace dump instructions",
Expand All @@ -42,34 +42,34 @@ def testRawDumpInstructions(self):

self.expect("thread trace dump instructions --raw",
substrs=['''thread #1: tid = 3842849, total instructions = 21
[ 1] 0x0000000000400518
[ 2] 0x000000000040051f
[ 3] 0x0000000000400529
[ 4] 0x000000000040052d
[ 5] 0x0000000000400521
[ 6] 0x0000000000400525
[ 7] 0x0000000000400529
[ 8] 0x000000000040052d
[ 9] 0x0000000000400521
[10] 0x0000000000400525
[11] 0x0000000000400529
[12] 0x000000000040052d
[13] 0x0000000000400521
[14] 0x0000000000400525
[15] 0x0000000000400529
[16] 0x000000000040052d
[17] 0x0000000000400521
[18] 0x0000000000400525
[19] 0x0000000000400529
[ 1] 0x0000000000400518
[ 2] 0x000000000040051f
[ 3] 0x0000000000400529
[ 4] 0x000000000040052d
[ 5] 0x0000000000400521
[ 6] 0x0000000000400525
[ 7] 0x0000000000400529
[ 8] 0x000000000040052d
[ 9] 0x0000000000400521
[10] 0x0000000000400525
[11] 0x0000000000400529
[12] 0x000000000040052d
[13] 0x0000000000400521
[14] 0x0000000000400525
[15] 0x0000000000400529
[16] 0x000000000040052d
[17] 0x0000000000400521
[18] 0x0000000000400525
[19] 0x0000000000400529
[20] 0x000000000040052d'''])

# We check if we can pass count and position
self.expect("thread trace dump instructions --count 5 --position 10 --raw",
substrs=['''thread #1: tid = 3842849, total instructions = 21
[ 6] 0x0000000000400525
[ 7] 0x0000000000400529
[ 8] 0x000000000040052d
[ 9] 0x0000000000400521
[ 6] 0x0000000000400525
[ 7] 0x0000000000400529
[ 8] 0x000000000040052d
[ 9] 0x0000000000400521
[10] 0x0000000000400525'''])

# We check if we can access the thread by index id
Expand All @@ -83,7 +83,7 @@ def testRawDumpInstructions(self):

def testDumpFullInstructionsWithMultipleThreads(self):
# We load a trace with two threads
self.expect("trace load -v " +
self.expect("trace load -v " +
os.path.join(self.getSourceDir(), "intelpt-trace", "trace_2threads.json"))

# We print the instructions of two threads simultaneously
Expand Down Expand Up @@ -181,7 +181,7 @@ def testMultiFileTraceWithMissingModule(self):
# - Then, the dump continues in the next synchronization point showing
# a call to an inlined function, which is displayed as [inlined].
# - Finally, a call to libfoo is performed, which invokes libbar inside.
#
#
# Whenever there's a line or symbol change, including the inline case, a
# line is printed showing the symbol context change.
#
Expand Down Expand Up @@ -241,8 +241,8 @@ def testMultiFileTraceWithMissingModule(self):
libbar.so`bar() + 22 at bar.cpp:4
[32] 0x00007ffff79d76a6 movl -0x4(%rbp), %eax
[33] 0x00007ffff79d76a9 popq %rbp
[34] 0x00007ffff79d76aa retq
libfoo.so`foo() + 13 at foo.cpp:4
[34] 0x00007ffff79d76aa retq''',
'''libfoo.so`foo() + 13 at foo.cpp:4
[35] 0x00007ffff7bd96ed movl %eax, -0x4(%rbp)
libfoo.so`foo() + 16 at foo.cpp:5
[36] 0x00007ffff7bd96f0 movl -0x4(%rbp), %eax
Expand All @@ -252,8 +252,8 @@ def testMultiFileTraceWithMissingModule(self):
[39] 0x00007ffff7bd96fb movl -0x4(%rbp), %eax
[40] 0x00007ffff7bd96fe addq $0x10, %rsp
[41] 0x00007ffff7bd9702 popq %rbp
[42] 0x00007ffff7bd9703 retq
a.out`main + 68 at main.cpp:16
[42] 0x00007ffff7bd9703 retq''',
'''a.out`main + 68 at main.cpp:16
[43] 0x00000000004006a4 movl -0xc(%rbp), %ecx
[44] 0x00000000004006a7 addl %eax, %ecx
[45] 0x00000000004006a9 movl %ecx, -0xc(%rbp)'''])

0 comments on commit e65242e

Please sign in to comment.