Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Avoid computing fullname if unused.
@ 2011-11-07  6:37 Doug Evans
  2011-11-07 14:49 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Doug Evans @ 2011-11-07  6:37 UTC (permalink / raw)
  To: gdb-patches

Hi.
"b functi<tab>" takes longer than it should.
gdb spends a lot of time computing a file's "fullname" and then
never using the result.  See maybe_add_partial_symtab_filename.

I will check this in in a few days if there are no objections.

2011-11-06  Doug Evans  <dje@google.com>

	* dwarf2read.c (dw2_map_symbol_filenames): New parameter
	`need_fullname'.
	* psymtab.c (map_symbol_filenames_psymtab): Ditto.
	(map_partial_symbol_filenames): Ditto.  All callers updated.
	* psymtab.h (map_partial_symbol_filenames): Update prototype.
	* symfile.h (struct quick_symbol_functions, map_symbol_filenames): New
	parameter need_fullname.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.578
diff -u -p -r1.578 dwarf2read.c
--- dwarf2read.c	20 Oct 2011 23:13:01 -0000	1.578
+++ dwarf2read.c	7 Nov 2011 06:07:10 -0000
@@ -2810,7 +2817,7 @@ dw2_find_pc_sect_symtab (struct objfile 
 
 static void
 dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
-			  void *data)
+			  void *data, int need_fullname)
 {
   int i;
 
@@ -2832,8 +2839,12 @@ dw2_map_symbol_filenames (struct objfile
 
       for (j = 0; j < file_data->num_file_names; ++j)
 	{
-	  const char *this_real_name = dw2_get_real_path (objfile, file_data,
-							  j);
+	  const char *this_real_name;
+
+	  if (need_fullname)
+	    this_real_name = dw2_get_real_path (objfile, file_data, j);
+	  else
+	    this_real_name = NULL;
 	  (*fun) (file_data->file_names[j], this_real_name, data);
 	}
     }
Index: psymtab.c
===================================================================
RCS file: /cvs/src/src/gdb/psymtab.c,v
retrieving revision 1.31
diff -u -p -r1.31 psymtab.c
--- psymtab.c	28 Oct 2011 17:29:37 -0000	1.31
+++ psymtab.c	7 Nov 2011 06:07:10 -0000
@@ -1082,7 +1089,8 @@ read_psymtabs_with_filename (struct objf
 
 static void
 map_symbol_filenames_psymtab (struct objfile *objfile,
-			      symbol_filename_ftype *fun, void *data)
+			      symbol_filename_ftype *fun, void *data,
+			      int need_fullname)
 {
   struct partial_symtab *ps;
 
@@ -1094,7 +1102,10 @@ map_symbol_filenames_psymtab (struct obj
 	continue;
 
       QUIT;
-      fullname = psymtab_to_fullname (ps);
+      if (need_fullname)
+	fullname = psymtab_to_fullname (ps);
+      else
+	fullname = NULL;
       (*fun) (ps->filename, fullname, data);
     }
 }
@@ -1916,13 +1927,15 @@ expand_partial_symbol_names (int (*fun) 
 }
 
 void
-map_partial_symbol_filenames (symbol_filename_ftype *fun, void *data)
+map_partial_symbol_filenames (symbol_filename_ftype *fun, void *data,
+			      int need_fullname)
 {
   struct objfile *objfile;
 
   ALL_OBJFILES (objfile)
   {
     if (objfile->sf)
-      objfile->sf->qf->map_symbol_filenames (objfile, fun, data);
+      objfile->sf->qf->map_symbol_filenames (objfile, fun, data,
+					     need_fullname);
   }
 }
Index: psymtab.h
===================================================================
RCS file: /cvs/src/src/gdb/psymtab.h,v
retrieving revision 1.8
diff -u -p -r1.8 psymtab.h
--- psymtab.h	10 Jun 2011 21:48:04 -0000	1.8
+++ psymtab.h	7 Nov 2011 06:07:10 -0000
@@ -33,7 +33,8 @@ extern struct bcache *psymbol_bcache_get
 void expand_partial_symbol_names (int (*fun) (const char *, void *),
 				  void *data);
 
-void map_partial_symbol_filenames (symbol_filename_ftype *fun, void *data);
+void map_partial_symbol_filenames (symbol_filename_ftype *fun, void *data,
+				   int need_fullname);
 
 extern const struct quick_symbol_functions psym_functions;
 
Index: symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.96
diff -u -p -r1.96 symfile.h
--- symfile.h	9 Oct 2011 18:37:27 -0000	1.96
+++ symfile.h	7 Nov 2011 06:07:10 -0000
@@ -289,9 +289,11 @@ struct quick_symbol_functions
 
   /* Call a callback for every file defined in OBJFILE whose symtab is
      not already read in.  FUN is the callback.  It is passed the file's
-     FILENAME, the file's FULLNAME, and the DATA passed to this function.  */
+     FILENAME, the file's FULLNAME (if need_fullname is non-zero), and
+     the DATA passed to this function.  */
   void (*map_symbol_filenames) (struct objfile *objfile,
-				symbol_filename_ftype *fun, void *data);
+				symbol_filename_ftype *fun, void *data,
+				int need_fullname);
 };
 
 /* Structure to keep track of symbol reading functions for various
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.285
diff -u -p -r1.285 symtab.c
--- symtab.c	29 Oct 2011 07:26:07 -0000	1.285
+++ symtab.c	7 Nov 2011 06:07:10 -0000
@@ -2881,7 +2890,8 @@ sources_info (char *ignore, int from_tty
 		   "will be read in on demand:\n\n");
 
   first = 1;
-  map_partial_symbol_filenames (output_partial_symbol_filename, &first);
+  map_partial_symbol_filenames (output_partial_symbol_filename, &first,
+				TRUE /*need_fullname*/);
   printf_filtered ("\n");
 }
 
@@ -4314,7 +4324,8 @@ make_source_files_completion_list (char 
   datum.list = &list;
   datum.list_used = &list_used;
   datum.list_alloced = &list_alloced;
-  map_partial_symbol_filenames (maybe_add_partial_symtab_filename, &datum);
+  map_partial_symbol_filenames (maybe_add_partial_symtab_filename, &datum,
+				FALSE /*need_fullname*/);
   discard_cleanups (back_to);
 
   return list;
Index: mi/mi-cmd-file.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-file.c,v
retrieving revision 1.16
diff -u -p -r1.16 mi-cmd-file.c
--- mi/mi-cmd-file.c	4 Aug 2011 19:10:14 -0000	1.16
+++ mi/mi-cmd-file.c	7 Nov 2011 06:07:12 -0000
@@ -109,7 +109,8 @@ mi_cmd_file_list_exec_source_files (char
     ui_out_end (uiout, ui_out_type_tuple);
   }
 
-  map_partial_symbol_filenames (print_partial_file_name, NULL);
+  map_partial_symbol_filenames (print_partial_file_name, NULL,
+				TRUE /*need_fullname*/);
 
   ui_out_end (uiout, ui_out_type_list);
 }


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] Avoid computing fullname if unused.
  2011-11-07  6:37 [patch] Avoid computing fullname if unused Doug Evans
@ 2011-11-07 14:49 ` Tom Tromey
  2011-11-11  0:46   ` Doug Evans
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2011-11-07 14:49 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> 2011-11-06  Doug Evans  <dje@google.com>
Doug> 	* dwarf2read.c (dw2_map_symbol_filenames): New parameter
Doug> 	`need_fullname'.
Doug> 	* psymtab.c (map_symbol_filenames_psymtab): Ditto.
Doug> 	(map_partial_symbol_filenames): Ditto.  All callers updated.
Doug> 	* psymtab.h (map_partial_symbol_filenames): Update prototype.
Doug> 	* symfile.h (struct quick_symbol_functions, map_symbol_filenames): New
Doug> 	parameter need_fullname.

Seems reasonable to me.

Ideally these could be computed lazily, but that is a bit of a pain in C.

Doug> +  map_partial_symbol_filenames (print_partial_file_name, NULL,
Doug> +				TRUE /*need_fullname*/);

I don't think TRUE and FALSE are really part of the gdb style.
gdb tends to just use 0/1 for this.
I'd like us to follow gcc and use 'bool', 'true', and 'false' -- but not
these all-caps spellings.

Tom


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] Avoid computing fullname if unused.
  2011-11-07 14:49 ` Tom Tromey
@ 2011-11-11  0:46   ` Doug Evans
  0 siblings, 0 replies; 3+ messages in thread
From: Doug Evans @ 2011-11-11  0:46 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1720 bytes --]

On Mon, Nov 7, 2011 at 6:48 AM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Doug" == Doug Evans <dje@google.com> writes:
>
> Doug> 2011-11-06  Doug Evans  <dje@google.com>
> Doug>   * dwarf2read.c (dw2_map_symbol_filenames): New parameter
> Doug>   `need_fullname'.
> Doug>   * psymtab.c (map_symbol_filenames_psymtab): Ditto.
> Doug>   (map_partial_symbol_filenames): Ditto.  All callers updated.
> Doug>   * psymtab.h (map_partial_symbol_filenames): Update prototype.
> Doug>   * symfile.h (struct quick_symbol_functions, map_symbol_filenames): New
> Doug>   parameter need_fullname.
>
> Seems reasonable to me.
>
> Ideally these could be computed lazily, but that is a bit of a pain in C.
>
> Doug> +  map_partial_symbol_filenames (print_partial_file_name, NULL,
> Doug> +                         TRUE /*need_fullname*/);
>
> I don't think TRUE and FALSE are really part of the gdb style.
> gdb tends to just use 0/1 for this.
> I'd like us to follow gcc and use 'bool', 'true', and 'false' -- but not
> these all-caps spellings.

TRUE,FALSE are already used in places and my thinking was it's easy to
do a mass search-n-replace when the time comes.
[Easier than 0,1. :-)]
But I went with 0,1 - they are more prevalent.

Committed.

2011-11-10  Doug Evans  <dje@google.com>

        * dwarf2read.c (dw2_map_symbol_filenames): New parameter
        `need_fullname'.
        * psymtab.c (map_symbol_filenames_psymtab): Ditto.
        (map_partial_symbol_filenames): Ditto.  All callers updated.
        * psymtab.h (map_partial_symbol_filenames): Update prototype.
        * symfile.h (struct quick_symbol_functions, map_symbol_filenames): New
        parameter need_fullname.

[-- Attachment #2: gdb-111110-need-fullname-2.patch.txt --]
[-- Type: text/plain, Size: 5844 bytes --]

2011-11-10  Doug Evans  <dje@google.com>

	* dwarf2read.c (dw2_map_symbol_filenames): New parameter
	`need_fullname'.
	* psymtab.c (map_symbol_filenames_psymtab): Ditto.
	(map_partial_symbol_filenames): Ditto.  All callers updated.
	* psymtab.h (map_partial_symbol_filenames): Update prototype.
	* symfile.h (struct quick_symbol_functions, map_symbol_filenames): New
	parameter need_fullname.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.579
diff -u -p -r1.579 dwarf2read.c
--- dwarf2read.c	10 Nov 2011 20:21:27 -0000	1.579
+++ dwarf2read.c	11 Nov 2011 00:18:14 -0000
@@ -2811,7 +2811,7 @@ dw2_find_pc_sect_symtab (struct objfile 
 
 static void
 dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
-			  void *data)
+			  void *data, int need_fullname)
 {
   int i;
 
@@ -2833,8 +2833,12 @@ dw2_map_symbol_filenames (struct objfile
 
       for (j = 0; j < file_data->num_file_names; ++j)
 	{
-	  const char *this_real_name = dw2_get_real_path (objfile, file_data,
-							  j);
+	  const char *this_real_name;
+
+	  if (need_fullname)
+	    this_real_name = dw2_get_real_path (objfile, file_data, j);
+	  else
+	    this_real_name = NULL;
 	  (*fun) (file_data->file_names[j], this_real_name, data);
 	}
     }
Index: psymtab.c
===================================================================
RCS file: /cvs/src/src/gdb/psymtab.c,v
retrieving revision 1.32
diff -u -p -r1.32 psymtab.c
--- psymtab.c	10 Nov 2011 22:14:16 -0000	1.32
+++ psymtab.c	11 Nov 2011 00:18:14 -0000
@@ -1082,7 +1082,8 @@ read_psymtabs_with_filename (struct objf
 
 static void
 map_symbol_filenames_psymtab (struct objfile *objfile,
-			      symbol_filename_ftype *fun, void *data)
+			      symbol_filename_ftype *fun, void *data,
+			      int need_fullname)
 {
   struct partial_symtab *ps;
 
@@ -1094,7 +1095,10 @@ map_symbol_filenames_psymtab (struct obj
 	continue;
 
       QUIT;
-      fullname = psymtab_to_fullname (ps);
+      if (need_fullname)
+	fullname = psymtab_to_fullname (ps);
+      else
+	fullname = NULL;
       (*fun) (ps->filename, fullname, data);
     }
 }
@@ -1921,13 +1925,15 @@ expand_partial_symbol_names (int (*fun) 
 }
 
 void
-map_partial_symbol_filenames (symbol_filename_ftype *fun, void *data)
+map_partial_symbol_filenames (symbol_filename_ftype *fun, void *data,
+			      int need_fullname)
 {
   struct objfile *objfile;
 
   ALL_OBJFILES (objfile)
   {
     if (objfile->sf)
-      objfile->sf->qf->map_symbol_filenames (objfile, fun, data);
+      objfile->sf->qf->map_symbol_filenames (objfile, fun, data,
+					     need_fullname);
   }
 }
Index: psymtab.h
===================================================================
RCS file: /cvs/src/src/gdb/psymtab.h,v
retrieving revision 1.8
diff -u -p -r1.8 psymtab.h
--- psymtab.h	10 Jun 2011 21:48:04 -0000	1.8
+++ psymtab.h	11 Nov 2011 00:18:14 -0000
@@ -33,7 +33,8 @@ extern struct bcache *psymbol_bcache_get
 void expand_partial_symbol_names (int (*fun) (const char *, void *),
 				  void *data);
 
-void map_partial_symbol_filenames (symbol_filename_ftype *fun, void *data);
+void map_partial_symbol_filenames (symbol_filename_ftype *fun, void *data,
+				   int need_fullname);
 
 extern const struct quick_symbol_functions psym_functions;
 
Index: symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.96
diff -u -p -r1.96 symfile.h
--- symfile.h	9 Oct 2011 18:37:27 -0000	1.96
+++ symfile.h	11 Nov 2011 00:18:14 -0000
@@ -289,9 +289,11 @@ struct quick_symbol_functions
 
   /* Call a callback for every file defined in OBJFILE whose symtab is
      not already read in.  FUN is the callback.  It is passed the file's
-     FILENAME, the file's FULLNAME, and the DATA passed to this function.  */
+     FILENAME, the file's FULLNAME (if need_fullname is non-zero), and
+     the DATA passed to this function.  */
   void (*map_symbol_filenames) (struct objfile *objfile,
-				symbol_filename_ftype *fun, void *data);
+				symbol_filename_ftype *fun, void *data,
+				int need_fullname);
 };
 
 /* Structure to keep track of symbol reading functions for various
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.285
diff -u -p -r1.285 symtab.c
--- symtab.c	29 Oct 2011 07:26:07 -0000	1.285
+++ symtab.c	11 Nov 2011 00:18:14 -0000
@@ -2881,7 +2881,8 @@ sources_info (char *ignore, int from_tty
 		   "will be read in on demand:\n\n");
 
   first = 1;
-  map_partial_symbol_filenames (output_partial_symbol_filename, &first);
+  map_partial_symbol_filenames (output_partial_symbol_filename, &first,
+				1 /*need_fullname*/);
   printf_filtered ("\n");
 }
 
@@ -4314,7 +4315,8 @@ make_source_files_completion_list (char 
   datum.list = &list;
   datum.list_used = &list_used;
   datum.list_alloced = &list_alloced;
-  map_partial_symbol_filenames (maybe_add_partial_symtab_filename, &datum);
+  map_partial_symbol_filenames (maybe_add_partial_symtab_filename, &datum,
+				0 /*need_fullname*/);
   discard_cleanups (back_to);
 
   return list;
Index: mi/mi-cmd-file.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-file.c,v
retrieving revision 1.16
diff -u -p -r1.16 mi-cmd-file.c
--- mi/mi-cmd-file.c	4 Aug 2011 19:10:14 -0000	1.16
+++ mi/mi-cmd-file.c	11 Nov 2011 00:18:14 -0000
@@ -109,7 +109,8 @@ mi_cmd_file_list_exec_source_files (char
     ui_out_end (uiout, ui_out_type_tuple);
   }
 
-  map_partial_symbol_filenames (print_partial_file_name, NULL);
+  map_partial_symbol_filenames (print_partial_file_name, NULL,
+				1 /*need_fullname*/);
 
   ui_out_end (uiout, ui_out_type_list);
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-11-11  0:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-07  6:37 [patch] Avoid computing fullname if unused Doug Evans
2011-11-07 14:49 ` Tom Tromey
2011-11-11  0:46   ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox