Add a new 'info proc files' subcommand of 'info proc'.
[deliverable/binutils-gdb.git] / gdb / python / py-breakpoint.c
index f865317ab3350a6c4496093118790c1d37df60a3..e1db674647a394efefd819f171aa8794d9f49ac0 100644 (file)
@@ -1,6 +1,6 @@
 /* Python interface to breakpoints
 
-   Copyright (C) 2008-2017 Free Software Foundation, Inc.
+   Copyright (C) 2008-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -25,7 +25,7 @@
 #include "breakpoint.h"
 #include "gdbcmd.h"
 #include "gdbthread.h"
-#include "observer.h"
+#include "observable.h"
 #include "cli/cli-script.h"
 #include "ada-lang.h"
 #include "arch-utils.h"
@@ -510,6 +510,48 @@ bppy_get_commands (PyObject *self, void *closure)
   return host_string_to_python_string (stb.c_str ());
 }
 
+/* Set the commands attached to a breakpoint.  Returns 0 on success.
+   Returns -1 on error, with a python exception set.  */
+static int
+bppy_set_commands (PyObject *self, PyObject *newvalue, void *closure)
+{
+  gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
+  struct gdb_exception except = exception_none;
+
+  BPPY_SET_REQUIRE_VALID (self_bp);
+
+  gdb::unique_xmalloc_ptr<char> commands
+    (python_string_to_host_string (newvalue));
+  if (commands == nullptr)
+    return -1;
+
+  TRY
+    {
+      bool first = true;
+      char *save_ptr = nullptr;
+      auto reader
+       = [&] ()
+         {
+           const char *result = strtok_r (first ? commands.get () : nullptr,
+                                          "\n", &save_ptr);
+           first = false;
+           return result;
+         };
+
+      counted_command_line lines = read_command_lines_1 (reader, 1, nullptr);
+      breakpoint_set_commands (self_bp->bp, std::move (lines));
+    }
+  CATCH (ex, RETURN_MASK_ALL)
+    {
+      except = ex;
+    }
+  END_CATCH
+
+  GDB_PY_SET_HANDLE_EXCEPTION (except);
+
+  return 0;
+}
+
 /* Python function to get the breakpoint type.  */
 static PyObject *
 bppy_get_type (PyObject *self, void *closure)
@@ -694,7 +736,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
 {
   static const char *keywords[] = { "spec", "type", "wp_class", "internal",
                                    "temporary","source", "function",
-                                   "label", "line", NULL };
+                                   "label", "line", "qualified", NULL };
   const char *spec = NULL;
   enum bptype type = bp_breakpoint;
   int access_type = hw_write;
@@ -707,12 +749,14 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
   char *label = NULL;
   char *source = NULL;
   char *function = NULL;
+  PyObject * qualified = NULL;
 
-  if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "|siiOOsssO", keywords,
+  if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "|siiOOsssOO", keywords,
                                        &spec, &type, &access_type,
                                        &internal,
                                        &temporary, &source,
-                                       &function, &label, &lineobj))
+                                       &function, &label, &lineobj,
+                                       &qualified))
     return -1;
 
 
@@ -759,6 +803,10 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
        case bp_breakpoint:
          {
            event_location_up location;
+           symbol_name_match_type func_name_match_type
+             = (qualified != NULL && PyObject_IsTrue (qualified)
+                 ? symbol_name_match_type::FULL
+                 : symbol_name_match_type::WILD);
 
            if (spec != NULL)
              {
@@ -767,7 +815,8 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
                const char *copy = copy_holder.get ();
 
                location  = string_to_event_location (&copy,
-                                                     current_language);
+                                                     current_language,
+                                                     func_name_match_type);
              }
            else
              {
@@ -782,6 +831,8 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
                  explicit_loc.line_offset =
                    linespec_parse_line_offset (line.get ());
 
+               explicit_loc.func_name_match_type = func_name_match_type;
+
                location = new_explicit_location (&explicit_loc);
              }
 
@@ -1077,9 +1128,9 @@ gdbpy_initialize_breakpoints (void)
                              (PyObject *) &breakpoint_object_type) < 0)
     return -1;
 
-  observer_attach_breakpoint_created (gdbpy_breakpoint_created);
-  observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted);
-  observer_attach_breakpoint_modified (gdbpy_breakpoint_modified);
+  gdb::observers::breakpoint_created.attach (gdbpy_breakpoint_created);
+  gdb::observers::breakpoint_deleted.attach (gdbpy_breakpoint_deleted);
+  gdb::observers::breakpoint_modified.attach (gdbpy_breakpoint_modified);
 
   /* Add breakpoint types constants.  */
   for (i = 0; pybp_codes[i].name; ++i)
@@ -1176,7 +1227,7 @@ when setting this property.", NULL },
   { "condition", bppy_get_condition, bppy_set_condition,
     "Condition of the breakpoint, as specified by the user,\
 or None if no condition set."},
-  { "commands", bppy_get_commands, NULL,
+  { "commands", bppy_get_commands, bppy_set_commands,
     "Commands of the breakpoint, as specified by the user."},
   { "type", bppy_get_type, NULL,
     "Type of breakpoint."},
This page took 0.028179 seconds and 4 git commands to generate.