public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Multiple inferiors and memory consumption
@ 2012-07-09 20:31 Vladimir Prus
  2012-07-10  2:29 ` Tom Tromey
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Vladimir Prus @ 2012-07-09 20:31 UTC (permalink / raw)
  To: gdb


It could be me, but I always expected that using GDB multi-process functionality should be better than
separate GDB instances -- including memory consumption. So, I've just tried to run CVS gdb on itself
inside 4 inferiors, and it looks like each inferior, the amount of data used by GDB (the DATA column
in top) grows pretty much linearly. That is, it does not seem like GDB notices that symbol tables of
all 4 loaded executables are identical (There's a link to the chart: http://goo.gl/0auVf)

Is this something that is going to be improved upon in future?

And now for my real question -- is there any case when using multi-process to debug several applications
not related via parent-child relationship is better than running N copies of GDB?

Thanks,

-- 
Vladimir Prus
CodeSourcery / Mentor Graphics
http://www.mentor.com/embedded-software/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Multiple inferiors and memory consumption
  2012-07-09 20:31 Multiple inferiors and memory consumption Vladimir Prus
@ 2012-07-10  2:29 ` Tom Tromey
  2012-07-10  4:55   ` Vladimir Prus
  2012-07-10  8:04 ` Chris January
  2012-07-10 20:35 ` Marc Khouzam
  2 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2012-07-10  2:29 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: gdb

>>>>> "Volodya" == Vladimir Prus <vladimir@codesourcery.com> writes:

Volodya> That is, it does not seem like GDB notices that symbol tables
Volodya> of all 4 loaded executables are identical

Volodya> Is this something that is going to be improved upon in future?

I've been working on it off and on.

You can see my latest attempt, search for

    [0/17] RFC: share minimal symbols across objfiles

in the Dec 2011 archives.

There are some follow-up thoughts scattered through the subsequent
months.  The problem is reasonably hard -- those 17 patches only address
minsym sharing, but there is at least partial- and full-symbol sharing
to deal with as well; plus some other things making it harder (dlmopen
support, should we want it, makes a mess of it all).

Volodya> And now for my real question -- is there any case when using
Volodya> multi-process to debug several applications
Volodya> not related via parent-child relationship is better than running N
Volodya> copies of GDB?

Nothing today.

In the future they'll share debuginfo when possible, but that may be the
only advantage.

I've occasionally wondered whether we could have gdb fork when in MI
mode and it follows both parent and child.

Tom

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Multiple inferiors and memory consumption
  2012-07-10  2:29 ` Tom Tromey
@ 2012-07-10  4:55   ` Vladimir Prus
  2012-07-10 19:12     ` Tom Tromey
  0 siblings, 1 reply; 10+ messages in thread
From: Vladimir Prus @ 2012-07-10  4:55 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb

On 10.07.2012 06:29, Tom Tromey wrote:
>>>>>> "Volodya" == Vladimir Prus <vladimir@codesourcery.com> writes:
>
> Volodya> That is, it does not seem like GDB notices that symbol tables
> Volodya> of all 4 loaded executables are identical
>
> Volodya> Is this something that is going to be improved upon in future?
>
> I've been working on it off and on.
>
> You can see my latest attempt, search for
>
>      [0/17] RFC: share minimal symbols across objfiles
>
> in the Dec 2011 archives.
>
> There are some follow-up thoughts scattered through the subsequent
> months.  The problem is reasonably hard -- those 17 patches only address
> minsym sharing, but there is at least partial- and full-symbol sharing
> to deal with as well; plus some other things making it harder (dlmopen
> support, should we want it, makes a mess of it all).

I see -- I did not even know about dlmopen until now ;-)

>
> Volodya> And now for my real question -- is there any case when using
> Volodya> multi-process to debug several applications
> Volodya> not related via parent-child relationship is better than running N
> Volodya> copies of GDB?
>
> Nothing today.
>
> In the future they'll share debuginfo when possible, but that may be the
> only advantage.
>
> I've occasionally wondered whether we could have gdb fork when in MI
> mode and it follows both parent and child.

Interesting approach ;-)

Though I'm thinking that single GDB might allow easier
implementation of possible cool things like "step through DBus call". Or anything where
direct access to two, or several, processes, is needed. Of course, we can do this via
IDE, but with remote debugging that might end up awkward/slow.

- Volodya

-- 
Vladimir Prus
CodeSourcery / Mentor Graphics
http://www.mentor.com/embedded-software/


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Multiple inferiors and memory consumption
  2012-07-09 20:31 Multiple inferiors and memory consumption Vladimir Prus
  2012-07-10  2:29 ` Tom Tromey
@ 2012-07-10  8:04 ` Chris January
  2012-07-10 19:09   ` Tom Tromey
  2012-07-10 20:35 ` Marc Khouzam
  2 siblings, 1 reply; 10+ messages in thread
From: Chris January @ 2012-07-10  8:04 UTC (permalink / raw)
  To: gdb

On Tue, 2012-07-10 at 00:31 +0400, Vladimir Prus wrote:
> It could be me, but I always expected that using GDB multi-process functionality should be better than
> separate GDB instances -- including memory consumption. So, I've just tried to run CVS gdb on itself
> inside 4 inferiors, and it looks like each inferior, the amount of data used by GDB (the DATA column
> in top) grows pretty much linearly. That is, it does not seem like GDB notices that symbol tables of
> all 4 loaded executables are identical (There's a link to the chart: http://goo.gl/0auVf)

We ran across the same problem some time back. There is a comment in
objfiles.h:

FIXME:  There is a problem here if the objfile is reusable, and if
        multiple users are to be supported.  The problem is that the 

so it looks like at least one person has thought about re-using objfile
in the past.

We have a patch that allows multiple programs_spaces to share the same
objfiles by moving the linked list entry into a new struct
objfile_instance.

> And now for my real question -- is there any case when using
> multi-process to debug several applications
> not related via parent-child relationship is better than running N
> copies of GDB?

Most of the time, no. If you are debugging so many processes that the
per GDB memory overhead is starting to hurt then yes, but only if you
are sharing symbol files between inferiors as above.

Regards,
Chris January


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Multiple inferiors and memory consumption
  2012-07-10  8:04 ` Chris January
@ 2012-07-10 19:09   ` Tom Tromey
  2012-07-12 11:01     ` Chris January
  0 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2012-07-10 19:09 UTC (permalink / raw)
  To: Chris January; +Cc: gdb

>>>>> "Chris" == Chris January <chris.january@allinea.com> writes:

Chris> We ran across the same problem some time back. There is a comment in
Chris> objfiles.h:
Chris> FIXME:  There is a problem here if the objfile is reusable, and if
Chris>         multiple users are to be supported.  The problem is that the 

I think this refers to some ancient code that wrote out data to a file
and then later mmap'd it back in.  Search the archives for "mmalloc", I
think.

That code is long gone.  I see the comment is gone now too.

Chris> We have a patch that allows multiple programs_spaces to share the same
Chris> objfiles by moving the linked list entry into a new struct
Chris> objfile_instance.

Presumably this only works if the objfile is mapped at the same address
in each inferior.

I wouldn't mind your patch -- I think it is an improvement -- but I was
trying to make it so that sharing happened regardless of the mapping.
There's no deep reason this can't be done, it is just a gdb design
error.

Tom

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Multiple inferiors and memory consumption
  2012-07-10  4:55   ` Vladimir Prus
@ 2012-07-10 19:12     ` Tom Tromey
  0 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2012-07-10 19:12 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: gdb

>>>>> "Volodya" == Vladimir Prus <vladimir@codesourcery.com> writes:

Volodya> Though I'm thinking that single GDB might allow easier
Volodya> implementation of possible cool things like "step through DBus
Volodya> call". Or anything where direct access to two, or several,
Volodya> processes, is needed. Of course, we can do this via IDE, but
Volodya> with remote debugging that might end up awkward/slow.

Yeah, I think there may be some useful features along these lines that
could be done.  There's nothing pre-canned, though.

I do tend to think that debugging multiple totally unrelated inferiors
is unusual.  That is, gdb will probably provide more benefit than you
might ordinarily expect.

Though, based on bug reporting rates, I think any kind of multi-inferior
debugging is still very rare.

Tom

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: Multiple inferiors and memory consumption
  2012-07-09 20:31 Multiple inferiors and memory consumption Vladimir Prus
  2012-07-10  2:29 ` Tom Tromey
  2012-07-10  8:04 ` Chris January
@ 2012-07-10 20:35 ` Marc Khouzam
  2012-07-10 20:59   ` Paul_Koning
  2012-07-10 21:06   ` Vladimir Prus
  2 siblings, 2 replies; 10+ messages in thread
From: Marc Khouzam @ 2012-07-10 20:35 UTC (permalink / raw)
  To: 'Vladimir Prus', 'gdb@sourceware.org'

 
> And now for my real question -- is there any case when using 
> multi-process to debug several applications
> not related via parent-child relationship is better than 
> running N copies of GDB?

For the sake of completeness, let me mention the obvious.
When doing remote debugging, only one GDB can connect
to the target, so multi-process is the only option to debug
several applications.

Marc

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Multiple inferiors and memory consumption
  2012-07-10 20:35 ` Marc Khouzam
@ 2012-07-10 20:59   ` Paul_Koning
  2012-07-10 21:06   ` Vladimir Prus
  1 sibling, 0 replies; 10+ messages in thread
From: Paul_Koning @ 2012-07-10 20:59 UTC (permalink / raw)
  To: marc.khouzam; +Cc: vladimir, gdb


On Jul 10, 2012, at 4:35 PM, Marc Khouzam wrote:

> 
>> And now for my real question -- is there any case when using 
>> multi-process to debug several applications
>> not related via parent-child relationship is better than 
>> running N copies of GDB?
> 
> For the sake of completeness, let me mention the obvious.
> When doing remote debugging, only one GDB can connect
> to the target, so multi-process is the only option to debug
> several applications.

True if you have a centralized stub.  If you have gdbserver implemented, you can run multiple instances of that, OS permitting.

	paul


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Multiple inferiors and memory consumption
  2012-07-10 20:35 ` Marc Khouzam
  2012-07-10 20:59   ` Paul_Koning
@ 2012-07-10 21:06   ` Vladimir Prus
  1 sibling, 0 replies; 10+ messages in thread
From: Vladimir Prus @ 2012-07-10 21:06 UTC (permalink / raw)
  To: Marc Khouzam; +Cc: 'gdb@sourceware.org'

On 11.07.2012 00:35, Marc Khouzam wrote:
>
>> And now for my real question -- is there any case when using
>> multi-process to debug several applications
>> not related via parent-child relationship is better than
>> running N copies of GDB?
>
> For the sake of completeness, let me mention the obvious.
> When doing remote debugging, only one GDB can connect
> to the target, so multi-process is the only option to debug
> several applications.

Well, yeah. Which seems like a limitation, not feature ;-)


-- 
Vladimir Prus
CodeSourcery / Mentor Graphics
http://www.mentor.com/embedded-software/


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Multiple inferiors and memory consumption
  2012-07-10 19:09   ` Tom Tromey
@ 2012-07-12 11:01     ` Chris January
  0 siblings, 0 replies; 10+ messages in thread
From: Chris January @ 2012-07-12 11:01 UTC (permalink / raw)
  To: gdb

On Tue, 2012-07-10 at 13:09 -0600, Tom Tromey wrote:
> Chris> We have a patch that allows multiple programs_spaces to share the same
> Chris> objfiles by moving the linked list entry into a new struct
> Chris> objfile_instance.
> 
> Presumably this only works if the objfile is mapped at the same address
> in each inferior.

Yes, indeed, so it works well for executables, but less well for shared
libraries.

Chris


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-07-12 11:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-09 20:31 Multiple inferiors and memory consumption Vladimir Prus
2012-07-10  2:29 ` Tom Tromey
2012-07-10  4:55   ` Vladimir Prus
2012-07-10 19:12     ` Tom Tromey
2012-07-10  8:04 ` Chris January
2012-07-10 19:09   ` Tom Tromey
2012-07-12 11:01     ` Chris January
2012-07-10 20:35 ` Marc Khouzam
2012-07-10 20:59   ` Paul_Koning
2012-07-10 21:06   ` Vladimir Prus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).