LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-04-2014, 08:10 AM   #1
sree_ec
Member
 
Registered: Sep 2010
Location: world
Distribution: Ubuntu 12.04LTS
Posts: 76

Rep: Reputation: 5
Thread names in GDB


Hi,

I was trying to set names to specific threads in a multi threaded application. This is to make sure that the debugging becomes easy when we debug the app. I tried using the function prctl(2) for the same purpose. Stil thread name doesnt appear when I try
(gdb) thread apply all bt


Currently the o/p of the above command is something like what I have pasted below
Quote:
Thread 2 (process 980):
#0 0x2aabd524 in ?? ()
I would like to see it as

Quote:
Name (process 980):
#0 0x2aabd524 in ?? ()
or
Quote:
Thread 2 (process Name):
#0 0x2aabd524 in ?? ()

is this possible?

this is how I used the function
Quote:
prctl(PR_SET_NAME, (unsigned long) "Name", 0, 0, 0);
Thanks
 
Old 07-08-2014, 12:17 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,150

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
You won't see thread names unless you compile with debug symbols. For gcc that's the "-g" switch.
 
Old 07-09-2014, 01:29 AM   #3
sree_ec
Member
 
Registered: Sep 2010
Location: world
Distribution: Ubuntu 12.04LTS
Posts: 76

Original Poster
Rep: Reputation: 5
Quote:
Originally Posted by smallpond View Post
You won't see thread names unless you compile with debug symbols. For gcc that's the "-g" switch.

I clearly see debug symbols in my program as I have compiled it with -g option as you said.
But still I dont see a name.
My requirement is I should be able to set a name and then the name should appear on GDB for each thread.

if you are referring to ?? in my first post, I edited the actual function names which was appearing on gdb to ??

Last edited by sree_ec; 07-09-2014 at 01:31 AM.
 
Old 07-10-2014, 07:33 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Haven't spent much time worrying over thread NAMES in GDB. Your attempt appeared to be a fair one; however it didn't work. I've always seen it in the "Thread # (Process #)" form. I would think that you'd have better success modifying GDB source and recompiling it so that it would do what you want; however you'd have to determine if the PR_SET_NAME gave symbol information sufficient enough for GDB's use. That is the core problem IMHO. The process name is dynamic, not sure that it is available to the symbol table.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GDB new thread silent/quiet atulsvasu Programming 3 01-05-2022 10:39 AM
how to debug single thread using gdb ven_visu Linux - Software 1 09-08-2011 04:04 AM
thread debugging gdbserver gdb 256Doofus Linux - Embedded & Single-board computer 6 04-13-2009 06:13 AM
how to find thread name using gdb venkat_k Linux - General 0 04-10-2009 01:37 AM
Multi-thread debugging with gdb on RedHat 9.0 Rodney Riggs Linux - Software 0 09-23-2003 04:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration