This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
RE: Command for number of cores
- From: Marc Khouzam <marc dot khouzam at ericsson dot com>
- To: Hui Zhu <teawater at gmail dot com>
- Cc: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Sun, 1 Aug 2010 20:33:29 -0400
- Subject: RE: Command for number of cores
- References: <F7CE05678329534C957159168FA70DEC5716B5EE01@EUSAACMS0703.eamcs.ericsson.se> <AANLkTinwS-wqdkDuf3zc6+c71CogT70WvmF=dMOMnL_T@mail.gmail.com> <F7CE05678329534C957159168FA70DEC5716BC276A@EUSAACMS0703.eamcs.ericsson.se>,<AANLkTikMTxGUHFXx-QG=H3d+EePU03xmueegT7BZRmPk@mail.gmail.com>
>>> 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