public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Command for number of cores
@ 2010-07-27 19:55 Marc Khouzam
  2010-07-28  2:05 ` Hui Zhu
  2010-07-28 19:50 ` Doug Evans
  0 siblings, 2 replies; 8+ messages in thread
From: Marc Khouzam @ 2010-07-27 19:55 UTC (permalink / raw)
  To: 'gdb@sourceware.org'

Hi,

I need a way to know how many cores are on my target (where gdbserver is running).
I'm wondering if GDB already has this information?

If not, I was thinking of adding 'info cores' or 'show cores'.
Or maybe a convenience variable '$numcores'?

I'm thinking 'info cores'.

If this makes sense, I'll give it a try.

Thanks

Marc

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

* Re: Command for number of cores
  2010-07-27 19:55 Command for number of cores Marc Khouzam
@ 2010-07-28  2:05 ` Hui Zhu
  2010-07-28 19:02   ` Marc Khouzam
  2010-07-28 19:50 ` Doug Evans
  1 sibling, 1 reply; 8+ messages in thread
From: Hui Zhu @ 2010-07-28  2:05 UTC (permalink / raw)
  To: Marc Khouzam; +Cc: gdb

p sysconf(_SC_NPROCESSORS_CONF)

On Wed, Jul 28, 2010 at 03:55, Marc Khouzam <marc.khouzam@ericsson.com> wrote:
> Hi,
>
> I need a way to know how many cores are on my target (where gdbserver is running).
> I'm wondering if GDB already has this information?
>
> If not, I was thinking of adding 'info cores' or 'show cores'.
> Or maybe a convenience variable '$numcores'?
>
> I'm thinking 'info cores'.
>
> If this makes sense, I'll give it a try.
>
> Thanks
>
> Marc
>

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

* RE: Command for number of cores
  2010-07-28  2:05 ` Hui Zhu
@ 2010-07-28 19:02   ` Marc Khouzam
  2010-07-29  2:21     ` Hui Zhu
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Khouzam @ 2010-07-28 19:02 UTC (permalink / raw)
  To: 'Hui Zhu'; +Cc: 'gdb@sourceware.org'

> -----Original Message-----
> From: Hui Zhu [mailto:teawater@gmail.com] 
> Sent: Tuesday, July 27, 2010 10:05 PM
> To: Marc Khouzam
> Cc: gdb@sourceware.org
> Subject: Re: Command for number of cores
> 
> p sysconf(_SC_NPROCESSORS_CONF)

How do I get GDB to know about the symbol _SC_NPROCESSORS_CONF?

And when I call sysconf() does it execute on the host or the target?

Thanks


> On Wed, Jul 28, 2010 at 03:55, Marc Khouzam 
> <marc.khouzam@ericsson.com> wrote:
> > Hi,
> >
> > I need a way to know how many cores are on my target (where 
> gdbserver is running).
> > I'm wondering if GDB already has this information?
> >
> > If not, I was thinking of adding 'info cores' or 'show cores'.
> > Or maybe a convenience variable '$numcores'?
> >
> > I'm thinking 'info cores'.
> >
> > If this makes sense, I'll give it a try.
> >
> > Thanks
> >
> > Marc
> >
> 

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

* Re: Command for number of cores
  2010-07-27 19:55 Command for number of cores Marc Khouzam
  2010-07-28  2:05 ` Hui Zhu
@ 2010-07-28 19:50 ` Doug Evans
  2010-07-29 20:27   ` Marc Khouzam
  2010-08-02 15:17   ` Stan Shebs
  1 sibling, 2 replies; 8+ messages in thread
From: Doug Evans @ 2010-07-28 19:50 UTC (permalink / raw)
  To: Marc Khouzam; +Cc: gdb

On Tue, Jul 27, 2010 at 12:55 PM, Marc Khouzam
<marc.khouzam@ericsson.com> wrote:
> Hi,
>
> I need a way to know how many cores are on my target (where gdbserver is running).
> I'm wondering if GDB already has this information?
>
> If not, I was thinking of adding 'info cores' or 'show cores'.
> Or maybe a convenience variable '$numcores'?
>
> I'm thinking 'info cores'.
>
> If this makes sense, I'll give it a try.
>
> Thanks
>
> Marc

If this is on linux, the following should work:

(gdb) remote get /proc/cpuinfo foo
(gdb) shell cat foo

Alas it gives:

Remote I/O error: Invalid argument

[lseek on /proc/cpuinfo failing?]
I think that's a bug though (not the lseek failing, but that "remote
get /proc/cpuinfo foo" fails).
If this is linux, and this is indeed a bug and it were fixed, would
that suffice?

I hesitate to add "info cores" because it seems a bit esoteric, and
you'd have to hack gdb, gdbserver, and document it all when "remote
get" could suffice.

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

* Re: Command for number of cores
  2010-07-28 19:02   ` Marc Khouzam
@ 2010-07-29  2:21     ` Hui Zhu
  2010-08-02  0:38       ` Marc Khouzam
  0 siblings, 1 reply; 8+ messages in thread
From: Hui Zhu @ 2010-07-29  2:21 UTC (permalink / raw)
  To: Marc Khouzam; +Cc: gdb

On Thu, Jul 29, 2010 at 03:02, Marc Khouzam <marc.khouzam@ericsson.com> wrote:
>> -----Original Message-----
>> From: Hui Zhu [mailto:teawater@gmail.com]
>> Sent: Tuesday, July 27, 2010 10:05 PM
>> To: Marc Khouzam
>> Cc: gdb@sourceware.org
>> Subject: Re: Command for number of cores
>>
>> p sysconf(_SC_NPROCESSORS_CONF)
>
> How do I get GDB to know about the symbol _SC_NPROCESSORS_CONF?
>
> And when I call sysconf() does it execute on the host or the target?

This command will let inferior call function sysconf(_SC_NPROCESSORS_CONF).
_SC_NPROCESSORS_CONF is a enum.  In my pc, it's 83.  You can run a
small program that have "printf ("%d", _SC_NPROCESSORS_CONF);" to get
it's value in your target.

I try "p sysconf(83)" in my part.  It works OK.

Thanks,
Hui

>
> Thanks
>
>
>> On Wed, Jul 28, 2010 at 03:55, Marc Khouzam
>> <marc.khouzam@ericsson.com> wrote:
>> > Hi,
>> >
>> > I need a way to know how many cores are on my target (where
>> gdbserver is running).
>> > I'm wondering if GDB already has this information?
>> >
>> > If not, I was thinking of adding 'info cores' or 'show cores'.
>> > Or maybe a convenience variable '$numcores'?
>> >
>> > I'm thinking 'info cores'.
>> >
>> > If this makes sense, I'll give it a try.
>> >
>> > Thanks
>> >
>> > Marc
>> >
>>

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

* RE: Command for number of cores
  2010-07-28 19:50 ` Doug Evans
@ 2010-07-29 20:27   ` Marc Khouzam
  2010-08-02 15:17   ` Stan Shebs
  1 sibling, 0 replies; 8+ messages in thread
From: Marc Khouzam @ 2010-07-29 20:27 UTC (permalink / raw)
  To: 'Doug Evans'; +Cc: 'gdb@sourceware.org'

 

> -----Original Message-----
> From: Doug Evans [mailto:dje@google.com] 
> Sent: Wednesday, July 28, 2010 3:50 PM
> To: Marc Khouzam
> Cc: gdb@sourceware.org
> Subject: Re: Command for number of cores
> 
> On Tue, Jul 27, 2010 at 12:55 PM, Marc Khouzam
> <marc.khouzam@ericsson.com> wrote:
> > Hi,
> >
> > I need a way to know how many cores are on my target (where 
> gdbserver is running).
> > I'm wondering if GDB already has this information?
> >
> > If not, I was thinking of adding 'info cores' or 'show cores'.
> > Or maybe a convenience variable '$numcores'?
> >
> > I'm thinking 'info cores'.
> >
> > If this makes sense, I'll give it a try.
> >
> > Thanks
> >
> > Marc
> 
> If this is on linux, the following should work:
> 
> (gdb) remote get /proc/cpuinfo foo
> (gdb) shell cat foo
> 
> Alas it gives:
> 
> Remote I/O error: Invalid argument

I see that too.
Note that it only fails for /proc/cpuinfo, not for a
'regular' file.

> [lseek on /proc/cpuinfo failing?]
> I think that's a bug though (not the lseek failing, but that "remote
> get /proc/cpuinfo foo" fails).
> If this is linux, and this is indeed a bug and it were fixed, would
> that suffice?

Yes, it is for linux.
And I think that would be enough.  This is needed by eclipse, but I
can have it give this series of commands.

Thanks for the suggestion

> I hesitate to add "info cores" because it seems a bit esoteric, and
> you'd have to hack gdb, gdbserver, and document it all when "remote
> get" could suffice.
> 

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

* RE: Command for number of cores
  2010-07-29  2:21     ` Hui Zhu
@ 2010-08-02  0:38       ` Marc Khouzam
  0 siblings, 0 replies; 8+ messages in thread
From: Marc Khouzam @ 2010-08-02  0:38 UTC (permalink / raw)
  To: Hui Zhu; +Cc: gdb

>>> p sysconf(_SC_NPROCESSORS_CONF)
>>
>> How do I get GDB to know about the symbol _SC_NPROCESSORS_CONF?
>>
>> And when I call sysconf() does it execute on the host or the target?
>
> This command will let inferior call function sysconf(_SC_NPROCESSORS_CONF).
> _SC_NPROCESSORS_CONF is a enum.  In my pc, it's 83.  You can run a
> small program that have "printf ("%d", _SC_NPROCESSORS_CONF);" to get
> it's value in your target.
>
> I try "p sysconf(83)" in my part.  It works OK.

I'm worried that this is not safe.
I didn't mention the context before, but I want to have Eclipse figure out how many cores
are on the target it is connected to when debugging.  Therefore, hard-coding the use of 
sysconf(83) is not safe since I don't know the host Eclipse will run on, and even if I did,
I don't know the target of the particular debug session.
Maybe 83 is good for most Linux, but I don't think it is a very safe approach.

Thanks 

Marc

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

* Re: Command for number of cores
  2010-07-28 19:50 ` Doug Evans
  2010-07-29 20:27   ` Marc Khouzam
@ 2010-08-02 15:17   ` Stan Shebs
  1 sibling, 0 replies; 8+ messages in thread
From: Stan Shebs @ 2010-08-02 15:17 UTC (permalink / raw)
  To: Doug Evans; +Cc: Marc Khouzam, gdb

Doug Evans wrote:
> I hesitate to add "info cores" because it seems a bit esoteric, and
> you'd have to hack gdb, gdbserver, and document it all when "remote
> get" could suffice.
>   

How about an "info arch cores"?  We have "info os <x>" that is 
extensible in a OS-specific way, but I would think number of cores is 
more a property of the architecture than of the OS (although they do 
interact).

Curious that we don't have an "info arch" already - have we really never 
needed random arch info before?

Stan

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

end of thread, other threads:[~2010-08-02 15:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-27 19:55 Command for number of cores Marc Khouzam
2010-07-28  2:05 ` Hui Zhu
2010-07-28 19:02   ` Marc Khouzam
2010-07-29  2:21     ` Hui Zhu
2010-08-02  0:38       ` Marc Khouzam
2010-07-28 19:50 ` Doug Evans
2010-07-29 20:27   ` Marc Khouzam
2010-08-02 15:17   ` Stan Shebs

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).