Remove ptid_equal
[deliverable/binutils-gdb.git] / gdb / gdbserver / mem-break.c
index d836177165feac50b78801213dd64b86c864e2bb..447afc7c10cd66026d465409f7273b9c8e8415b2 100644 (file)
@@ -1,5 +1,5 @@
 /* Memory breakpoint operations for the remote server for GDB.
-   Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   Copyright (C) 2002-2018 Free Software Foundation, Inc.
 
    Contributed by MontaVista Software.
 
@@ -431,7 +431,6 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind,
 {
   struct process_info *proc = current_process ();
   struct raw_breakpoint *bp;
-  struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
 
   if (type == raw_bkpt_type_sw || type == raw_bkpt_type_hw)
     {
@@ -450,13 +449,14 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind,
   else
     bp = find_raw_breakpoint_at (where, type, kind);
 
+  gdb::unique_xmalloc_ptr<struct raw_breakpoint> bp_holder;
   if (bp == NULL)
     {
-      bp = XCNEW (struct raw_breakpoint);
+      bp_holder.reset (XCNEW (struct raw_breakpoint));
+      bp = bp_holder.get ();
       bp->pc = where;
       bp->kind = kind;
       bp->raw_type = type;
-      make_cleanup (xfree, bp);
     }
 
   if (!bp->inserted)
@@ -468,14 +468,15 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind,
            debug_printf ("Failed to insert breakpoint at 0x%s (%d).\n",
                          paddress (where), *err);
 
-         do_cleanups (old_chain);
          return NULL;
        }
 
       bp->inserted = 1;
     }
 
-  discard_cleanups (old_chain);
+  /* If the breakpoint was allocated above, we know we want to keep it
+     now.  */
+  bp_holder.release ();
 
   /* Link the breakpoint in, if this is the first reference.  */
   if (++bp->refcount == 1)
@@ -1481,7 +1482,7 @@ set_single_step_breakpoint (CORE_ADDR stop_at, ptid_t ptid)
 {
   struct single_step_breakpoint *bp;
 
-  gdb_assert (ptid_get_pid (current_ptid) == ptid_get_pid (ptid));
+  gdb_assert (current_ptid.pid () == ptid.pid ());
 
   bp = (struct single_step_breakpoint *) set_breakpoint_type_at (single_step_breakpoint,
                                                                stop_at, NULL);
@@ -1500,8 +1501,7 @@ delete_single_step_breakpoints (struct thread_info *thread)
   while (bp)
     {
       if (bp->type == single_step_breakpoint
-         && ptid_equal (((struct single_step_breakpoint *) bp)->ptid,
-                        ptid_of (thread)))
+         && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
        {
          struct thread_info *saved_thread = current_thread;
 
@@ -1597,8 +1597,7 @@ uninsert_single_step_breakpoints (struct thread_info *thread)
   for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
     {
     if (bp->type == single_step_breakpoint
-       && ptid_equal (((struct single_step_breakpoint *) bp)->ptid,
-                      ptid_of (thread)))
+       && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
       {
        gdb_assert (bp->raw->inserted > 0);
 
@@ -1672,8 +1671,7 @@ has_single_step_breakpoints (struct thread_info *thread)
   while (bp)
     {
       if (bp->type == single_step_breakpoint
-         && ptid_equal (((struct single_step_breakpoint *) bp)->ptid,
-                        ptid_of (thread)))
+         && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
        return 1;
       else
        {
@@ -1707,8 +1705,7 @@ reinsert_single_step_breakpoints (struct thread_info *thread)
   for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
     {
       if (bp->type == single_step_breakpoint
-         && ptid_equal (((struct single_step_breakpoint *) bp)->ptid,
-                        ptid_of (thread)))
+         && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
        {
          gdb_assert (bp->raw->inserted > 0);
 
This page took 0.025383 seconds and 4 git commands to generate.