[Lldb-commits] [lldb] r139560 - in /lldb/trunk: include/lldb/Breakpoint/WatchpointLocation.h include/lldb/Interpreter/OptionGroupWatchpoint.h include/lldb/Target/Target.h include/lldb/lldb-enumerations.h source/Breakpoint/WatchpointLocation.cpp source/Commands/CommandObjectFrame.cpp source/Interpreter/CommandObject.cpp source/Interpreter/OptionGroupWatchpoint.cpp source/Target/Target.cpp
Johnny Chen
johnny.chen at apple.com
Mon Sep 12 16:38:44 PDT 2011
Author: johnny
Date: Mon Sep 12 18:38:44 2011
New Revision: 139560
URL: http://llvm.org/viewvc/llvm-project?rev=139560&view=rev
Log:
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.
Modified:
lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h
lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/Breakpoint/WatchpointLocation.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Interpreter/CommandObject.cpp
lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp
lldb/trunk/source/Target/Target.cpp
Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h?rev=139560&r1=139559&r2=139560&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h Mon Sep 12 18:38:44 2011
@@ -46,6 +46,7 @@
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:
Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h?rev=139560&r1=139559&r2=139560&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h Mon Sep 12 18:38:44 2011
@@ -45,15 +45,18 @@
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);
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=139560&r1=139559&r2=139560&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Mon Sep 12 18:38:44 2011
@@ -280,6 +280,12 @@
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()
{
Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=139560&r1=139559&r2=139560&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Mon Sep 12 18:38:44 2011
@@ -408,7 +408,7 @@
eArgTypeWidth,
eArgTypeNone,
eArgTypePlatform,
- eArgTypeWatchMode,
+ eArgTypeWatchType,
eArgTypeLastArg // Always keep this entry as the last entry in this enumeration!!
} CommandArgumentType;
Modified: lldb/trunk/source/Breakpoint/WatchpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocation.cpp?rev=139560&r1=139559&r2=139560&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/WatchpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Mon Sep 12 18:38:44 2011
@@ -72,6 +72,13 @@
}
void
+WatchpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level)
+{
+ // FIXME: Add implmentation of GetDescription().
+ return;
+}
+
+void
WatchpointLocation::Dump(Stream *s) const
{
if (s == NULL)
Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=139560&r1=139559&r2=139560&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Sep 12 18:38:44 2011
@@ -493,7 +493,7 @@
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 @@
}
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
{
Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=139560&r1=139559&r2=139560&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObject.cpp Mon Sep 12 18:38:44 2011
@@ -830,7 +830,7 @@
{ 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*
Modified: lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp?rev=139560&r1=139559&r2=139560&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp Mon Sep 12 18:38:44 2011
@@ -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 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 @@
{
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 @@
OptionGroupWatchpoint::OptionParsingStarting (CommandInterpreter &interpreter)
{
watch_variable = false;
- watch_mode = eWatchInvalid;
+ watch_type = eWatchInvalid;
}
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=139560&r1=139559&r2=139560&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Mon Sep 12 18:38:44 2011
@@ -328,6 +328,15 @@
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)
{
More information about the lldb-commits
mailing list