gdb how to get thread name displayed

前端 未结 3 1122
深忆病人
深忆病人 2021-01-04 19:34

There are many threads created in my application. some of the threads name are visible in the gdb while i execute the command \'info threads\', others are not displayed. How

3条回答
  •  温柔的废话
    2021-01-04 20:12

    You can set the thread name via non-standard POSIX api calls. GDB (and other debuggers) will display these names.

    On Linux

    // watch out, 16 char limit on the name
    pthread_setname_np(pthread_self(), "My thread name");
    

    On Mac

    pthread_setname_np("My thread name");
    

提交回复
热议问题