[lldb-dev] [PATCH] Fixing a crashing bug in multiword commands
wlynch at wlynch.cx
Tue Jul 20 13:44:18 PDT 2010
*Currently, this is the output from a LLDB session:*
[3:21pm][wlynch at orange bin] ./lldb
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid
*If the attached patch is applied, the following is the LLDB session:*
[3:25pm][wlynch at orange bin] ./lldb
The following subcommands are supported:
attach -- Attaches to a process.
continue -- Continues execution all threads in the current process.
detach -- Detaches from the current process being debugged.
interrupt -- Interrupts the current process being debugged.
kill -- Terminates the current process being debugged.
launch -- Launches the executable in the debugger.
signal -- Sends a UNIX signal to the current process being debugged.
status -- Shows the current status and location of executing process.
For more help on any particular subcommand, type 'help <command>
*Here's some notes on what's going on:*
So, "process" is a multiword command object. That is, it uses
CommandObjectMultiword to choose between a set of possible classes. In
CommandObjectMultiword, a map is created to search for the desired
subcommand. If null is searched for in that map, an uncaught exception is
thrown by the standard library. Basically, it calls std::string(NULL).
The fix for this is to make sure that when we look for the next subcommand,
to verify that one does in fact exist.
*And here's the patch:*
--- source/Commands/CommandObjectMultiword.cpp (revision 108841)
+++ source/Commands/CommandObjectMultiword.cpp (working copy)
@@ -290,13 +290,12 @@
const char *
CommandObjectMultiword::GetRepeatCommand (Args ¤t_command_args,
- if (current_command_args.GetArgumentCount() == 0)
- return NULL;
+ if (current_command_args.GetArgumentCount() <= index)
+ return NULL;
CommandObject *sub_command_object = GetSubcommandObject
if (sub_command_object == NULL)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the lldb-dev