This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Python objfile-gdb.py file -- how to handle reloading properly ?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]