diff options
author | Jim Ingham <jingham@apple.com> | 2013-01-09 03:27:33 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2013-01-09 03:27:33 +0000 |
commit | 196bbc25711745032ab3d73ab946162dee7ba7cb (patch) | |
tree | c5dc0d9f02a890bc78315f89930dac7b58bc0e76 /lldb/source/Commands/CommandObjectSource.cpp | |
parent | c52435b4a254af96128c19e473071ec30cfb51f2 (diff) | |
download | bcm5719-llvm-196bbc25711745032ab3d73ab946162dee7ba7cb.tar.gz bcm5719-llvm-196bbc25711745032ab3d73ab946162dee7ba7cb.zip |
Add a "--reverse" or "-r" option to the "list" with no options command. This will list backwards from the
last source point listed.
Also fix the setting of the default file & line to the file containing main, when you do a plain "list".
<rdar://problem/12685226>
llvm-svn: 171945
Diffstat (limited to 'lldb/source/Commands/CommandObjectSource.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectSource.cpp | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 03715a0ee4b..9915d705ce6 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -201,6 +201,9 @@ class CommandObjectSourceList : public CommandObjectParsed case 'b': show_bp_locs = true; break; + case 'r': + reverse = true; + break; default: error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option); break; @@ -219,6 +222,7 @@ class CommandObjectSourceList : public CommandObjectParsed start_line = 0; num_lines = 10; show_bp_locs = false; + reverse = false; modules.clear(); } @@ -238,6 +242,7 @@ class CommandObjectSourceList : public CommandObjectParsed uint32_t num_lines; STLStringArray modules; bool show_bp_locs; + bool reverse; }; public: @@ -248,18 +253,6 @@ public: NULL), m_options (interpreter) { - CommandArgumentEntry arg; - CommandArgumentData file_arg; - - // Define the first (and only) variant of this arg. - file_arg.arg_type = eArgTypeFilename; - file_arg.arg_repetition = eArgRepeatOptional; - - // There is only one variant this argument could be; put it into the argument entry. - arg.push_back (file_arg); - - // Push the data for the first argument into the m_arguments vector. - m_arguments.push_back (arg); } ~CommandObjectSourceList () @@ -276,7 +269,29 @@ public: virtual const char * GetRepeatCommand (Args ¤t_command_args, uint32_t index) { - return m_cmd_name.c_str(); + // This is kind of gross, but the command hasn't been parsed yet so we can't look at the option + // values for this invocation... I have to scan the arguments directly. + size_t num_args = current_command_args.GetArgumentCount(); + bool is_reverse = false; + for (size_t i = 0 ; i < num_args; i++) + { + const char *arg = current_command_args.GetArgumentAtIndex(i); + if (arg && (strcmp(arg, "-r") == 0 || strcmp(arg, "--reverse") == 0)) + { + is_reverse = true; + } + } + if (is_reverse) + { + if (m_reverse_name.empty()) + { + m_reverse_name = m_cmd_name; + m_reverse_name.append (" -r"); + } + return m_reverse_name.c_str(); + } + else + return m_cmd_name.c_str(); } protected: @@ -570,7 +585,8 @@ protected: if (m_options.start_line == 0) { if (target->GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream(), - GetBreakpointLocations ())) + GetBreakpointLocations (), + m_options.reverse)) { result.SetStatus (eReturnStatusSuccessFinishResult); } @@ -724,6 +740,7 @@ protected: } CommandOptions m_options; FileLineResolver m_breakpoint_locations; + std::string m_reverse_name; }; @@ -738,6 +755,7 @@ CommandObjectSourceList::CommandOptions::g_option_table[] = { LLDB_OPT_SET_1 , false, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, "The line number at which to start the display source."}, { LLDB_OPT_SET_2 , false, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeSymbol, "The name of a function whose source to display."}, { LLDB_OPT_SET_3 , false, "address",'a', required_argument, NULL, 0, eArgTypeAddress, "Lookup the address and display the source information for the corresponding file and line."}, +{ LLDB_OPT_SET_4, false, "reverse", 'r', no_argument, NULL, 0, eArgTypeNone, "Reverse the listing to look backwards from the last displayed block of source."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; |