#include "interps.h"
#include "event-top.h"
#include "py-ref.h"
+#include "py-event.h"
/* True if Python has been successfully initialized, false
otherwise. */
/* Because we have a string for a filename, and are using Python to
open the file, we need to expand any tilde in the path first. */
gdb::unique_xmalloc_ptr<char> full_path (tilde_expand (filename));
- gdbpy_ref<> python_file (PyFile_FromString (full_path.get (), "r"));
+ gdbpy_ref<> python_file (PyFile_FromString (full_path.get (), (char *) "r"));
if (python_file == NULL)
{
gdbpy_print_stack ();
}
else
{
- struct command_line *l = get_command_line (python_control, "");
- struct cleanup *cleanup = make_cleanup_free_command_lines (&l);
+ command_line_up l = get_command_line (python_control, "");
- execute_control_command_untraced (l);
- do_cleanups (cleanup);
+ execute_control_command_untraced (l.get ());
}
}
case var_filename:
case var_enum:
{
- char *str = * (char **) var;
+ const char *str = *(char **) var;
if (! str)
str = "";
const char *arg;
PyObject *from_tty_obj = NULL, *to_string_obj = NULL;
int from_tty, to_string;
- static char *keywords[] = {"command", "from_tty", "to_string", NULL };
+ static const char *keywords[] = { "command", "from_tty", "to_string", NULL };
- if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!", keywords, &arg,
- &PyBool_Type, &from_tty_obj,
- &PyBool_Type, &to_string_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!", keywords, &arg,
+ &PyBool_Type, &from_tty_obj,
+ &PyBool_Type, &to_string_obj))
return NULL;
from_tty = 0;
struct cleanup *cleanups;
gdbpy_ref<> result;
gdbpy_ref<> unparsed;
- struct event_location *location = NULL;
+ event_location_up location;
if (! PyArg_ParseTuple (args, "|s", &arg))
return NULL;
sals.sals = NULL;
if (arg != NULL)
- {
- location = string_to_event_location_basic (&arg, python_language);
- make_cleanup_delete_event_location (location);
- }
+ location = string_to_event_location_basic (&arg, python_language);
TRY
{
if (location != NULL)
- sals = decode_line_1 (location, 0, NULL, NULL, 0);
+ sals = decode_line_1 (location.get (), 0, NULL, NULL, 0);
else
{
set_default_source_symtab_and_line ();
gdbpy_enter enter_py (get_current_arch (), current_language);
+ if (!evregpy_no_listeners_p (gdb_py_events.before_prompt)
+ && evpy_emit_event (NULL, gdb_py_events.before_prompt) < 0)
+ return EXT_LANG_RC_ERROR;
+
if (gdb_python_module
&& PyObject_HasAttrString (gdb_python_module, "prompt_hook"))
{
gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
{
const char *arg;
- static char *keywords[] = {"text", "stream", NULL };
+ static const char *keywords[] = { "text", "stream", NULL };
int stream_type = 0;
- if (! PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &arg,
- &stream_type))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &arg,
+ &stream_type))
return NULL;
TRY
static PyObject *
gdbpy_flush (PyObject *self, PyObject *args, PyObject *kw)
{
- static char *keywords[] = {"stream", NULL };
+ static const char *keywords[] = { "stream", NULL };
int stream_type = 0;
- if (! PyArg_ParseTupleAndKeywords (args, kw, "|i", keywords,
- &stream_type))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "|i", keywords,
+ &stream_type))
return NULL;
switch (stream_type)
error (_("Python scripting is not supported in this copy of GDB."));
else
{
- struct command_line *l = get_command_line (python_control, "");
- struct cleanup *cleanups = make_cleanup_free_command_lines (&l);
+ command_line_up l = get_command_line (python_control, "");
- execute_control_command_untraced (l);
- do_cleanups (cleanups);
+ execute_control_command_untraced (l.get ());
}
}
/foo/bin/python
/foo/lib/pythonX.Y/...
This must be done before calling Py_Initialize. */
- progname = concat (ldirname (python_libdir), SLASH_STRING, "bin",
+ progname = concat (ldirname (python_libdir).c_str (), SLASH_STRING, "bin",
SLASH_STRING, "python", (char *) NULL);
#ifdef IS_PY3K
oldloc = xstrdup (setlocale (LC_ALL, NULL));
|| gdbpy_initialize_values () < 0
|| gdbpy_initialize_frames () < 0
|| gdbpy_initialize_commands () < 0
+ || gdbpy_initialize_record () < 0
+ || gdbpy_initialize_btrace () < 0
|| gdbpy_initialize_symbols () < 0
|| gdbpy_initialize_symtabs () < 0
|| gdbpy_initialize_blocks () < 0
"stop_reason_string (Integer) -> String.\n\
Return a string explaining unwind stop reason." },
+ { "start_recording", gdbpy_start_recording, METH_VARARGS,
+ "start_recording ([method] [, format]) -> gdb.Record.\n\
+Start recording with the given method. If no method is given, will fall back\n\
+to the system default method. If no format is given, will fall back to the\n\
+default format for the given method."},
+ { "current_recording", gdbpy_current_recording, METH_NOARGS,
+ "current_recording () -> gdb.Record.\n\
+Return current recording object." },
+ { "stop_recording", gdbpy_stop_recording, METH_NOARGS,
+ "stop_recording () -> None.\n\
+Stop current recording." },
+
{ "lookup_type", (PyCFunction) gdbpy_lookup_type,
METH_VARARGS | METH_KEYWORDS,
"lookup_type (name [, block]) -> type\n\