Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:tabraham1:branches:home:jeff_mahoney:crash-python:devel
gdb
0014-gdb-python-add-gdb.NotAvailableError-excep...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0014-gdb-python-add-gdb.NotAvailableError-exception.patch of Package gdb
From 6fbdcb6cefa4aebe4e1ee4f57a36835904834919 Mon Sep 17 00:00:00 2001 From: Jeff Mahoney <jeffm@suse.com> Date: Wed, 15 May 2019 18:14:34 -0400 Subject: [PATCH 14/17] gdb-python: add gdb.NotAvailableError exception Internally, gdb differentiates between exceptions but those differentiations are lost when crossing into Python code. Client code can make use of the knowledge that a value is unavailable. Signed-off-by: Jeff Mahoney <jeffm@suse.com> --- gdb/doc/python.texi | 4 ++++ gdb/python/py-utils.c | 2 ++ gdb/python/python-internal.h | 1 + gdb/python/python.c | 10 ++++++++++ 4 files changed, 17 insertions(+) diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index 8d502905d27..0ce1948d12e 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -656,6 +656,10 @@ operation tried to access invalid memory in the inferior. @item KeyboardInterrupt User interrupt (via @kbd{C-c} or by typing @kbd{q} at a pagination prompt) is translated to a Python @code{KeyboardInterrupt} exception. + +@item gdb.NotAvailableError +This is a subclass of @code{gdb.error} which is thrown when the contents +of a value are not available. @end ftable In all cases, your exception handler will see the @value{GDBN} error diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index 838853c896c..d8f6de739f4 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -239,6 +239,8 @@ gdbpy_convert_exception (const struct gdb_exception &exception) exc_class = PyExc_KeyboardInterrupt; else if (exception.error == MEMORY_ERROR) exc_class = gdbpy_gdb_memory_error; + else if (exception.error == NOT_AVAILABLE_ERROR) + exc_class = gdbpy_gdb_not_available_error; else exc_class = gdbpy_gdb_error; diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index f15dc9386ce..9faf6a5ff01 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -816,6 +816,7 @@ extern PyObject *gdbpy_value_cst; extern PyObject *gdbpy_gdb_error; extern PyObject *gdbpy_gdb_memory_error; extern PyObject *gdbpy_gdberror_exc; +extern PyObject *gdbpy_gdb_not_available_error; extern void gdbpy_convert_exception (const struct gdb_exception &) CPYCHECKER_SETS_EXCEPTION; diff --git a/gdb/python/python.c b/gdb/python/python.c index c17502406d0..a718dc776c4 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -101,6 +101,9 @@ PyObject *gdbpy_gdb_error; /* The `gdb.MemoryError' exception. */ PyObject *gdbpy_gdb_memory_error; +/* The `gdb.NotAvailableError' exception. */ +PyObject *gdbpy_gdb_not_available_error; + static script_sourcer_func gdbpy_source_script; static objfile_script_sourcer_func gdbpy_source_objfile_script; static objfile_script_executor_func gdbpy_execute_objfile_script; @@ -1947,6 +1950,13 @@ do_start_initialization () gdbpy_gdb_memory_error) < 0) return false; + gdbpy_gdb_not_available_error = PyErr_NewException ("gdb.NotAvailableError", + gdbpy_gdb_error, NULL); + if (gdbpy_gdb_not_available_error == NULL + || gdb_pymodule_addobject (gdb_module, "NotAvailableError", + gdbpy_gdb_not_available_error) < 0) + return false; + gdbpy_gdberror_exc = PyErr_NewException ("gdb.GdbError", NULL, NULL); if (gdbpy_gdberror_exc == NULL || gdb_pymodule_addobject (gdb_module, "GdbError", -- 2.37.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor