Author: Walter Erquinigo Date: 2022-10-19T00:44:48-07:00 New Revision: 1e58e3e1e96096f2d8db759555cf5132c5860519
URL: https://github.com/llvm/llvm-project/commit/1e58e3e1e96096f2d8db759555cf5132c5860519 DIFF: https://github.com/llvm/llvm-project/commit/1e58e3e1e96096f2d8db759555cf5132c5860519.diff LOG: [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. Added: Modified: lldb/source/Commands/CommandObjectThread.cpp lldb/source/Target/TraceDumper.cpp Removed: ################################################################################ diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 414acfb23ef9d..bfe85043f3703 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -2199,7 +2199,8 @@ class CommandObjectTraceDumpFunctionCalls : public CommandObjectParsed { llvm::Optional<StreamFile> out_file; if (m_options.m_output_file) { out_file.emplace(m_options.m_output_file->GetPath().c_str(), - File::eOpenOptionWriteOnly | File::eOpenOptionCanCreate); + File::eOpenOptionWriteOnly | File::eOpenOptionCanCreate | + File::eOpenOptionTruncate); } m_options.m_dumper_options.forwards = true; @@ -2395,7 +2396,8 @@ class CommandObjectTraceDumpInstructions : public CommandObjectParsed { llvm::Optional<StreamFile> out_file; if (m_options.m_output_file) { out_file.emplace(m_options.m_output_file->GetPath().c_str(), - File::eOpenOptionWriteOnly | File::eOpenOptionCanCreate); + File::eOpenOptionWriteOnly | File::eOpenOptionCanCreate | + File::eOpenOptionTruncate); } if (m_options.m_continue && !m_last_id) { diff --git a/lldb/source/Target/TraceDumper.cpp b/lldb/source/Target/TraceDumper.cpp index 7a5214d7cff0f..268dc039365f7 100644 --- a/lldb/source/Target/TraceDumper.cpp +++ b/lldb/source/Target/TraceDumper.cpp @@ -799,9 +799,14 @@ static TraceDumper::FunctionCall &AppendInstructionToFunctionCallForest( } // Now we are in a diff erent symbol. Let's see if this is a return or a // call - switch (last_function_call->GetLastTracedSegment() - .GetLastInstructionSymbolInfo() - .instruction->GetControlFlowKind(&exe_ctx)) { + const InstructionSP &insn = last_function_call->GetLastTracedSegment() + .GetLastInstructionSymbolInfo() + .instruction; + InstructionControlFlowKind insn_kind = + insn ? insn->GetControlFlowKind(&exe_ctx) + : eInstructionControlFlowKindOther; + + switch (insn_kind) { case lldb::eInstructionControlFlowKindCall: case lldb::eInstructionControlFlowKindFarCall: { // This is a regular call _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits