This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Python objfile-gdb.py file -- how to handle reloading properly ?
- From: Kevin Pouget <kevin dot pouget at gmail dot com>
- To: mark florisson <markflorisson88 at gmail dot com>, gdb at sourceware dot org
- Date: Tue, 22 Mar 2011 10:59:00 -0400
- Subject: Re: Python objfile-gdb.py file -- how to handle reloading properly ?
- References: <AANLkTinM7hqg9W5rYvgSEkvrsO96kJzsp-uRMuV8R2TY@mail.gmail.com> <AANLkTikZX2JvZF4bNYh8ZQR-e-bqLS=+zZq_m_b2Y+an@mail.gmail.com>
Thanks for your answer Mark
(I know I'm not very good at Python, I use it only since a few days :)
>> class my_list:
>> ? ?list = []
>>
>> ? ?def addToList(elt):
>> ? ? ? ?my_list.__class__.list.append(elt)
>
> That should read 'self.list.append(elt) (and you forgot the first
> parameter 'self' to 'addToList').
actually, it's rather
@staticmethod
def addToList(elt):
that I wanted to do, that is, access a *static* attribute
> Yes, it is quite terrible (also, don't use a bare 'except' clause). If
> you want your code to be autoloaded with your object file, have your
> script import your actual code instead (that can be installed using
> distutils). Modules are cached, so it will only be imported once.
what would you think about caching the already-loaded module list, and
allowing them to register a callback?
That's for instance what is done in `linux-thread-db.c` to detect the
loading of the libpthread.so, and that's pretty much what I would like
to do.
(I mean, if you guys feel like it's an interesting feature but no one
fancies doing it, I could give it a try)
> Although not related directly to your problem, I suggest reading
> docs.python.org/tut.
will do, thanks
Kevin