Add logging to Target::CreateWatchpointLocation() and fix some bug of using the wrong variable.
Plus simplify WatchpointLocation::Dump() output.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@139724 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Breakpoint/WatchpointLocation.cpp b/source/Breakpoint/WatchpointLocation.cpp
index 6e35418..3a78290 100644
--- a/source/Breakpoint/WatchpointLocation.cpp
+++ b/source/Breakpoint/WatchpointLocation.cpp
@@ -85,15 +85,13 @@
if (s == NULL)
return;
- s->Printf("WatchpointLocation %u: addr = 0x%8.8llx size = %zu state = %s type = %s watchpoint (%s%s) hw_index = %i hit_count = %-4u ignore_count = %-4u callback = %8p baton = %8p",
+ 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",
- IsHardware() ? "hardware" : "software",
m_watch_read ? "r" : "",
m_watch_write ? "w" : "",
- GetHardwareIndex(),
GetHitCount(),
GetIgnoreCount(),
m_callback,
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 11934e0..2c788f5 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -333,6 +333,11 @@
WatchpointLocationSP
Target::CreateWatchpointLocation(lldb::addr_t addr, size_t size, uint32_t type)
{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+ if (log)
+ log->Printf("Target::%s (addr = 0x%8.8llx size = %zu type = %u)\n",
+ __FUNCTION__, addr, size, type);
+
WatchpointLocationSP wp_loc_sp;
bool process_is_valid = m_process_sp && m_process_sp->IsAlive();
if (!process_is_valid)
@@ -348,10 +353,10 @@
WatchpointLocationSP matched_sp = m_watchpoint_location_list.FindByAddress(addr);
if (matched_sp)
{
- size_t old_size = wp_loc_sp->GetByteSize();
+ size_t old_size = matched_sp->GetByteSize();
uint32_t old_type =
- (wp_loc_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) |
- (wp_loc_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0);
+ (matched_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) |
+ (matched_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0);
// Return an empty watchpoint location if the same one exists already.
if (size == old_size && type == old_type)
return wp_loc_sp;
@@ -362,10 +367,22 @@
}
WatchpointLocation *new_loc = new WatchpointLocation(addr, size);
+ if (!new_loc)
+ printf("WatchpointLocation ctor failed, out of memory?\n");
+
new_loc->SetWatchpointType(type);
wp_loc_sp.reset(new_loc);
m_watchpoint_location_list.Add(wp_loc_sp);
- m_process_sp->EnableWatchpoint(wp_loc_sp.get());
+ Error rc = m_process_sp->EnableWatchpoint(wp_loc_sp.get());
+ if (rc.Success())
+ wp_loc_sp->SetEnabled(true);
+
+ if (log)
+ log->Printf("Target::%s (creation of watchpoint %s with id = %u)\n",
+ __FUNCTION__,
+ rc.Success() ? "succeeded" : "failed",
+ wp_loc_sp->GetID());
+
return wp_loc_sp;
}