Add a new 'info proc files' subcommand of 'info proc'.
[deliverable/binutils-gdb.git] / gdb / python / py-finishbreakpoint.c
index 7f30d86055108f642497a05959340333873e7207..c33b7dd7aa64a127d4f4aba5787f2b67a98784b3 100644 (file)
@@ -1,6 +1,6 @@
 /* Python interface to finish breakpoints
 
-   Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   Copyright (C) 2011-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "gdbthread.h"
 #include "arch-utils.h"
 #include "language.h"
-#include "observer.h"
+#include "observable.h"
 #include "inferior.h"
 #include "block.h"
 #include "location.h"
 #include "py-ref.h"
 
 /* Function that is called when a Python finish bp is found out of scope.  */
-static char * const outofscope_func = "out_of_scope";
+static const char outofscope_func[] = "out_of_scope";
 
 /* struct implementing the gdb.FinishBreakpoint object by extending
    the gdb.Breakpoint class.  */
@@ -156,7 +156,7 @@ bpfinishpy_post_stop_hook (struct gdbpy_breakpoint_object *bp_obj)
 static int
 bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
 {
-  static char *keywords[] = { "frame", "internal", NULL };
+  static const char *keywords[] = { "frame", "internal", NULL };
   struct finish_breakpoint_object *self_bpfinish =
       (struct finish_breakpoint_object *) self;
   PyObject *frame_obj = NULL;
@@ -169,8 +169,8 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
   CORE_ADDR pc;
   struct symbol *function;
 
-  if (!PyArg_ParseTupleAndKeywords (args, kwargs, "|OO", keywords,
-                                    &frame_obj, &internal))
+  if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "|OO", keywords,
+                                       &frame_obj, &internal))
     return -1;
 
   TRY
@@ -221,14 +221,15 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
   if (PyErr_Occurred ())
     return -1;
 
-  thread = ptid_to_global_thread_id (inferior_ptid);
-  if (thread == 0)
+  if (inferior_ptid == null_ptid)
     {
       PyErr_SetString (PyExc_ValueError,
                        _("No thread currently selected."));
       return -1;
     }
 
+  thread = inferior_thread ()->global_num;
+
   if (internal)
     {
       internal_bp = PyObject_IsTrue (internal);
@@ -293,14 +294,11 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
 
   TRY
     {
-      struct event_location *location;
-      struct cleanup *back_to;
-
       /* Set a breakpoint on the return address.  */
-      location = new_address_location (get_frame_pc (prev_frame), NULL, 0);
-      back_to = make_cleanup_delete_event_location (location);
+      event_location_up location
+       = new_address_location (get_frame_pc (prev_frame), NULL, 0);
       create_breakpoint (python_gdbarch,
-                         location, NULL, thread, NULL,
+                         location.get (), NULL, thread, NULL,
                          0,
                          1 /*temp_flag*/,
                          bp_breakpoint,
@@ -308,7 +306,6 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
                          AUTO_BOOLEAN_TRUE,
                          &bkpt_breakpoint_ops,
                          0, 1, internal_bp, 0);
-      do_cleanups (back_to);
     }
   CATCH (except, RETURN_MASK_ALL)
     {
@@ -338,8 +335,8 @@ bpfinishpy_out_of_scope (struct finish_breakpoint_object *bpfinish_obj)
   if (bpfinish_obj->py_bp.bp->enable_state == bp_enabled
       && PyObject_HasAttrString (py_obj, outofscope_func))
     {
-      gdbpy_ref meth_result (PyObject_CallMethod (py_obj, outofscope_func,
-                                                 NULL));
+      gdbpy_ref<> meth_result (PyObject_CallMethod (py_obj, outofscope_func,
+                                                   NULL));
       if (meth_result == NULL)
        gdbpy_print_stack ();
     }
@@ -420,13 +417,13 @@ gdbpy_initialize_finishbreakpoints (void)
                              (PyObject *) &finish_breakpoint_object_type) < 0)
     return -1;
 
-  observer_attach_normal_stop (bpfinishpy_handle_stop);
-  observer_attach_inferior_exit (bpfinishpy_handle_exit);
+  gdb::observers::normal_stop.attach (bpfinishpy_handle_stop);
+  gdb::observers::inferior_exit.attach (bpfinishpy_handle_exit);
 
   return 0;
 }
 
-static PyGetSetDef finish_breakpoint_object_getset[] = {
+static gdb_PyGetSetDef finish_breakpoint_object_getset[] = {
   { "return_value", bpfinishpy_get_returnvalue, NULL,
   "gdb.Value object representing the return value, if any. \
 None otherwise.", NULL },
This page took 0.025473 seconds and 4 git commands to generate.