Don't call decode_line_with_current_source from select_source_symtab
authorTom Tromey <tromey@adacore.com>
Thu, 1 Aug 2019 15:17:14 +0000 (09:17 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 2 Oct 2019 15:53:17 +0000 (09:53 -0600)
select_source_symtab currently calls decode_line_with_current_source.
However, this function iterates over all program spaces, and so it is
possible that it will return a "main" from some other program space.

This patch changes select_source_symtab to simply use the symbol it
already found in the current program space.

gdb/ChangeLog
2019-10-02  Tom Tromey  <tromey@adacore.com>

* source.c (select_source_symtab): Don't call
decode_line_with_current_source.

gdb/ChangeLog
gdb/source.c

index c2417cfd3715bc2142a25241a3d63d29edd8a87b..d419fdfdae3d23ef988dd416dbfa28af31ad016d 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-02  Tom Tromey  <tromey@adacore.com>
+
+       * source.c (select_source_symtab): Don't call
+       decode_line_with_current_source.
+
 2019-10-02  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * symtab.c (lookup_global_symbol): Search global block.
index ff2181894951a16739ee562d531dbcb74c08befc..9222df150508347d079c97b6f3871f24b18d327b 100644 (file)
@@ -252,17 +252,14 @@ select_source_symtab (struct symtab *s)
 
   /* Make the default place to list be the function `main'
      if one exists.  */
-  if (lookup_symbol (main_name (), 0, VAR_DOMAIN, 0).symbol)
+  block_symbol bsym = lookup_symbol (main_name (), 0, VAR_DOMAIN, 0);
+  if (bsym.symbol != nullptr && SYMBOL_CLASS (bsym.symbol) == LOC_BLOCK)
     {
-      std::vector<symtab_and_line> sals
-       = decode_line_with_current_source (main_name (),
-                                          DECODE_LINE_FUNFIRSTLINE);
-      const symtab_and_line &sal = sals[0];
+      symtab_and_line sal = find_function_start_sal (bsym.symbol, true);
       current_source_pspace = sal.pspace;
       current_source_symtab = sal.symtab;
       current_source_line = std::max (sal.line - (lines_to_list - 1), 1);
-      if (current_source_symtab)
-       return;
+      return;
     }
 
   /* Alright; find the last file in the symtab list (ignoring .h's
This page took 0.030442 seconds and 4 git commands to generate.