This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Default value for option "python print-stack"
- From: Maxim Akhmedov <max42 at yandex-team dot com>
- To: gdb at sourceware dot org
- Date: Wed, 15 Feb 2017 03:03:34 +0300
- Subject: Default value for option "python print-stack"
- Authentication-results: sourceware.org; auth=none
- Authentication-results: mxbackcorp1h.mail.yandex.net; dkim=pass header.i=@yandex-team.com
- Envelope-from: max42 at yandex-team dot ru
Hi,
Currently the default value for an option "python print-stack" is "message"
that enables show only the messages of Python exceptions, but not their
tracebacks nor line numbers.
Though, usually the message of a Python error itself is pretty useless as it
doesn't point you where exactly the error happened. Like, suppose you have a
pretty-printer written in Python, and then you get the following output:
(gdb) yp lastKey
Python Exception <type 'exceptions.UnboundLocalError'> local variable
'value_data' referenced before assignment:
Error occurred in Python command: local variable 'value_data' referenced before
assignment
it doesn't really tell you anything, there may be lots of usages of a mentioned
variable, and due to the dynamic nature of Python you may easily mess somewhere
and it's particularly hard to find out the exact place by this message. Also,
the exception message is duplicated.
I see two options here.
First one is choosing "full" as a default value for this option. Is their any
rationale for not doing that? Python tracebacks are usually not that large to
intentionally suppress them.
Second one is appending the sourcefile:lineno to the message. Like:
"/path/to/source.py:123". I believe it should be possible to extract this
information from the traceback object you get after invoking the Python code.
>From my point of view, it's a good idea to implement both of this options.
--
Best wishes,
Maxim Akhmedov
max42@yandex-team.com