What are the numbers in the square brackets in NSLog() output?

后端 未结 4 1363
半阙折子戏
半阙折子戏 2020-12-03 05:16

What is the stuff between the [] in the log message below? I get this in my iPhone app, and I have no idea where the message is coming from. My first guess woul

4条回答
  •  甜味超标
    2020-12-03 05:47

    The first number is the process ID, the second is the logging thread's Mach port. A desktop example:

    2010-10-19 17:37:13.189 nc_init[28617:a0f] nc  - default 
    
    (gdb) i thread
    Thread 1 has current state "WAITING"
        Mach port #0xa0f (gdb port #0x4203)
        frame 0: main () at nc_init.m:10
        pthread ID: 0x7fff70ebfc20
        system-wide unique thread id: 0x167b49
        dispatch queue name: "com.apple.main-thread"
        dispatch queue flags: 0x0
        total user time: 13232000
        total system time: 16099000
        scaled cpu usage percentage: 0
        scheduling policy in effect: 0x1
        run state: 0x3 (WAITING)
        flags: 0x0
        number of seconds that thread has slept: 0
        current priority: 31
        max priority: 63
        suspend count: 0.
    
    (gdb) p/x (int)mach_thread_self()
    $1 = 0xa0f
    

    Notice how 0xa0f is reported as the thread's Mach port.

提交回复
热议问题