This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Python objfile-gdb.py file -- how to handle reloading properly ?
- From: Kevin Pouget <kevin dot pouget at gmail dot com>
- To: gdb at sourceware dot org
- Date: Tue, 22 Mar 2011 10:07:07 -0400
- Subject: Python objfile-gdb.py file -- how to handle reloading properly ?
Hello,
I'm playing with the objfile-gdb.py loading, and I can't manage to
support the reloading efficiently:
class my_list:
list = []
def addToList(elt):
my_list.__class__.list.append(elt)
I would need this `list` attribute to keep its value across the
multiple `start` of my application, but it doesn't work this way, and
the only solution I found was:
try:
if a is None:
print "(exception thrown)"
print "second time"
except:
print "firs timet"
# The list of replay breakpoints
replay_breakpoints = []
a = 1
class my_list:
global list
def addToList(elt):
list.append(elt)
which looks like a ugly hack! Did you find any better solution? ("gdb
does not track which files it has already auto-loaded this way. gdb
will load the associated script every time the corresponding objfile
is opened. So your -gdb.py file should be careful to avoid errors if
it is evaluated more than once.")
Cordially,
Kevin