Skip to content

Commit 1e58e3e

Browse files
author
Walter Erquinigo
committed
[lldb][trace] Fix some minor bugs in the call tree
- We weren't truncating the output files - We weren't considering the case in which we couldn't disassembly an instruction.
1 parent 6e85b88 commit 1e58e3e

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

lldb/source/Commands/CommandObjectThread.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,7 +2199,8 @@ class CommandObjectTraceDumpFunctionCalls : public CommandObjectParsed {
21992199
llvm::Optional<StreamFile> out_file;
22002200
if (m_options.m_output_file) {
22012201
out_file.emplace(m_options.m_output_file->GetPath().c_str(),
2202-
File::eOpenOptionWriteOnly | File::eOpenOptionCanCreate);
2202+
File::eOpenOptionWriteOnly | File::eOpenOptionCanCreate |
2203+
File::eOpenOptionTruncate);
22032204
}
22042205

22052206
m_options.m_dumper_options.forwards = true;
@@ -2395,7 +2396,8 @@ class CommandObjectTraceDumpInstructions : public CommandObjectParsed {
23952396
llvm::Optional<StreamFile> out_file;
23962397
if (m_options.m_output_file) {
23972398
out_file.emplace(m_options.m_output_file->GetPath().c_str(),
2398-
File::eOpenOptionWriteOnly | File::eOpenOptionCanCreate);
2399+
File::eOpenOptionWriteOnly | File::eOpenOptionCanCreate |
2400+
File::eOpenOptionTruncate);
23992401
}
24002402

24012403
if (m_options.m_continue && !m_last_id) {

lldb/source/Target/TraceDumper.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -799,9 +799,14 @@ static TraceDumper::FunctionCall &AppendInstructionToFunctionCallForest(
799799
}
800800
// Now we are in a different symbol. Let's see if this is a return or a
801801
// call
802-
switch (last_function_call->GetLastTracedSegment()
803-
.GetLastInstructionSymbolInfo()
804-
.instruction->GetControlFlowKind(&exe_ctx)) {
802+
const InstructionSP &insn = last_function_call->GetLastTracedSegment()
803+
.GetLastInstructionSymbolInfo()
804+
.instruction;
805+
InstructionControlFlowKind insn_kind =
806+
insn ? insn->GetControlFlowKind(&exe_ctx)
807+
: eInstructionControlFlowKindOther;
808+
809+
switch (insn_kind) {
805810
case lldb::eInstructionControlFlowKindCall:
806811
case lldb::eInstructionControlFlowKindFarCall: {
807812
// This is a regular call

0 commit comments

Comments
 (0)