NSLog - What's the last number?

Member
Posts: 469
Joined: 2002.10
Post: #1
2009-11-24 10:53:48.760 TestApp[35935:207]
Date...Time...proc...pid...

What is that last number?
Mad
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2009.08
Post: #2
It's either process or thread id, I forget which.
Quote this message in a reply
Member
Posts: 254
Joined: 2005.10
Post: #3
_sjc_ Wrote:It's either process or thread id, I forget which.

Probably thread id since kelvin already identified the pid.
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #4
As far as I can tell, it is none of the following:
pid
thread id
gid
ppid
uid
host id

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2009.08
Post: #5
Blacktiger Wrote:Probably thread id since kelvin already identified the pid.

Yeah, thanks. If my posts weren't being held for moderation I would have edited that just after I hit submit.

The value in question is the current mach thread id -- the value returned from pthread_mach_thread_np() -- displayed in hex. See the public CFLite source code, CFUtilities.c, around line 705, for the source of the CFShow() function, which produces output identical to NSLog().
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
That's all well and good in theory but neither pthread_self() nor pthread_mach_thread_np(pthread_self()) give the value that NSLog does:

Code:
Desktop keith$ cat test.m
#import <Foundation/Foundation.h>
#import <unistd.h>

int main() {
    NSLog(@"%p", pthread_self());
    NSLog(@"%u", pthread_mach_thread_np(pthread_self()));
    return 0;
}
Desktop keith$ gcc -Wall -Wextra -Werror test.m -framework Foundation
Desktop keith$ ./a.out
2009-11-27 10:06:48.758 a.out[24390:903] 0x7fff70e5abe0
2009-11-27 10:06:48.760 a.out[24390:903] 2307

So while a thread ID does seem most likely, it's not one of those.
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2009.08
Post: #7
2307 == 0x903

Like I said above, it's displayed in hexadecimal.
Quote this message in a reply
Member
Posts: 245
Joined: 2005.11
Post: #8
Actually, if 903 is a hexadecimal value, then it is equal to 2307 (decimal)...
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #9
Mystery solved. What kind of weirdo thought that printing the thread ID as hexadecimal without a leading 0x was a good idea?
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2009.08
Post: #10
OneSadCookie Wrote:Mystery solved. What kind of weirdo thought that printing the thread ID as hexadecimal without a leading 0x was a good idea?

I only guessed because mine keep coming up with a "d" on the end.
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #11
Thanks for the replies!

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Post Reply