mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 21:55:39 +08:00
Add a new disassembly-format specification so that the disassembler
output style can be customized. Change the built-in default to be
more similar to gdb's disassembly formatting.
The disassembly-format for a gdb-like output is
${addr-file-or-load} <${function.name-without-args}${function.concrete-only-addr-offset-no-padding}>:
The disassembly-format for the lldb style output is
{${function.initial-function}{${module.file.basename}`}{${function.name-without-args}}:\n}{${function.changed}\n{${module.file.basename}`}{${function.name-without-args}}:\n}{${current-pc-arrow} }{${addr-file-or-load}}:
The two backticks in the lldb style formatter triggers the sub-expression evaluation in
CommandInterpreter::PreprocessCommand() so you can't use that one as-is ... changing to
use ' characters instead of ` would work around that.
<rdar://problem/9885398>
llvm-svn: 219544
This commit is contained in:
@@ -410,17 +410,18 @@ Disassembler::PrintInstructions
|
||||
SymbolContext prev_sc;
|
||||
AddressRange sc_range;
|
||||
const Address *pc_addr_ptr = NULL;
|
||||
ExecutionContextScope *exe_scope = exe_ctx.GetBestExecutionContextScope();
|
||||
StackFrame *frame = exe_ctx.GetFramePtr();
|
||||
|
||||
TargetSP target_sp (exe_ctx.GetTargetSP());
|
||||
SourceManager &source_manager = target_sp ? target_sp->GetSourceManager() : debugger.GetSourceManager();
|
||||
|
||||
if (frame)
|
||||
{
|
||||
pc_addr_ptr = &frame->GetFrameCodeAddress();
|
||||
}
|
||||
const uint32_t scope = eSymbolContextLineEntry | eSymbolContextFunction | eSymbolContextSymbol;
|
||||
const bool use_inline_block_range = false;
|
||||
for (size_t i=0; i<num_instructions_found; ++i)
|
||||
for (size_t i = 0; i < num_instructions_found; ++i)
|
||||
{
|
||||
Instruction *inst = disasm_ptr->GetInstructionList().GetInstructionAtIndex (i).get();
|
||||
if (inst)
|
||||
@@ -447,7 +448,7 @@ Disassembler::PrintInstructions
|
||||
if (offset != 0)
|
||||
strm.EOL();
|
||||
|
||||
sc.DumpStopContext(&strm, exe_ctx.GetProcessPtr(), addr, false, true, false);
|
||||
sc.DumpStopContext(&strm, exe_ctx.GetProcessPtr(), addr, false, true, false, false);
|
||||
strm.EOL();
|
||||
|
||||
if (sc.comp_unit && sc.line_entry.IsValid())
|
||||
@@ -462,23 +463,6 @@ Disassembler::PrintInstructions
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((sc.function || sc.symbol) && (sc.function != prev_sc.function || sc.symbol != prev_sc.symbol))
|
||||
{
|
||||
if (prev_sc.function || prev_sc.symbol)
|
||||
strm.EOL();
|
||||
|
||||
bool show_fullpaths = false;
|
||||
bool show_module = true;
|
||||
bool show_inlined_frames = true;
|
||||
sc.DumpStopContext (&strm,
|
||||
exe_scope,
|
||||
addr,
|
||||
show_fullpaths,
|
||||
show_module,
|
||||
show_inlined_frames);
|
||||
|
||||
strm << ":\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -486,12 +470,13 @@ Disassembler::PrintInstructions
|
||||
}
|
||||
}
|
||||
|
||||
if ((options & eOptionMarkPCAddress) && pc_addr_ptr)
|
||||
{
|
||||
strm.PutCString(inst_is_at_pc ? "-> " : " ");
|
||||
}
|
||||
const bool show_bytes = (options & eOptionShowBytes) != 0;
|
||||
inst->Dump(&strm, max_opcode_byte_size, true, show_bytes, &exe_ctx);
|
||||
const char *disassembly_format = "${addr-file-or-load}: ";
|
||||
if (exe_ctx.HasTargetScope())
|
||||
{
|
||||
disassembly_format = exe_ctx.GetTargetRef().GetDebugger().GetDisassemblyFormat ();
|
||||
}
|
||||
inst->Dump (&strm, max_opcode_byte_size, true, show_bytes, &exe_ctx, &sc, &prev_sc, disassembly_format);
|
||||
strm.EOL();
|
||||
}
|
||||
else
|
||||
@@ -578,7 +563,10 @@ Instruction::Dump (lldb_private::Stream *s,
|
||||
uint32_t max_opcode_byte_size,
|
||||
bool show_address,
|
||||
bool show_bytes,
|
||||
const ExecutionContext* exe_ctx)
|
||||
const ExecutionContext* exe_ctx,
|
||||
const SymbolContext *sym_ctx,
|
||||
const SymbolContext *prev_sym_ctx,
|
||||
const char *disassembly_addr_format_spec)
|
||||
{
|
||||
size_t opcode_column_width = 7;
|
||||
const size_t operand_column_width = 25;
|
||||
@@ -589,13 +577,7 @@ Instruction::Dump (lldb_private::Stream *s,
|
||||
|
||||
if (show_address)
|
||||
{
|
||||
m_address.Dump(&ss,
|
||||
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL,
|
||||
Address::DumpStyleLoadAddress,
|
||||
Address::DumpStyleModuleWithFileAddress,
|
||||
0);
|
||||
|
||||
ss.PutCString(": ");
|
||||
Debugger::FormatDisassemblerAddress (disassembly_addr_format_spec, sym_ctx, prev_sym_ctx, exe_ctx, &m_address, ss);
|
||||
}
|
||||
|
||||
if (show_bytes)
|
||||
@@ -621,7 +603,7 @@ Instruction::Dump (lldb_private::Stream *s,
|
||||
}
|
||||
}
|
||||
|
||||
const size_t opcode_pos = ss.GetSize();
|
||||
const size_t opcode_pos = ss.GetSizeOfLastLine();
|
||||
|
||||
// The default opcode size of 7 characters is plenty for most architectures
|
||||
// but some like arm can pull out the occasional vqrshrun.s16. We won't get
|
||||
@@ -1003,13 +985,18 @@ InstructionList::Dump (Stream *s,
|
||||
{
|
||||
const uint32_t max_opcode_byte_size = GetMaxOpcocdeByteSize();
|
||||
collection::const_iterator pos, begin, end;
|
||||
const char *disassemble_format = "${addr-file-or-load}: ";
|
||||
if (exe_ctx)
|
||||
{
|
||||
disassemble_format = exe_ctx->GetTargetRef().GetDebugger().GetDisassemblyFormat ();
|
||||
}
|
||||
for (begin = m_instructions.begin(), end = m_instructions.end(), pos = begin;
|
||||
pos != end;
|
||||
++pos)
|
||||
{
|
||||
if (pos != begin)
|
||||
s->EOL();
|
||||
(*pos)->Dump(s, max_opcode_byte_size, show_address, show_bytes, exe_ctx);
|
||||
(*pos)->Dump(s, max_opcode_byte_size, show_address, show_bytes, exe_ctx, NULL, NULL, disassemble_format);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user