mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-24 02:37:23 +08:00
Add python gdb.GdbError and gdb.string_to_argv.
* NEWS: Document them. * python/py-cmd.c (cmdpy_function): Don't print a traceback if the exception is gdb.GdbError. Print a second traceback if there's an error computing the error message. (gdbpy_string_to_argv): New function. * python/py-utils.c (gdbpy_obj_to_string): New function. (gdbpy_exception_to_string): New function. * python/python-internal.h (gdbpy_string_to_argv): Declare. (gdbpy_obj_to_string, gdbpy_exception_to_string): Declare. (gdbpy_gdberror_exc): Declare. * python/python.c (gdbpy_gdberror_exc): New global. (_initialize_python): Initialize gdbpy_gdberror_exc and create gdb.GdbError. (GdbMethods): Add string_to_argv. doc/ * gdb.texinfo (Exception Handling): Document gdb.GdbError. (Commands In Python): Document gdb.string_to_argv. testsuite/ * gdb.python/py-cmd.exp: Add tests for gdb.GdbError and gdb.string_to_argv.
This commit is contained in:
@ -57,6 +57,8 @@ PyObject *gdbpy_children_cst;
|
||||
PyObject *gdbpy_display_hint_cst;
|
||||
PyObject *gdbpy_doc_cst;
|
||||
|
||||
/* The GdbError exception. */
|
||||
PyObject *gdbpy_gdberror_exc;
|
||||
|
||||
/* Architecture and language to be used in callbacks from
|
||||
the Python interpreter. */
|
||||
@ -655,6 +657,9 @@ Enables or disables printing of Python stack traces."),
|
||||
PyModule_AddStringConstant (gdb_module, "HOST_CONFIG", (char*) host_name);
|
||||
PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG", (char*) target_name);
|
||||
|
||||
gdbpy_gdberror_exc = PyErr_NewException ("gdb.GdbError", NULL, NULL);
|
||||
PyModule_AddObject (gdb_module, "GdbError", gdbpy_gdberror_exc);
|
||||
|
||||
gdbpy_initialize_auto_load ();
|
||||
gdbpy_initialize_values ();
|
||||
gdbpy_initialize_frames ();
|
||||
@ -771,6 +776,12 @@ Return the name of the current target charset." },
|
||||
"target_wide_charset () -> string.\n\
|
||||
Return the name of the current target wide charset." },
|
||||
|
||||
{ "string_to_argv", gdbpy_string_to_argv, METH_VARARGS,
|
||||
"string_to_argv (String) -> Array.\n\
|
||||
Parse String and return an argv-like array.\n\
|
||||
Arguments are separate by spaces and may be quoted."
|
||||
},
|
||||
|
||||
{ "write", gdbpy_write, METH_VARARGS,
|
||||
"Write a string using gdb's filtered stream." },
|
||||
{ "flush", gdbpy_flush, METH_NOARGS,
|
||||
|
Reference in New Issue
Block a user