Fw: question about expand_symtabs_matching()

"Hannes Domani via gdb" <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
Am Freitag, 8. März 2019, 22:13:52 MEZ hat Tom Tromey <[email protected]> Folgendes geschrieben:

> >>>>> "Hannes" == Hannes Domani via gdb <[email protected]> writes:
> 
> Hannes> For the case of 'b some_function', with the application I'm testing:
> Hannes> - startup time with the call of cp_canonicalize_string_no_typedefs(): 1m 25s
> Hannes> - startup time without this call: 27s
> 
> Wow.
> 
> Hannes> In my personal build I've changed this:
> Hannes> - only call cp_canonicalize_string_no_typedefs() if it's not a simple function
> Hannes>   name (like 'function_name' or 'Class::member_function')
> Hannes> - only call expand_symtabs_matching() if the lookup_name doesn't contain a '.'
>
 > Hannes> I admit that I don't fully understand what could break with these changes,
> Hannes> but the speedup makes it worth for me right now.
> 
> Could you send the diff?

Both are attached.

As said before, the first improves the startup time (with 1 pending function breakpoint) from 1m 25s to 27s.

And the second improves it (with 1 pending source:line breakpoint) from 27s to 13s.


Regards
Hannes Domani
0001-Don-t-expand-typedefs-for-functions-without-argument.patch (application/octet-stream, 1.5 KB)
From 2902f8e28b5d8e3c2bf4010c8bf495ae4bc98ff3 Mon Sep 17 00:00:00 2001
From: Hannes Domani <[email protected]>
Date: Fri, 1 Mar 2019 14:05:17 +0100
Subject: [PATCH 1/2] Don't expand typedefs for functions without arguments.

---
 gdb/linespec.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/gdb/linespec.c b/gdb/linespec.c
index 0f2fcfdff0..b01afadd91 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3899,6 +3899,23 @@ find_function_symbols (struct linespec_state *state,
 				  &info, state->search_pspace);
 }
 
+static bool
+is_simple_name (const char *name)
+{
+  do
+    {
+      if (name[0] == ':' && name[1] == ':')
+	name += 2;
+      if (*name == ':')
+	break;
+      while ((*name >= 'A' && *name <= 'Z') || (*name >= 'a' && *name <= 'z')
+	     || (*name >= '0' && *name <= '9') || *name == '_')
+	name++;
+    }
+  while (name[0] == ':' && name[1] == ':');
+  return *name == '\0';
+}
+
 /* Find all symbols named NAME in FILE_SYMTABS, returning debug symbols
    in SYMBOLS and minimal symbols in MINSYMS.  */
 
@@ -3910,7 +3927,9 @@ find_linespec_symbols (struct linespec_state *state,
 		       std::vector <block_symbol> *symbols,
 		       std::vector<bound_minimal_symbol> *minsyms)
 {
-  std::string canon = cp_canonicalize_string_no_typedefs (lookup_name);
+  std::string canon;
+  if (!is_simple_name (lookup_name))
+    canon = cp_canonicalize_string_no_typedefs (lookup_name);
   if (!canon.empty ())
     lookup_name = canon.c_str ();
 
-- 
2.15.1.windows.2
0002-Don-t-expand-symtabs-when-looking-for-a-filename.patch (application/octet-stream, 767 B)
From 9f1e4c10b9e3a691f674b2d2a5c9d4af305f0b26 Mon Sep 17 00:00:00 2001
From: Hannes Domani <[email protected]>
Date: Fri, 1 Mar 2019 14:07:47 +0100
Subject: [PATCH 2/2] Don't expand symtabs when looking for a filename.

---
 gdb/linespec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/linespec.c b/gdb/linespec.c
index e902b11c8e..0f2fcfdff0 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1143,7 +1143,8 @@ iterate_over_all_matching_symtabs
 
     for (objfile *objfile : current_program_space->objfiles ())
       {
-	if (objfile->sf)
+	if (objfile->sf
+	    && lookup_name.name ().find ('.') == std::string::npos)
 	  objfile->sf->qf->expand_symtabs_matching (objfile,
 						    NULL,
 						    lookup_name,
-- 
2.15.1.windows.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.