[Lldb-commits] [lldb] r139946 - in /lldb/trunk: include/lldb/Breakpoint/WatchpointLocation.h include/lldb/Breakpoint/WatchpointLocationList.h source/Breakpoint/WatchpointLocation.cpp source/Breakpoint/WatchpointLocationList.cpp source/Commands/CommandObjectFrame.cpp test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py test/functionalities/watchpoint/hello_watchpoint/main.c
Johnny Chen
johnny.chen at apple.com
Fri Sep 16 14:41:42 PDT 2011
Author: johnny
Date: Fri Sep 16 16:41:42 2011
New Revision: 139946
URL: http://llvm.org/viewvc/llvm-project?rev=139946&view=rev
Log:
Add a declaraion info member field to the WatchpointLocation class.
Modify CommandObjectFrame.cpp to populate this field when creating a watchpoint location.
Update the test case to verify that the declaration info matches the file and line number.
Modified:
lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h
lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h
lldb/trunk/source/Breakpoint/WatchpointLocation.cpp
lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py
lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/main.c
Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h?rev=139946&r1=139945&r2=139946&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h Fri Sep 16 16:41:42 2011
@@ -14,6 +14,7 @@
// C++ Includes
#include <list>
+#include <string>
// Other libraries and framework includes
@@ -46,8 +47,10 @@
void SetWatchpointType (uint32_t type);
bool BreakpointWasHit (StoppointCallbackContext *context);
bool SetCallback (WatchpointHitCallback callback, void *callback_baton);
+ void SetDeclInfo (std::string &str);
void GetDescription (Stream *s, lldb::DescriptionLevel level);
void Dump (Stream *s) const;
+ void DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const;
private:
bool m_enabled; // Is this breakpoint enabled
@@ -58,6 +61,7 @@
uint32_t m_ignore_count; // Number of times to ignore this breakpoint
WatchpointHitCallback m_callback;
void * m_callback_baton; // Callback user data to pass to callback
+ std::string m_decl_str; // Declaration information, if any.
static lldb::break_id_t
GetNextID();
Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h?rev=139946&r1=139945&r2=139946&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h Fri Sep 16 16:41:42 2011
@@ -67,6 +67,12 @@
Dump (Stream *s) const;
//------------------------------------------------------------------
+ /// Dump with lldb::DescriptionLevel.
+ //------------------------------------------------------------------
+ void
+ DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const;
+
+ //------------------------------------------------------------------
/// Returns a shared pointer to the watchpoint location at address
/// \a addr - const version.
///
Modified: lldb/trunk/source/Breakpoint/WatchpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocation.cpp?rev=139946&r1=139945&r2=139946&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/WatchpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Fri Sep 16 16:41:42 2011
@@ -50,6 +50,13 @@
return true;
}
+void
+WatchpointLocation::SetDeclInfo (std::string &str)
+{
+ m_decl_str = str;
+ return;
+}
+
// RETURNS - true if we should stop at this breakpoint, false if we
// should continue.
@@ -75,27 +82,42 @@
WatchpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level)
{
s->Printf(" ");
- Dump(s);
+ DumpWithLevel(s, level);
return;
}
void
WatchpointLocation::Dump(Stream *s) const
{
+ DumpWithLevel(s, lldb::eDescriptionLevelBrief);
+}
+
+void
+WatchpointLocation::DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const
+{
if (s == NULL)
return;
- s->Printf("WatchpointLocation %u: addr = 0x%8.8llx size = %zu state = %s type = %s%s hit_count = %-4u ignore_count = %-4u callback = %8p baton = %8p",
- GetID(),
- (uint64_t)m_addr,
- m_byte_size,
- m_enabled ? "enabled " : "disabled",
- m_watch_read ? "r" : "",
- m_watch_write ? "w" : "",
- GetHitCount(),
- GetIgnoreCount(),
- m_callback,
- m_callback_baton);
+ assert(description_level >= lldb::eDescriptionLevelBrief &&
+ description_level <= lldb::eDescriptionLevelVerbose);
+
+ s->Printf("WatchpointLocation %u: addr = 0x%8.8llx size = %zu state = %s type = %s%s",
+ GetID(),
+ (uint64_t)m_addr,
+ m_byte_size,
+ m_enabled ? "enabled" : "disabled",
+ m_watch_read ? "r" : "",
+ m_watch_write ? "w" : "");
+
+ if (description_level >= lldb::eDescriptionLevelFull)
+ s->Printf("\n declare @ '%s'", m_decl_str.c_str());
+
+ if (description_level >= lldb::eDescriptionLevelVerbose)
+ s->Printf("\n hit_count = %-4u ignore_count = %-4u callback = %8p baton = %8p",
+ GetHitCount(),
+ GetIgnoreCount(),
+ m_callback,
+ m_callback_baton);
}
bool
Modified: lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp?rev=139946&r1=139945&r2=139946&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp (original)
+++ lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp Fri Sep 16 16:41:42 2011
@@ -54,6 +54,12 @@
void
WatchpointLocationList::Dump (Stream *s) const
{
+ DumpWithLevel(s, lldb::eDescriptionLevelBrief);
+}
+
+void
+WatchpointLocationList::DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const
+{
Mutex::Locker locker (m_mutex);
s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
//s->Indent();
@@ -62,7 +68,7 @@
s->IndentMore();
addr_map::const_iterator pos, end = m_address_to_location.end();
for (pos = m_address_to_location.begin(); pos != end; ++pos)
- pos->second->Dump(s);
+ pos->second->DumpWithLevel(s, description_level);
s->IndentLess();
}
Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=139946&r1=139945&r2=139946&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Sep 16 16:41:42 2011
@@ -11,12 +11,14 @@
// C Includes
// C++ Includes
+#include <string>
// Other libraries and framework includes
// Project includes
#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
@@ -535,8 +537,15 @@
exe_ctx.target->CreateWatchpointLocation(addr, size, watch_type).get();
if (wp_loc)
{
+ if (var_sp && var_sp->GetDeclaration().GetFile())
+ {
+ StreamString ss;
+ var_sp->GetDeclaration().DumpStopContext(&ss, true);
+ wp_loc->SetDeclInfo(ss.GetString());
+ }
+ StreamString ss;
output_stream.Printf("Watchpoint created: ");
- wp_loc->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
+ wp_loc->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
output_stream.EOL();
result.SetStatus(eReturnStatusSuccessFinishResult);
}
Modified: lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py?rev=139946&r1=139945&r2=139946&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py (original)
+++ lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py Fri Sep 16 16:41:42 2011
@@ -31,6 +31,8 @@
self.source = 'main.c'
# Find the line number to break inside main().
self.line = line_number(self.source, '// Set break point at this line.')
+ # And the watchpoint variable declaration line number.
+ self.decl = line_number(self.source, '// Watchpoint variable declaration.')
# Build dictionary to have unique executable names for each test method.
self.exe_name = self.testMethodName
self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}
@@ -57,7 +59,8 @@
# Now let's set a write-type watchpoint for 'global'.
# There should be only one watchpoint hit (see main.c).
self.expect("frame variable -w write -g -L global", WATCHPOINT_CREATED,
- substrs = ['Watchpoint created', 'size = 4', 'type = w'])
+ substrs = ['Watchpoint created', 'size = 4', 'type = w',
+ '%s:%d' % (self.source, self.decl)])
self.runCmd("process continue")
Modified: lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/main.c?rev=139946&r1=139945&r2=139946&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/main.c (original)
+++ lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/main.c Fri Sep 16 16:41:42 2011
@@ -9,7 +9,7 @@
#include <stdio.h>
#include <stdint.h>
-int32_t global = 10;
+int32_t global = 10; // Watchpoint variable declaration.
int main(int argc, char** argv) {
int local = 0;
More information about the lldb-commits
mailing list