Use the "last created watchpoint" rather than asserting on watchpoint commands passing no watchpoint ID.

<rdar://problem/14327560> 

llvm-svn: 185406
This commit is contained in:
Jim Ingham 2013-07-02 02:09:46 +00:00
parent 92821745bf
commit b0b4513ea2
4 changed files with 29 additions and 12 deletions

View File

@ -88,10 +88,22 @@ WithRSAIndex(llvm::StringRef &Arg)
// Return true if wp_ids is successfully populated with the watch ids.
// False otherwise.
bool
CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(Args &args, std::vector<uint32_t> &wp_ids)
CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(Target *target, Args &args, std::vector<uint32_t> &wp_ids)
{
// Pre-condition: args.GetArgumentCount() > 0.
assert(args.GetArgumentCount() > 0);
if (args.GetArgumentCount() == 0)
{
if (target == NULL)
return false;
WatchpointSP watch_sp = target->GetLastCreatedWatchpoint();
if (watch_sp)
{
wp_ids.push_back(watch_sp->GetID());
return true;
}
else
return false;
}
llvm::StringRef Minus("-");
std::vector<llvm::StringRef> StrRefArgs;
@ -292,7 +304,7 @@ protected:
{
// Particular watchpoints selected; enable them.
std::vector<uint32_t> wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(command, wp_ids))
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
@ -392,7 +404,7 @@ protected:
{
// Particular watchpoints selected; enable them.
std::vector<uint32_t> wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(command, wp_ids))
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
@ -477,7 +489,7 @@ protected:
{
// Particular watchpoints selected; disable them.
std::vector<uint32_t> wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(command, wp_ids))
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
@ -560,7 +572,7 @@ protected:
{
// Particular watchpoints selected; delete them.
std::vector<uint32_t> wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(command, wp_ids))
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
@ -701,7 +713,7 @@ protected:
{
// Particular watchpoints selected; ignore them.
std::vector<uint32_t> wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(command, wp_ids))
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
@ -858,7 +870,7 @@ protected:
{
// Particular watchpoints selected; set condition on them.
std::vector<uint32_t> wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(command, wp_ids))
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);

View File

@ -34,7 +34,7 @@ public:
~CommandObjectMultiwordWatchpoint ();
static bool
VerifyWatchpointIDs(Args &args, std::vector<uint32_t> &wp_ids);
VerifyWatchpointIDs(Target *target, Args &args, std::vector<uint32_t> &wp_ids);
};

View File

@ -512,7 +512,7 @@ protected:
}
std::vector<uint32_t> valid_wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(command, valid_wp_ids))
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, valid_wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
@ -678,7 +678,7 @@ protected:
}
std::vector<uint32_t> valid_wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(command, valid_wp_ids))
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, valid_wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
@ -770,7 +770,7 @@ protected:
}
std::vector<uint32_t> valid_wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(command, valid_wp_ids))
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, valid_wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);

View File

@ -782,6 +782,7 @@ Target::RemoveAllWatchpoints (bool end_to_end)
return false;
}
m_watchpoint_list.RemoveAll (true);
m_last_created_watchpoint.reset();
return true; // Success!
}
@ -949,6 +950,10 @@ Target::RemoveWatchpointByID (lldb::watch_id_t watch_id)
if (log)
log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id);
WatchpointSP watch_to_remove_sp = m_watchpoint_list.FindByID(watch_id);
if (watch_to_remove_sp == m_last_created_watchpoint)
m_last_created_watchpoint.reset();
if (DisableWatchpointByID (watch_id))
{
m_watchpoint_list.Remove(watch_id, true);