diff options
author | Johnny Chen <johnny.chen@apple.com> | 2011-09-12 23:38:44 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2011-09-12 23:38:44 +0000 |
commit | 887062aeb3f78734ddeac73b227e8d1dd40b1bf3 (patch) | |
tree | 56b8bc67a4f1608327fea9c75753af921b52fb0d | |
parent | 3337e396c8863af74d84bac60115d25692dcb581 (diff) | |
download | bcm5719-llvm-887062aeb3f78734ddeac73b227e8d1dd40b1bf3.tar.gz bcm5719-llvm-887062aeb3f78734ddeac73b227e8d1dd40b1bf3.zip |
Watchpoint WIP:
o Rename from OptionGroupWatchpoint::WatchMode to OptionGroupWatchpoint::WatchType,
and CommandArgumentType::eArgTypeWatchMode to CommandArgumentType::eArgTypeWatchType.
Update the sources to reflect the change.
o Add a CreateWatchpointLocation() method to Target class, which is currently not implmeneted
(returns an empty WatchpointLocationSP object). Add logic to CommandObjectFrame::Execute()
to exercise the added API for creating a watchpoint location.
llvm-svn: 139560
-rw-r--r-- | lldb/include/lldb/Breakpoint/WatchpointLocation.h | 1 | ||||
-rw-r--r-- | lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h | 11 | ||||
-rw-r--r-- | lldb/include/lldb/Target/Target.h | 6 | ||||
-rw-r--r-- | lldb/include/lldb/lldb-enumerations.h | 2 | ||||
-rw-r--r-- | lldb/source/Breakpoint/WatchpointLocation.cpp | 7 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectFrame.cpp | 28 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandObject.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionGroupWatchpoint.cpp | 8 | ||||
-rw-r--r-- | lldb/source/Target/Target.cpp | 9 |
9 files changed, 62 insertions, 12 deletions
diff --git a/lldb/include/lldb/Breakpoint/WatchpointLocation.h b/lldb/include/lldb/Breakpoint/WatchpointLocation.h index 77c0ba20bae..84a855898a9 100644 --- a/lldb/include/lldb/Breakpoint/WatchpointLocation.h +++ b/lldb/include/lldb/Breakpoint/WatchpointLocation.h @@ -46,6 +46,7 @@ public: void SetWatchpointType (uint32_t type); bool BreakpointWasHit (StoppointCallbackContext *context); bool SetCallback (WatchpointHitCallback callback, void *callback_baton); + void GetDescription (Stream *s, lldb::DescriptionLevel level); void Dump (Stream *s) const; private: diff --git a/lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h b/lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h index b3995537378..e9aba962a0e 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h +++ b/lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h @@ -45,15 +45,18 @@ namespace lldb_private { virtual void OptionParsingStarting (CommandInterpreter &interpreter); - typedef enum WatchMode { - eWatchInvalid, + // Note: + // eWatchRead == LLDB_WATCH_TYPE_EREAD; and + // eWatchWrite == LLDB_WATCH_TYPE_WRITE + typedef enum WatchType { + eWatchInvalid = 0, eWatchRead, eWatchWrite, eWatchReadWrite - } WatchMode; + } WatchType; bool watch_variable; - WatchMode watch_mode; + WatchType watch_type; private: DISALLOW_COPY_AND_ASSIGN(OptionGroupWatchpoint); diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index b63234f4c31..830d3a86d20 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -280,6 +280,12 @@ public: lldb::BreakpointResolverSP &resolver_sp, bool internal = false); + // Use this to create a watchpoint location: + lldb::WatchpointLocationSP + CreateWatchpointLocation (lldb::addr_t addr, + size_t size, + uint32_t type); + WatchpointLocationList & GetWatchpointLocationList() { diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 99522c9965a..a02da6b1581 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -408,7 +408,7 @@ namespace lldb { eArgTypeWidth, eArgTypeNone, eArgTypePlatform, - eArgTypeWatchMode, + eArgTypeWatchType, eArgTypeLastArg // Always keep this entry as the last entry in this enumeration!! } CommandArgumentType; diff --git a/lldb/source/Breakpoint/WatchpointLocation.cpp b/lldb/source/Breakpoint/WatchpointLocation.cpp index 3387e483605..937fc8fca00 100644 --- a/lldb/source/Breakpoint/WatchpointLocation.cpp +++ b/lldb/source/Breakpoint/WatchpointLocation.cpp @@ -72,6 +72,13 @@ WatchpointLocation::BreakpointWasHit (StoppointCallbackContext *context) } void +WatchpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level) +{ + // FIXME: Add implmentation of GetDescription(). + return; +} + +void WatchpointLocation::Dump(Stream *s) const { if (s == NULL) diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 235ecfd958f..a86156cb084 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -493,7 +493,7 @@ public: result.GetErrorStream().Printf ("error: unkown regex error when compiling '%s'\n", name_cstr); } } - else + else // No regex, either exact variable names or variable expressions. { Error error; uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember; @@ -514,10 +514,34 @@ public: } if (summary_format_sp) valobj_sp->SetCustomSummaryFormat(summary_format_sp); - ValueObject::DumpValueObject (result.GetOutputStream(), + + Stream &output_stream = result.GetOutputStream(); + ValueObject::DumpValueObject (output_stream, valobj_sp.get(), valobj_sp->GetParent() ? name_cstr : NULL, options); + // Process watchpoint if necessary. + if (m_option_watchpoint.watch_variable) + { + lldb::addr_t addr = LLDB_INVALID_ADDRESS; + size_t size = 0; + uint32_t watch_type = m_option_watchpoint.watch_type; + WatchpointLocation *wp_loc = + exe_ctx.target->CreateWatchpointLocation(addr, size, watch_type).get(); + if (wp_loc) + { + output_stream.Printf("Watchpoint created: "); + wp_loc->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); + output_stream.EOL(); + result.SetStatus(eReturnStatusSuccessFinishResult); + } + else + { + result.AppendErrorWithFormat("Watchpoint creation failed.\n"); + result.SetStatus(eReturnStatusFailed); + } + return (wp_loc != NULL); + } } else { diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index c3547e23995..afd00c520b7 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -830,7 +830,7 @@ CommandObject::g_arguments_data[] = { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, { eArgTypeNone, "none", CommandCompletions::eNoCompletion, { NULL, false }, "No help available for this." }, { eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, { NULL, false }, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." }, - { eArgTypeWatchMode, "watch-mode", CommandCompletions::eNoCompletion, { NULL, false }, "Specify the mode for a watchpoint." } + { eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { NULL, false }, "Specify the type for a watchpoint." } }; const CommandObject::ArgumentTableEntry* diff --git a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp index 4f9f2c19a6a..b0f381ef4b3 100644 --- a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp +++ b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp @@ -20,7 +20,7 @@ using namespace lldb; using namespace lldb_private; -static OptionEnumValueElement g_watch_mode[] = +static OptionEnumValueElement g_watch_type[] = { { OptionGroupWatchpoint::eWatchRead, "read", "Watch for read"}, { OptionGroupWatchpoint::eWatchWrite, "write", "Watch for write"}, @@ -32,7 +32,7 @@ static OptionEnumValueElement g_watch_mode[] = static OptionDefinition g_option_table[] = { - { LLDB_OPT_SET_1, false, "watch", 'w', required_argument, g_watch_mode, 0, eArgTypeWatchMode, "Determine how to watch a memory location (read, write, or read/write)."} + { LLDB_OPT_SET_1, false, "watch", 'w', required_argument, g_watch_type, 0, eArgTypeWatchType, "Determine how to watch a memory location (read, write, or read/write)."} }; @@ -56,7 +56,7 @@ OptionGroupWatchpoint::SetOptionValue (CommandInterpreter &interpreter, { case 'w': { OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; - watch_mode = (WatchMode) Args::StringToOptionEnum(option_arg, enum_values, 0, &watch_variable); + watch_type = (WatchType) Args::StringToOptionEnum(option_arg, enum_values, 0, &watch_variable); if (!watch_variable) error.SetErrorStringWithFormat("Invalid option arg for '-w': '%s'.\n", option_arg); break; @@ -73,7 +73,7 @@ void OptionGroupWatchpoint::OptionParsingStarting (CommandInterpreter &interpreter) { watch_variable = false; - watch_mode = eWatchInvalid; + watch_type = eWatchInvalid; } diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index a236d71bdc4..7dfe4558c8f 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -328,6 +328,15 @@ Target::CreateBreakpoint (SearchFilterSP &filter_sp, BreakpointResolverSP &resol return bp_sp; } +// See also WatchpointLocation::SetWatchpointType() and OptionGroupWatchpoint::WatchType. +WatchpointLocationSP +Target::CreateWatchpointLocation(lldb::addr_t addr, size_t size, uint32_t type) +{ + WatchpointLocationSP wp_loc_sp; + if (addr == LLDB_INVALID_ADDRESS || size == 0 || GetProcessSP()) + return wp_loc_sp; +} + void Target::RemoveAllBreakpoints (bool internal_also) { |