[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.
This commit is contained in:
Walter Erquinigo 2022-10-19 00:18:01 -07:00
parent 6e85b8807f
commit 1e58e3e1e9
2 changed files with 12 additions and 5 deletions

View File

@ -2199,7 +2199,8 @@ protected:
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 @@ protected:
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) {

View File

@ -799,9 +799,14 @@ static TraceDumper::FunctionCall &AppendInstructionToFunctionCallForest(
}
// Now we are in a different 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