From: Aleksandar Ristovski <aristovski@qnx.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [patch] Do not add partial_symbol again and again to the list
Date: Tue, 06 May 2008 18:45:00 -0000 [thread overview]
Message-ID: <48209891.3000400@qnx.com> (raw)
In-Reply-To: <20080506141754.GA17275@caradoc.them.org>
Daniel Jacobowitz wrote:
> On Mon, May 05, 2008 at 02:58:53PM -0400, Aleksandar Ristovski wrote:
>>>> +const void *
>>>> +bcache (const void *addr, int length, struct bcache *bcache)
>>>> +{
>>>> + return bcache_data (addr, length, bcache);
>>>> +}
>>>> +
>>>> +void *
>>>> +bcache_added (const void *addr, int length, struct bcache *bcache,
>>>> + int *added)
>>> It should return a const pointer, like bcache. Also the indentation
>>> on the second line is too deep.
>> bcache_added is more like bcache_data which returns void*. It would make
>> sense to return void const* but then I would have to change const-ness in
>> many places (too many: I would leave that for some other patch).
>
> This really is not OK. Take a look at the explanation of a bcache:
>
> A bcache is a data structure for factoring out duplication in
> read-only structures.
Yes, but only while loading partial symbols; I am not aware it is being used after psymbols have been loaded.
>
> If you modify the pointed-to object then things go wrong: we put
> duplicates in the cache which is what it's supposed to avoid. And you
> modify the other copies which share the same bcache entry, corrupting
> them.
>
> If you don't want to fix the constification issues right now, then
> just call this deprecated_bcache_added and we can fix it later; you're
> not making it any worse. But this is something you have to understand
> about the bcache.
Understood and agreed. As you said, this patch does not make things any worse than what it is now.
>>
>> The attached is revised patch with the changes above; additionally, it
>> calls new add_partial_symbol_to_global_list for all partial symbols that
>> are being added to the global list.
I don't see how. Each reader treats psymbols in its own way (unless I am missing something here).
>
> This is not symbol-reader specific, right? There's nothing that makes
> it safe for DWARF2 but unsafe for stabs?
>
> If so, a smaller patch would be do just do this in add_psymbol_to_list
> if list == &objfile->global_symbols.
>
Yes it could be done that way, I thought what I proposed was 'cleaner'... but either way it would work.
I am not, however, happy with the patch completely - I think we can optimize it a bit more. Both struct partial_symbol and struct symbol are space critical and we should save everything we (reasonably) can.
My "feeling" is that we could use struct symbol for both, populate only the "partial_symbol" portion and then, as we load full symbols, "promote" the existing allocated structures to full symbols; some operations would not repeat (like name construction or fixup_[p]?symbol_section); initial memory allocation would be greater, but in the long run I would expect that gdb would use less memory than it does now. Savings I am hoping to see from such approach are: overall lower memory consumption, much lower number of memory alloc's, and saving some redundant operations we do for both psyms and syms.
Or, maybe, we could go step by step: commit this patch (providing you find it good enough) and then continue with more extensive changes?
Either way, let me know what you think.
Thanks,
Aleksandar
WARNING: multiple messages have this Message-ID
From: Aleksandar Ristovski <aristovski@qnx.com>
To: Aleksandar Ristovski <aristovski@qnx.com>, gdb-patches@sourceware.org
Subject: Re: [patch] Do not add partial_symbol again and again to the list
Date: Tue, 06 May 2008 18:39:00 -0000 [thread overview]
Message-ID: <48209891.3000400@qnx.com> (raw)
Message-ID: <20080506183900.Bksj-DJ8ZY7ZsYTWXTCnHavNvt9ic2dDel02usfEcOU@z> (raw)
In-Reply-To: <20080506141754.GA17275@caradoc.them.org>
Daniel Jacobowitz wrote:
> On Mon, May 05, 2008 at 02:58:53PM -0400, Aleksandar Ristovski wrote:
>>>> +const void *
>>>> +bcache (const void *addr, int length, struct bcache *bcache)
>>>> +{
>>>> + return bcache_data (addr, length, bcache);
>>>> +}
>>>> +
>>>> +void *
>>>> +bcache_added (const void *addr, int length, struct bcache *bcache,
>>>> + int *added)
>>> It should return a const pointer, like bcache. Also the indentation
>>> on the second line is too deep.
>> bcache_added is more like bcache_data which returns void*. It would make
>> sense to return void const* but then I would have to change const-ness in
>> many places (too many: I would leave that for some other patch).
>
> This really is not OK. Take a look at the explanation of a bcache:
>
> A bcache is a data structure for factoring out duplication in
> read-only structures.
Yes, but only while loading partial symbols; I am not aware it is being used after psymbols have been loaded.
>
> If you modify the pointed-to object then things go wrong: we put
> duplicates in the cache which is what it's supposed to avoid. And you
> modify the other copies which share the same bcache entry, corrupting
> them.
>
> If you don't want to fix the constification issues right now, then
> just call this deprecated_bcache_added and we can fix it later; you're
> not making it any worse. But this is something you have to understand
> about the bcache.
Understood and agreed. As you said, this patch does not make things any worse than what it is now.
>>
>> The attached is revised patch with the changes above; additionally, it
>> calls new add_partial_symbol_to_global_list for all partial symbols that
>> are being added to the global list.
I don't see how. Each reader treats psymbols in its own way (unless I am missing something here).
>
> This is not symbol-reader specific, right? There's nothing that makes
> it safe for DWARF2 but unsafe for stabs?
>
> If so, a smaller patch would be do just do this in add_psymbol_to_list
> if list == &objfile->global_symbols.
>
Yes it could be done that way, I thought what I proposed was 'cleaner'... but either way it would work.
I am not, however, happy with the patch completely - I think we can optimize it a bit more. Both struct partial_symbol and struct symbol are space critical and we should save everything we (reasonably) can.
My "feeling" is that we could use struct symbol for both, populate only the "partial_symbol" portion and then, as we load full symbols, "promote" the existing allocated structures to full symbols; some operations would not repeat (like name construction or fixup_[p]?symbol_section); initial memory allocation would be greater, but in the long run I would expect that gdb would use less memory than it does now. Savings I am hoping to see from such approach are: overall lower memory consumption, much lower number of memory alloc's, and saving some redundant operations we do for both psyms and syms.
Or, maybe, we could go step by step: commit this patch (providing you find it good enough) and then continue with more extensive changes?
Either way, let me know what you think.
Thanks,
Aleksandar
next prev parent reply other threads:[~2008-05-06 17:43 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-11 20:23 Aleksandar Ristovski
2008-02-11 20:38 ` Daniel Jacobowitz
2008-02-11 20:52 ` Aleksandar Ristovski
2008-02-11 21:09 ` Daniel Jacobowitz
2008-02-11 21:41 ` Aleksandar Ristovski
2008-02-11 21:48 ` Daniel Jacobowitz
2008-02-11 22:10 ` Aleksandar Ristovski
2008-02-11 22:31 ` Daniel Jacobowitz
2008-02-11 22:43 ` Aleksandar Ristovski
2008-02-11 22:53 ` Daniel Jacobowitz
2008-02-12 1:08 ` Aleksandar Ristovski
2008-02-12 2:12 ` Daniel Jacobowitz
2008-02-12 5:35 ` Aleksandar Ristovski
2008-02-12 13:26 ` Daniel Jacobowitz
2008-02-12 15:54 ` Aleksandar Ristovski
2008-02-13 5:23 ` Aleksandar Ristovski
2008-02-14 1:31 ` Aleksandar Ristovski
2008-05-02 18:11 ` Aleksandar Ristovski
2008-05-03 21:32 ` Daniel Jacobowitz
2008-05-05 19:41 ` Aleksandar Ristovski
2008-05-05 19:38 ` Aleksandar Ristovski
2008-05-06 15:47 ` Daniel Jacobowitz
2008-05-06 18:45 ` Aleksandar Ristovski [this message]
2008-05-06 18:39 ` Aleksandar Ristovski
2008-05-06 18:50 ` Daniel Jacobowitz
2008-05-07 8:22 ` Aleksandar Ristovski
2008-05-07 9:01 ` Aleksandar Ristovski
2008-06-05 18:17 ` Daniel Jacobowitz
2008-06-05 19:26 ` Aleksandar Ristovski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48209891.3000400@qnx.com \
--to=aristovski@qnx.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox