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

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


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