[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 08:23:27 +01:00
|
|
|
//===-- ThreadPlanTracer.cpp ----------------------------------------------===//
|
2010-11-11 19:26:09 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-11-11 19:26:09 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
2015-12-15 01:33:19 +00:00
|
|
|
#include <cstring>
|
|
|
|
|
|
2010-11-11 19:26:09 +00:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2010-11-12 03:22:21 +00:00
|
|
|
#include "lldb/Core/Disassembler.h"
|
2018-07-24 15:48:13 +00:00
|
|
|
#include "lldb/Core/DumpRegisterValue.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-29 21:13:06 +00:00
|
|
|
#include "lldb/Core/Module.h"
|
2010-11-12 03:22:21 +00:00
|
|
|
#include "lldb/Core/Value.h"
|
|
|
|
|
#include "lldb/Symbol/TypeList.h"
|
2015-09-21 16:56:08 +00:00
|
|
|
#include "lldb/Symbol/TypeSystem.h"
|
2015-03-03 19:23:09 +00:00
|
|
|
#include "lldb/Target/ABI.h"
|
2010-11-11 19:26:09 +00:00
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2013-12-06 01:12:00 +00:00
|
|
|
#include "lldb/Target/SectionLoadList.h"
|
2010-11-11 19:26:09 +00:00
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
|
#include "lldb/Target/Thread.h"
|
2015-12-15 01:33:19 +00:00
|
|
|
#include "lldb/Target/ThreadPlan.h"
|
2017-03-04 01:30:05 +00:00
|
|
|
#include "lldb/Utility/DataBufferHeap.h"
|
|
|
|
|
#include "lldb/Utility/DataExtractor.h"
|
2022-02-03 13:26:10 +01:00
|
|
|
#include "lldb/Utility/LLDBLog.h"
|
2017-03-03 20:56:28 +00:00
|
|
|
#include "lldb/Utility/Log.h"
|
2018-08-07 11:07:21 +00:00
|
|
|
#include "lldb/Utility/State.h"
|
2025-02-19 08:31:40 -08:00
|
|
|
#include "lldb/lldb-forward.h"
|
2010-11-11 19:26:09 +00:00
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
2010-11-12 03:22:21 +00:00
|
|
|
#pragma mark ThreadPlanTracer
|
|
|
|
|
|
2010-11-11 19:26:09 +00:00
|
|
|
ThreadPlanTracer::ThreadPlanTracer(Thread &thread, lldb::StreamSP &stream_sp)
|
2020-03-10 14:04:42 -07:00
|
|
|
: m_process(*thread.GetProcess().get()), m_tid(thread.GetID()),
|
[LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan. Part 2
Improve LLDB reliability by fixing the following "uninitialized variables" static code inspection warnings from
scan.coverity.com:
1476275, 1274012, 1455035, 1364789, 1454282
1467483, 1406152, 1406255, 1454837, 1454416
1467446, 1462022, 1461909, 1420566, 1327228
1367767, 1431254, 1467299, 1312678, 1431780
1454731, 1490403
Differential Revision: https://reviews.llvm.org/D130528
2022-07-25 15:52:21 -07:00
|
|
|
m_enabled(false), m_stream_sp(stream_sp), m_thread(nullptr) {}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-11-11 19:26:09 +00:00
|
|
|
ThreadPlanTracer::ThreadPlanTracer(Thread &thread)
|
2020-03-10 14:04:42 -07:00
|
|
|
: m_process(*thread.GetProcess().get()), m_tid(thread.GetID()),
|
[LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan. Part 2
Improve LLDB reliability by fixing the following "uninitialized variables" static code inspection warnings from
scan.coverity.com:
1476275, 1274012, 1455035, 1364789, 1454282
1467483, 1406152, 1406255, 1454837, 1454416
1467446, 1462022, 1461909, 1420566, 1327228
1367767, 1431254, 1467299, 1312678, 1431780
1454731, 1490403
Differential Revision: https://reviews.llvm.org/D130528
2022-07-25 15:52:21 -07:00
|
|
|
m_enabled(false), m_stream_sp(), m_thread(nullptr) {}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2025-02-19 08:31:40 -08:00
|
|
|
StreamSP ThreadPlanTracer::GetLogStreamSP() {
|
2010-11-11 19:26:09 +00:00
|
|
|
if (m_stream_sp)
|
2025-02-19 08:31:40 -08:00
|
|
|
return m_stream_sp;
|
2010-11-11 19:26:09 +00:00
|
|
|
else {
|
2020-03-10 14:04:42 -07:00
|
|
|
TargetSP target_sp(GetThread().CalculateTarget());
|
2012-02-21 00:09:25 +00:00
|
|
|
if (target_sp)
|
2025-02-19 08:31:40 -08:00
|
|
|
return target_sp->GetDebugger().GetAsyncOutputStream();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-12-15 01:33:19 +00:00
|
|
|
return nullptr;
|
2010-11-11 19:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-10 14:04:42 -07:00
|
|
|
Thread &ThreadPlanTracer::GetThread() {
|
|
|
|
|
if (m_thread)
|
|
|
|
|
return *m_thread;
|
2023-07-05 10:47:14 -07:00
|
|
|
|
2020-03-10 14:04:42 -07:00
|
|
|
ThreadSP thread_sp = m_process.GetThreadList().FindThreadByID(m_tid);
|
|
|
|
|
m_thread = thread_sp.get();
|
|
|
|
|
return *m_thread;
|
|
|
|
|
}
|
2010-11-11 19:26:09 +00:00
|
|
|
void ThreadPlanTracer::Log() {
|
|
|
|
|
SymbolContext sc;
|
|
|
|
|
bool show_frame_index = false;
|
|
|
|
|
bool show_fullpaths = false;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2025-02-19 08:31:40 -08:00
|
|
|
if (StreamSP stream_sp = GetLogStreamSP()) {
|
|
|
|
|
GetThread().GetStackFrameAtIndex(0)->Dump(stream_sp.get(), show_frame_index,
|
2020-03-10 14:04:42 -07:00
|
|
|
show_fullpaths);
|
2025-02-19 08:31:40 -08:00
|
|
|
stream_sp->Printf("\n");
|
|
|
|
|
stream_sp->Flush();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-11-11 19:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ThreadPlanTracer::TracerExplainsStop() {
|
2021-02-13 15:48:05 -08:00
|
|
|
if (m_enabled) {
|
2020-03-10 14:04:42 -07:00
|
|
|
lldb::StopInfoSP stop_info = GetThread().GetStopInfo();
|
2010-11-11 19:26:09 +00:00
|
|
|
return (stop_info->GetStopReason() == eStopReasonTrace);
|
|
|
|
|
} else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-11-12 03:22:21 +00:00
|
|
|
|
|
|
|
|
#pragma mark ThreadPlanAssemblyTracer
|
|
|
|
|
|
|
|
|
|
ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer(Thread &thread,
|
|
|
|
|
lldb::StreamSP &stream_sp)
|
|
|
|
|
: ThreadPlanTracer(thread, stream_sp), m_disassembler_sp(), m_intptr_type(),
|
2011-08-12 21:40:01 +00:00
|
|
|
m_register_values() {}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-11-17 20:19:50 +00:00
|
|
|
ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer(Thread &thread)
|
2012-08-01 18:50:59 +00:00
|
|
|
: ThreadPlanTracer(thread), m_disassembler_sp(), m_intptr_type(),
|
2011-08-12 21:40:01 +00:00
|
|
|
m_register_values() {}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-11-12 03:22:21 +00:00
|
|
|
Disassembler *ThreadPlanAssemblyTracer::GetDisassembler() {
|
2015-12-15 01:33:19 +00:00
|
|
|
if (!m_disassembler_sp)
|
2024-11-11 16:27:15 -08:00
|
|
|
m_disassembler_sp =
|
|
|
|
|
Disassembler::FindPlugin(m_process.GetTarget().GetArchitecture(),
|
|
|
|
|
nullptr, nullptr, nullptr, nullptr);
|
2012-08-01 18:50:59 +00:00
|
|
|
return m_disassembler_sp.get();
|
2010-11-17 20:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-08-12 21:40:01 +00:00
|
|
|
TypeFromUser ThreadPlanAssemblyTracer::GetIntPointerType() {
|
2015-12-15 01:33:19 +00:00
|
|
|
if (!m_intptr_type.IsValid()) {
|
2020-03-10 14:04:42 -07:00
|
|
|
if (auto target_sp = m_process.CalculateTarget()) {
|
2019-07-30 22:12:34 +00:00
|
|
|
auto type_system_or_err =
|
|
|
|
|
target_sp->GetScratchTypeSystemForLanguage(eLanguageTypeC);
|
|
|
|
|
if (auto err = type_system_or_err.takeError()) {
|
2023-07-05 10:47:14 -07:00
|
|
|
LLDB_LOG_ERROR(
|
|
|
|
|
GetLog(LLDBLog::Types), std::move(err),
|
|
|
|
|
"Unable to get integer pointer type from TypeSystem: {0}");
|
2019-07-30 22:12:34 +00:00
|
|
|
} else {
|
2022-11-14 16:24:36 -08:00
|
|
|
if (auto ts = *type_system_or_err)
|
|
|
|
|
m_intptr_type = TypeFromUser(ts->GetBuiltinTypeForEncodingAndBitSize(
|
|
|
|
|
eEncodingUint,
|
|
|
|
|
target_sp->GetArchitecture().GetAddressByteSize() * 8));
|
2019-07-30 22:12:34 +00:00
|
|
|
}
|
2011-08-12 21:40:01 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-08-12 21:40:01 +00:00
|
|
|
return m_intptr_type;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-15 01:33:19 +00:00
|
|
|
ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer() = default;
|
2010-11-12 03:22:21 +00:00
|
|
|
|
2011-01-06 22:15:06 +00:00
|
|
|
void ThreadPlanAssemblyTracer::TracingStarted() {
|
2010-11-12 03:22:21 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-06 22:15:06 +00:00
|
|
|
void ThreadPlanAssemblyTracer::TracingEnded() { m_register_values.clear(); }
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-01-06 22:15:06 +00:00
|
|
|
void ThreadPlanAssemblyTracer::Log() {
|
2025-02-19 08:31:40 -08:00
|
|
|
StreamSP stream_sp = GetLogStreamSP();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2025-02-19 08:31:40 -08:00
|
|
|
if (!stream_sp)
|
2010-11-12 03:22:21 +00:00
|
|
|
return;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2020-03-10 14:04:42 -07:00
|
|
|
RegisterContext *reg_ctx = GetThread().GetRegisterContext().get();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-11-12 03:22:21 +00:00
|
|
|
lldb::addr_t pc = reg_ctx->GetPC();
|
|
|
|
|
Address pc_addr;
|
|
|
|
|
bool addr_valid = false;
|
2011-08-12 21:40:01 +00:00
|
|
|
uint8_t buffer[16] = {0}; // Must be big enough for any single instruction
|
2025-01-14 20:12:46 -08:00
|
|
|
addr_valid = m_process.GetTarget().ResolveLoadAddress(pc, pc_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2025-02-19 08:31:40 -08:00
|
|
|
pc_addr.Dump(stream_sp.get(), &GetThread(),
|
|
|
|
|
Address::DumpStyleResolvedDescription,
|
2011-05-18 01:58:14 +00:00
|
|
|
Address::DumpStyleModuleWithFileAddress);
|
2025-02-19 08:31:40 -08:00
|
|
|
stream_sp->PutCString(" ");
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-08-12 21:40:01 +00:00
|
|
|
Disassembler *disassembler = GetDisassembler();
|
|
|
|
|
if (disassembler) {
|
2017-05-12 04:51:55 +00:00
|
|
|
Status err;
|
2020-03-10 14:04:42 -07:00
|
|
|
m_process.ReadMemory(pc, buffer, sizeof(buffer), err);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-11-12 03:22:21 +00:00
|
|
|
if (err.Success()) {
|
2020-03-10 14:04:42 -07:00
|
|
|
DataExtractor extractor(buffer, sizeof(buffer), m_process.GetByteOrder(),
|
|
|
|
|
m_process.GetAddressByteSize());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-03-28 23:42:53 +00:00
|
|
|
bool data_from_file = false;
|
2010-11-12 03:22:21 +00:00
|
|
|
if (addr_valid)
|
2013-03-28 23:42:53 +00:00
|
|
|
disassembler->DecodeInstructions(pc_addr, extractor, 0, 1, false,
|
|
|
|
|
data_from_file);
|
2010-11-12 03:22:21 +00:00
|
|
|
else
|
2013-03-28 23:42:53 +00:00
|
|
|
disassembler->DecodeInstructions(Address(pc), extractor, 0, 1, false,
|
|
|
|
|
data_from_file);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-08-12 21:40:01 +00:00
|
|
|
InstructionList &instruction_list = disassembler->GetInstructionList();
|
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-26 19:14:58 +00:00
|
|
|
const uint32_t max_opcode_byte_size =
|
|
|
|
|
instruction_list.GetMaxOpcocdeByteSize();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-11-12 03:22:21 +00:00
|
|
|
if (instruction_list.GetSize()) {
|
2011-05-18 01:58:14 +00:00
|
|
|
const bool show_bytes = true;
|
|
|
|
|
const bool show_address = true;
|
[trace] Add a flag to the decoder to output the instruction type
To build complex binding upon instruction trace, additional metadata 'instruction type' is needed.
This diff has followings:
- Add a flag -k / --kind for instruction dump
- Remove SetGranularity and SetIgnoreErros from Trace cursor
Sample output:
```
(lldb) thread trace dump instruction -k
thread #1: tid = 3198805
libc.so.6`_IO_puts + 356
2107: 0x00007ffff7163594 ( return) retq
2106: 0x00007ffff7163592 ( other) popq %r13
2105: 0x00007ffff7163590 ( other) popq %r12
2104: 0x00007ffff716358f ( other) popq %rbp
2103: 0x00007ffff716358e ( other) popq %rbx
2102: 0x00007ffff716358c ( other) movl %ebx, %eax
2101: 0x00007ffff7163588 ( other) addq $0x8, %rsp
2100: 0x00007ffff7163570 ( cond jump) je 0x89588 ; <+344>
2099: 0x00007ffff716356e ( other) decl (%rdx)
2098: 0x00007ffff7163565 ( cond jump) je 0x8956e ; <+318>
2097: 0x00007ffff716355e ( other) cmpl $0x0, 0x33c02b(%rip) ; __libc_multiple_threads
2096: 0x00007ffff7163556 ( other) movq $0x0, 0x8(%rdx)
2095: 0x00007ffff7163554 ( cond jump) jne 0x89588 ; <+344>
2094: 0x00007ffff7163550 ( other) subl $0x1, 0x4(%rdx)
2093: 0x00007ffff7163549 ( other) movq 0x88(%rbp), %rdx
2092: 0x00007ffff7163547 ( cond jump) jne 0x89588 ; <+344>
2091: 0x00007ffff7163540 ( other) testl $0x8000, (%rbp) ; imm = 0x8000
2090: 0x00007ffff716353c ( other) cmovaq %rax, %rbx
2089: 0x00007ffff7163535 ( other) cmpq $0x7fffffff, %rbx ; imm = 0x7FFFFFFF
2088: 0x00007ffff7163530 ( other) movl $0x7fffffff, %eax ; imm = 0x7FFFFFFF
```
Reviewed By: wallace
Differential Revision: https://reviews.llvm.org/D128477
2022-07-12 16:09:03 -07:00
|
|
|
const bool show_control_flow_kind = true;
|
2010-11-12 03:22:21 +00:00
|
|
|
Instruction *instruction =
|
|
|
|
|
instruction_list.GetInstructionAtIndex(0).get();
|
2025-06-03 19:12:30 -07:00
|
|
|
FormatEntity::Entry disassemble_format =
|
2020-03-10 14:04:42 -07:00
|
|
|
m_process.GetTarget().GetDebugger().GetDisassemblyFormat();
|
2025-02-19 08:31:40 -08:00
|
|
|
instruction->Dump(stream_sp.get(), max_opcode_byte_size, show_address,
|
[trace] Add a flag to the decoder to output the instruction type
To build complex binding upon instruction trace, additional metadata 'instruction type' is needed.
This diff has followings:
- Add a flag -k / --kind for instruction dump
- Remove SetGranularity and SetIgnoreErros from Trace cursor
Sample output:
```
(lldb) thread trace dump instruction -k
thread #1: tid = 3198805
libc.so.6`_IO_puts + 356
2107: 0x00007ffff7163594 ( return) retq
2106: 0x00007ffff7163592 ( other) popq %r13
2105: 0x00007ffff7163590 ( other) popq %r12
2104: 0x00007ffff716358f ( other) popq %rbp
2103: 0x00007ffff716358e ( other) popq %rbx
2102: 0x00007ffff716358c ( other) movl %ebx, %eax
2101: 0x00007ffff7163588 ( other) addq $0x8, %rsp
2100: 0x00007ffff7163570 ( cond jump) je 0x89588 ; <+344>
2099: 0x00007ffff716356e ( other) decl (%rdx)
2098: 0x00007ffff7163565 ( cond jump) je 0x8956e ; <+318>
2097: 0x00007ffff716355e ( other) cmpl $0x0, 0x33c02b(%rip) ; __libc_multiple_threads
2096: 0x00007ffff7163556 ( other) movq $0x0, 0x8(%rdx)
2095: 0x00007ffff7163554 ( cond jump) jne 0x89588 ; <+344>
2094: 0x00007ffff7163550 ( other) subl $0x1, 0x4(%rdx)
2093: 0x00007ffff7163549 ( other) movq 0x88(%rbp), %rdx
2092: 0x00007ffff7163547 ( cond jump) jne 0x89588 ; <+344>
2091: 0x00007ffff7163540 ( other) testl $0x8000, (%rbp) ; imm = 0x8000
2090: 0x00007ffff716353c ( other) cmovaq %rax, %rbx
2089: 0x00007ffff7163535 ( other) cmpq $0x7fffffff, %rbx ; imm = 0x7FFFFFFF
2088: 0x00007ffff7163530 ( other) movl $0x7fffffff, %eax ; imm = 0x7FFFFFFF
```
Reviewed By: wallace
Differential Revision: https://reviews.llvm.org/D128477
2022-07-12 16:09:03 -07:00
|
|
|
show_bytes, show_control_flow_kind, nullptr, nullptr,
|
2025-06-03 19:12:30 -07:00
|
|
|
nullptr, &disassemble_format, 0);
|
2010-11-12 03:22:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-10 14:04:42 -07:00
|
|
|
const ABI *abi = m_process.GetABI().get();
|
2011-08-12 21:40:01 +00:00
|
|
|
TypeFromUser intptr_type = GetIntPointerType();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-08-12 21:40:01 +00:00
|
|
|
if (abi && intptr_type.IsValid()) {
|
2010-11-12 03:22:21 +00:00
|
|
|
ValueList value_list;
|
|
|
|
|
const int num_args = 1;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-11-12 03:22:21 +00:00
|
|
|
for (int arg_index = 0; arg_index < num_args; ++arg_index) {
|
|
|
|
|
Value value;
|
2021-02-11 12:57:04 -08:00
|
|
|
value.SetValueType(Value::ValueType::Scalar);
|
2015-08-24 23:46:31 +00:00
|
|
|
value.SetCompilerType(intptr_type);
|
2010-11-12 03:22:21 +00:00
|
|
|
value_list.PushValue(value);
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2020-03-10 14:04:42 -07:00
|
|
|
if (abi->GetArgumentValues(GetThread(), value_list)) {
|
2010-11-12 03:22:21 +00:00
|
|
|
for (int arg_index = 0; arg_index < num_args; ++arg_index) {
|
2025-02-19 08:31:40 -08:00
|
|
|
stream_sp->Printf(
|
2011-05-18 01:58:14 +00:00
|
|
|
"\n\targ[%d]=%llx", arg_index,
|
|
|
|
|
value_list.GetValueAtIndex(arg_index)->GetScalar().ULongLong());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-11-12 03:22:21 +00:00
|
|
|
if (arg_index + 1 < num_args)
|
2025-02-19 08:31:40 -08:00
|
|
|
stream_sp->PutCString(", ");
|
2010-11-12 03:22:21 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-20 10:56:39 -08:00
|
|
|
if (m_register_values.empty()) {
|
2020-03-10 14:04:42 -07:00
|
|
|
RegisterContext *reg_ctx = GetThread().GetRegisterContext().get();
|
2019-12-20 10:56:39 -08:00
|
|
|
m_register_values.resize(reg_ctx->GetRegisterCount());
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-18 01:58:14 +00:00
|
|
|
RegisterValue reg_value;
|
|
|
|
|
for (uint32_t reg_num = 0, num_registers = reg_ctx->GetRegisterCount();
|
|
|
|
|
reg_num < num_registers; ++reg_num) {
|
|
|
|
|
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num);
|
|
|
|
|
if (reg_ctx->ReadRegister(reg_info, reg_value)) {
|
|
|
|
|
assert(reg_num < m_register_values.size());
|
|
|
|
|
if (m_register_values[reg_num].GetType() == RegisterValue::eTypeInvalid ||
|
|
|
|
|
reg_value != m_register_values[reg_num]) {
|
|
|
|
|
if (reg_value.GetType() != RegisterValue::eTypeInvalid) {
|
2025-02-19 08:31:40 -08:00
|
|
|
stream_sp->PutCString("\n\t");
|
|
|
|
|
DumpRegisterValue(reg_value, *stream_sp, *reg_info, true, false,
|
2018-07-24 15:48:13 +00:00
|
|
|
eFormatDefault);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-05-18 01:58:14 +00:00
|
|
|
}
|
|
|
|
|
m_register_values[reg_num] = reg_value;
|
2010-11-12 03:22:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
2025-02-19 08:31:40 -08:00
|
|
|
stream_sp->EOL();
|
|
|
|
|
stream_sp->Flush();
|
2010-11-12 03:22:21 +00:00
|
|
|
}
|