summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-03-25 18:03:16 +0000
committerGreg Clayton <gclayton@apple.com>2011-03-25 18:03:16 +0000
commit1080edbcdd7d24ad5213749e396e23b54c1a3040 (patch)
tree25cb5d0a1e62ba603df46e3376cdf4dfeb1969ca /lldb/source/Commands
parent6f4c9425eb5b689a2a4bfa19531ef9ab4c5c6e5d (diff)
downloadbcm5719-llvm-1080edbcdd7d24ad5213749e396e23b54c1a3040.tar.gz
bcm5719-llvm-1080edbcdd7d24ad5213749e396e23b54c1a3040.zip
Cleaned up the Disassembler code a bit more. You can now request a disassembler
plugin by name on the command line for when there is more than one disassembler plugin. Taught the Opcode class to dump itself so that "disassembler -b" will dump the bytes correctly for each opcode type. Modified all places that were passing the opcode bytes buffer in so that the bytes could be displayed to just pass in a bool that indicates if we should dump the opcode bytes since the opcode now lives inside llvm_private::Instruction. llvm-svn: 128290
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r--lldb/source/Commands/CommandObjectDisassemble.cpp33
-rw-r--r--lldb/source/Commands/CommandObjectDisassemble.h10
2 files changed, 35 insertions, 8 deletions
diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp
index 26752b86fbd..c3b52cfeab8 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -39,7 +39,8 @@ CommandObjectDisassemble::CommandOptions::CommandOptions () :
m_func_name(),
m_start_addr(),
m_end_addr (),
- m_at_pc (false)
+ m_at_pc (false),
+ m_plugin_name ()
{
ResetOptionValues();
}
@@ -97,13 +98,17 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (int option_idx, const
break;
case 'n':
- m_func_name = option_arg;
+ m_func_name.assign (option_arg);
break;
case 'p':
m_at_pc = true;
break;
+ case 'P':
+ m_plugin_name.assign (option_arg);
+ break;
+
case 'r':
raw = true;
break;
@@ -134,6 +139,7 @@ CommandObjectDisassemble::CommandOptions::ResetOptionValues ()
m_start_addr = LLDB_INVALID_ADDRESS;
m_end_addr = LLDB_INVALID_ADDRESS;
raw = false;
+ m_plugin_name.clear();
}
const OptionDefinition*
@@ -145,10 +151,11 @@ CommandObjectDisassemble::CommandOptions::GetDefinitions ()
OptionDefinition
CommandObjectDisassemble::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_ALL, false, "bytes", 'b', no_argument, NULL, 0, eArgTypeNone, "Show opcode bytes when disassembling."},
-{ LLDB_OPT_SET_ALL, false, "context", 'x', required_argument, NULL, 0, eArgTypeNumLines, "Number of context lines of source to show."},
-{ LLDB_OPT_SET_ALL, false, "mixed", 'm', no_argument, NULL, 0, eArgTypeNone, "Enable mixed source and assembly display."},
-{ LLDB_OPT_SET_ALL, false, "raw", 'r', no_argument, NULL, 0, eArgTypeNone, "Print raw disassembly with no symbol information."},
+{ LLDB_OPT_SET_ALL, false, "bytes", 'b', no_argument, NULL, 0, eArgTypeNone, "Show opcode bytes when disassembling."},
+{ LLDB_OPT_SET_ALL, false, "context", 'x', required_argument, NULL, 0, eArgTypeNumLines,"Number of context lines of source to show."},
+{ LLDB_OPT_SET_ALL, false, "mixed", 'm', no_argument, NULL, 0, eArgTypeNone, "Enable mixed source and assembly display."},
+{ LLDB_OPT_SET_ALL, false, "raw", 'r', no_argument, NULL, 0, eArgTypeNone, "Print raw disassembly with no symbol information."},
+{ LLDB_OPT_SET_ALL, false, "plugin", 'P', required_argument, NULL, 0, eArgTypePlugin, "Name of the disassembler plugin you want to use."},
{ LLDB_OPT_SET_1, true, "start-address", 's', required_argument, NULL, 0, eArgTypeStartAddress, "Address at which to start disassembling."},
{ LLDB_OPT_SET_1, false, "end-address", 'e', required_argument, NULL, 0, eArgTypeEndAddress, "Address at which to end disassembling."},
@@ -209,11 +216,18 @@ CommandObjectDisassemble::Execute
return false;
}
- Disassembler *disassembler = Disassembler::FindPlugin(arch);
+ const char *plugin_name = m_options.GetPluginName ();
+ Disassembler *disassembler = Disassembler::FindPlugin(arch, plugin_name);
if (disassembler == NULL)
{
- result.AppendErrorWithFormat ("Unable to find Disassembler plug-in for %s architecture.\n", arch.GetArchitectureName());
+ if (plugin_name)
+ result.AppendErrorWithFormat ("Unable to find Disassembler plug-in for %s architecture named '%s'.\n",
+ arch.GetArchitectureName(),
+ plugin_name);
+ else
+ result.AppendErrorWithFormat ("Unable to find Disassembler plug-in for %s architecture.\n",
+ arch.GetArchitectureName());
result.SetStatus (eReturnStatusFailed);
return false;
}
@@ -242,6 +256,7 @@ CommandObjectDisassemble::Execute
if (Disassembler::Disassemble (m_interpreter.GetDebugger(),
arch,
+ plugin_name,
exe_ctx,
name,
NULL, // Module *
@@ -323,6 +338,7 @@ CommandObjectDisassemble::Execute
if (Disassembler::Disassemble (m_interpreter.GetDebugger(),
arch,
+ plugin_name,
exe_ctx,
start_addr,
m_options.num_instructions,
@@ -372,6 +388,7 @@ CommandObjectDisassemble::Execute
if (Disassembler::Disassemble (m_interpreter.GetDebugger(),
arch,
+ plugin_name,
exe_ctx,
range,
m_options.num_instructions,
diff --git a/lldb/source/Commands/CommandObjectDisassemble.h b/lldb/source/Commands/CommandObjectDisassemble.h
index 4794ee5fd71..91812af3187 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.h
+++ b/lldb/source/Commands/CommandObjectDisassemble.h
@@ -44,6 +44,15 @@ public:
const OptionDefinition*
GetDefinitions ();
+ const char *
+ GetPluginName ()
+ {
+ if (m_plugin_name.empty())
+ return NULL;
+ return m_plugin_name.c_str();
+ }
+
+
bool show_mixed; // Show mixed source/assembly
bool show_bytes;
uint32_t num_lines_context;
@@ -53,6 +62,7 @@ public:
lldb::addr_t m_start_addr;
lldb::addr_t m_end_addr;
bool m_at_pc;
+ std::string m_plugin_name;
static OptionDefinition g_option_table[];
};
OpenPOWER on IntegriCloud