[Lldb-commits] [lldb] r138929 - in /lldb/trunk/source/Commands: CommandObjectDisassemble.cpp CommandObjectDisassemble.h

Jim Ingham jingham at apple.com
Wed Aug 31 18:11:04 PDT 2011


Author: jingham
Date: Wed Aug 31 20:11:04 2011
New Revision: 138929

URL: http://llvm.org/viewvc/llvm-project?rev=138929&view=rev
Log:
disassemble with no arguments disassembles at the pc.  Also got "disassemble -f" to work, that had gotten broken at some point in the past.

Modified:
    lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
    lldb/trunk/source/Commands/CommandObjectDisassemble.h

Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=138929&r1=138928&r2=138929&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Wed Aug 31 20:11:04 2011
@@ -37,12 +37,14 @@
     num_lines_context(0),
     num_instructions (0),
     func_name(),
+    cur_function (false),
     start_addr(),
     end_addr (),
     at_pc (false),
     frame_line (false),
     plugin_name (),
-    arch() 
+    arch(),
+    some_location_specified (false) 
 {
     OptionParsingStarting();
 }
@@ -89,6 +91,7 @@
 
         if (start_addr == LLDB_INVALID_ADDRESS)
             error.SetErrorStringWithFormat ("Invalid start address string '%s'.\n", option_arg);
+        some_location_specified = true;
         break;
     case 'e':
         end_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
@@ -98,13 +101,15 @@
         if (end_addr == LLDB_INVALID_ADDRESS)
             error.SetErrorStringWithFormat ("Invalid end address string '%s'.\n", option_arg);
         break;
-
+        some_location_specified = true;
     case 'n':
         func_name.assign (option_arg);
+        some_location_specified = true;
         break;
 
     case 'p':
         at_pc = true;
+        some_location_specified = true;
         break;
 
     case 'l':
@@ -112,6 +117,7 @@
         // Disassemble the current source line kind of implies showing mixed
         // source code context. 
         show_mixed = true;
+        some_location_specified = true;
         break;
 
     case 'P':
@@ -123,8 +129,8 @@
         break;
 
     case 'f':
-        // The default action is to disassemble the function for the current frame.
-        // There's no need to set any flag.
+        cur_function = true;
+        some_location_specified = true;
         break;
 
     case 'a':
@@ -147,6 +153,7 @@
     num_lines_context = 0;
     num_instructions = 0;
     func_name.clear();
+    cur_function = false;
     at_pc = false;
     frame_line = false;
     start_addr = LLDB_INVALID_ADDRESS;
@@ -154,6 +161,16 @@
     raw = false;
     plugin_name.clear();
     arch.Clear();
+    some_location_specified = false;
+}
+
+Error
+CommandObjectDisassemble::CommandOptions::OptionParsingFinished ()
+{
+    if (!some_location_specified)
+        at_pc = true;
+    return Error();
+    
 }
 
 const OptionDefinition*
@@ -178,10 +195,10 @@
   LLDB_OPT_SET_3 |
   LLDB_OPT_SET_4 |
   LLDB_OPT_SET_5    , false , "count",          'c', required_argument  , NULL, 0, eArgTypeNumLines,    "Number of instructions to display."},
-{ LLDB_OPT_SET_3    , true  , "name",           'n', required_argument  , NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,             "Disassemble entire contents of the given function name."},
-{ LLDB_OPT_SET_4    , true  , "frame",          'f', no_argument        , NULL, 0, eArgTypeNone,        "Disassemble from the start of the current frame's function."},
-{ LLDB_OPT_SET_5    , true  , "pc",             'p', no_argument        , NULL, 0, eArgTypeNone,        "Disassemble around the current pc."},
-{ LLDB_OPT_SET_6    , true  , "line",           'l', no_argument        , NULL, 0, eArgTypeNone,        "Disassemble the current frame's current source line instructions if there debug line table information, else disasemble around the pc."},
+{ LLDB_OPT_SET_3    , false  , "name",           'n', required_argument  , NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,             "Disassemble entire contents of the given function name."},
+{ LLDB_OPT_SET_4    , false  , "frame",          'f', no_argument        , NULL, 0, eArgTypeNone,        "Disassemble from the start of the current frame's function."},
+{ LLDB_OPT_SET_5    , false  , "pc",             'p', no_argument        , NULL, 0, eArgTypeNone,        "Disassemble around the current pc."},
+{ LLDB_OPT_SET_6    , false  , "line",           'l', no_argument        , NULL, 0, eArgTypeNone,        "Disassemble the current frame's current source line instructions if there debug line table information, else disasemble around the pc."},
 { 0                 , false , NULL,             0,   0                  , NULL, 0, eArgTypeNone,        NULL }
 };
 
@@ -299,6 +316,12 @@
         AddressRange range;
         if (m_options.frame_line)
         {
+            if (exe_ctx.frame == NULL)
+            {
+                result.AppendError ("Cannot disassemble around the current line without a selected frame.\n");
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            }
             LineEntry pc_line_entry (exe_ctx.frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
             if (pc_line_entry.IsValid())
             {
@@ -310,6 +333,18 @@
                 m_options.show_mixed = false;
             }
         }
+        else if (m_options.cur_function)
+        {
+            if (exe_ctx.frame == NULL)
+            {
+                result.AppendError ("Cannot disassemble around the current function without a selected frame.\n");
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            }
+            Symbol *symbol = exe_ctx.frame->GetSymbolContext(eSymbolContextSymbol).symbol;
+            if (symbol)
+                range = symbol->GetAddressRangeRef();
+        }
 
         // Did the "m_options.frame_line" find a valid range already? If so
         // skip the rest...

Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.h?rev=138929&r1=138928&r2=138929&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectDisassemble.h (original)
+++ lldb/trunk/source/Commands/CommandObjectDisassemble.h Wed Aug 31 20:11:04 2011
@@ -52,6 +52,8 @@
             return plugin_name.c_str();
         }
         
+        virtual Error
+        OptionParsingFinished ();
 
         bool show_mixed; // Show mixed source/assembly
         bool show_bytes;
@@ -59,12 +61,15 @@
         uint32_t num_instructions;
         bool raw;
         std::string func_name;
+        bool cur_function;
         lldb::addr_t start_addr;
         lldb::addr_t end_addr;
         bool at_pc;
         bool frame_line;
         std::string plugin_name;
         ArchSpec arch;
+        bool some_location_specified; // If no location was specified, we'll select "at_pc".  This should be set
+                                      // in SetOptionValue if anything the selects a location is set.
         static OptionDefinition g_option_table[];
     };
 





More information about the lldb-commits mailing list