This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [PATCH] fix PR-12417
- From: "Agovic, Sanimir" <sanimir dot agovic at intel dot com>
- To: 'Mohsan Saleem' <mohsansaleem_ms at yahoo dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Wed, 4 Sep 2013 08:56:09 +0000
- Subject: RE: [PATCH] fix PR-12417
- Authentication-results: sourceware.org; auth=none
- References: <521E2414 dot 40602 at codesourcery dot com> <52254BC6 dot 1050105 at codesourcery dot com> <1378282781 dot 96893 dot YahooMailNeo at web142604 dot mail dot bf1 dot yahoo dot com>
Some comments below.
-Sanimir
> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-owner@sourceware.org] On Behalf
> Of Mohsan Saleem
> Sent: Wednesday, September 04, 2013 10:20 AM
> To: gdb-patches@sourceware.org
> Subject: Re: [PATCH] fix PR-12417
>
>
> Index: ./gdb/thread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/thread.c,v
> retrieving revision 1.155
> diff -u -p -r1.155 thread.c
> --- ./gdb/thread.c 15 Jul 2013 11:14:32 -0000 1.155
> +++ ./gdb/thread.c 3 Sep 2013 02:36:11 -0000
> @@ -64,6 +64,7 @@ static void info_threads_command (char *
> static void thread_apply_command (char *, int);
> static void restore_current_thread (ptid_t);
> static void prune_threads (void);
> +static const char *thread_name (struct thread_info *);
>
> /* Data to cleanup thread array. */
>
> @@ -78,6 +79,14 @@ struct thread_array_cleanup
> };
>
>
> +const char *
> +thread_name (struct thread_info *ti)
>
Constify TI if possible.
> +{
> + const char *name;
>
Newline between variable decl and first statement.
> + name = ti->name != NULL ? ti->name : target_thread_name (ti);
>
A matter of taste, but I prefer explicit if/else
name = ti->name;
if (name == NULL) name = target_thread_name (ti);
if (name == NULL) name = "";
> @@ -251,7 +260,7 @@ add_thread_with_info (ptid_t ptid, struc
> result->private = private;
>
> if (print_thread_events)
> - printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid));
> + printf_unfiltered (_("[New %s \"%s\"\n"), target_pid_to_str (ptid), thread_name
>
This will print [New 1234 ""] in case a thread name is not available, not sure if we
should omit thread name instead.
> @@ -1456,7 +1466,9 @@ do_captured_thread_select (struct ui_out
>
> ui_out_text (uiout, "[Switching to thread ");
> ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferior_ptid));
> - ui_out_text (uiout, " (");
> + ui_out_text (uiout, " \"");
> + ui_out_text (uiout, thread_name (tp));
> + ui_out_text (uiout, "\" (");
> ui_out_text (uiout, target_pid_to_str (inferior_ptid));
> ui_out_text (uiout, ")]");
>
Is the thread name exposed via the MI protocol in some way?
-Sanimir
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052