]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: pass program space to get_current_source_symtab_and_line
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 16 May 2024 20:50:22 +0000 (16:50 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 15 Jul 2024 18:34:12 +0000 (14:34 -0400)
Make the current program space reference bubble up one level.

Change-Id: I6ba6dc4a2cb188720cbb61b84ab5c954aac105c6
Approved-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
16 files changed:
gdb/breakpoint.c
gdb/cli/cli-cmds.c
gdb/compile/compile.c
gdb/infcmd.c
gdb/linespec.c
gdb/macroscope.c
gdb/mi/mi-cmd-file.c
gdb/objfiles.c
gdb/parse.c
gdb/python/python.c
gdb/source.c
gdb/source.h
gdb/tui/tui-disasm.c
gdb/tui/tui-hooks.c
gdb/tui/tui-source.c
gdb/tui/tui-winsource.c

index 84b18ecb4b0345da09a7f431c875a6f41c0c732a..a81951702d2fab6ca50e0894276e86865e30a41d 100644 (file)
@@ -8825,8 +8825,6 @@ static void
 parse_breakpoint_sals (location_spec *locspec,
                       struct linespec_result *canonical)
 {
-  struct symtab_and_line cursal;
-
   if (locspec->type () == LINESPEC_LOCATION_SPEC)
     {
       const char *spec
@@ -8875,7 +8873,8 @@ parse_breakpoint_sals (location_spec *locspec,
 
      ObjC: However, don't match an Objective-C method name which
      may have a '+' or '-' succeeded by a '['.  */
-  cursal = get_current_source_symtab_and_line ();
+  symtab_and_line cursal
+    = get_current_source_symtab_and_line (current_program_space);
   if (last_displayed_sal_is_valid ())
     {
       const char *spec = NULL;
index 9d3a90b057d2d48858d468906ba55f54197e8be8..92bb8fc2142063a03a890a240e08ad4637f864e7 100644 (file)
@@ -984,7 +984,7 @@ edit_command (const char *arg, int from_tty)
   if (arg == 0)
     {
       set_default_source_symtab_and_line ();
-      sal = get_current_source_symtab_and_line ();
+      sal = get_current_source_symtab_and_line (current_program_space);
     }
 
   /* Bare "edit" edits file with present line.  */
@@ -1240,7 +1240,8 @@ list_command (const char *arg, int from_tty)
       if (get_first_line_listed () == 0 && (arg == nullptr || arg[0] != '.'))
        {
          set_default_source_symtab_and_line ();
-         list_around_line (arg, get_current_source_symtab_and_line ());
+         list_around_line
+           (arg, get_current_source_symtab_and_line (current_program_space));
        }
 
       /* "l" and "l +" lists the next few lines, unless we're listing past
@@ -1248,7 +1249,8 @@ list_command (const char *arg, int from_tty)
       else if (arg == nullptr || arg[0] == '+')
        {
          set_default_source_symtab_and_line ();
-         const symtab_and_line cursal = get_current_source_symtab_and_line ();
+         const symtab_and_line cursal
+           = get_current_source_symtab_and_line (current_program_space);
          if (last_symtab_line (cursal.symtab) >= cursal.line)
            print_source_lines (cursal.symtab,
                                source_lines_range (cursal.line), 0);
@@ -1262,7 +1264,8 @@ list_command (const char *arg, int from_tty)
       else if (arg[0] == '-')
        {
          set_default_source_symtab_and_line ();
-         const symtab_and_line cursal = get_current_source_symtab_and_line ();
+         const symtab_and_line cursal
+           = get_current_source_symtab_and_line (current_program_space);
 
          if (get_first_line_listed () == 1)
            error (_("Already at the start of %s."),
@@ -1305,7 +1308,8 @@ list_command (const char *arg, int from_tty)
                  error (_("Insufficient debug info for showing source "
                           "lines at default location"));
                }
-             cursal = get_current_source_symtab_and_line ();
+             cursal
+               = get_current_source_symtab_and_line (current_program_space);
 
              gdb_assert (cursal.symtab != nullptr);
            }
index 88531a2178149dd855b57fb0e097c96c57d48549..8896b44a8c41d6e70e141b6500f3b76231a338c9 100644 (file)
@@ -17,6 +17,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include "progspace.h"
 #include "ui.h"
 #include "ui-out.h"
 #include "command.h"
@@ -487,7 +488,8 @@ get_expr_block_and_pc (CORE_ADDR *pc)
 
   if (block == NULL)
     {
-      struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+      symtab_and_line cursal
+       = get_current_source_symtab_and_line (current_program_space);
 
       if (cursal.symtab)
        block = cursal.symtab->compunit ()->blockvector ()->static_block ();
index 4ce11b5af4685c55e0d977b5c38dd5611b5177c6..a030788331c3a8c0f536111dab0f7bf76a375483 100644 (file)
@@ -1078,7 +1078,8 @@ jump_command (const char *arg, int from_tty)
     {
       /* If multiple sal-objects were found, try dropping those that aren't
         from the current symtab.  */
-      struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+      symtab_and_line cursal
+       = get_current_source_symtab_and_line (current_program_space);
       sals.erase (std::remove_if (sals.begin (), sals.end (),
                  [&] (const symtab_and_line &sal)
                    {
index 8670e0ac541535958f7ce136baac1bb836b273b7..eae4f9f44f07500e92b53605e8f481a3114efde4 100644 (file)
@@ -3205,7 +3205,8 @@ decode_line_with_current_source (const char *string, int flags)
 
   /* We use whatever is set as the current source line.  We do not try
      and get a default source symtab+line or it will recursively call us!  */
-  symtab_and_line cursal = get_current_source_symtab_and_line ();
+  symtab_and_line cursal
+    = get_current_source_symtab_and_line (current_program_space);
 
   location_spec_up locspec = string_to_location_spec (&string,
                                                      current_language);
@@ -3255,9 +3256,9 @@ initialize_defaults (struct symtab **default_symtab, int *default_line)
       /* Use whatever we have for the default source line.  We don't use
         get_current_or_default_symtab_and_line as it can recurse and call
         us back!  */
-      struct symtab_and_line cursal = 
-       get_current_source_symtab_and_line ();
-      
+      symtab_and_line cursal
+       = get_current_source_symtab_and_line (current_program_space);
+
       *default_symtab = cursal.symtab;
       *default_line = cursal.line;
     }
index 4c1304f119ad1c506a829edb570a4916ed127003..c1b2238b173f439676b13da15718319dc0f4167c 100644 (file)
@@ -121,9 +121,9 @@ default_macro_scope (void)
         symbol files loaded, then get_current_or_default would raise an
         error.  But `set width' shouldn't raise an error just because
         it can't decide which scope to macro-expand its argument in.  */
-      struct symtab_and_line cursal
-       = get_current_source_symtab_and_line ();
-      
+      symtab_and_line cursal
+       = get_current_source_symtab_and_line (current_program_space);
+
       sal.symtab = cursal.symtab;
       sal.line = cursal.line;
     }
index 3e2702e04ed18784963c353f0c09443b62244cf9..f2fe4351f87397b7584a8a87fd49a1c1f0dbf68e 100644 (file)
@@ -35,7 +35,6 @@ void
 mi_cmd_file_list_exec_source_file (const char *command,
                                   const char *const *argv, int argc)
 {
-  struct symtab_and_line st;
   struct ui_out *uiout = current_uiout;
   
   if (!mi_valid_noargs ("-file-list-exec-source-file", argc, argv))
@@ -43,7 +42,8 @@ mi_cmd_file_list_exec_source_file (const char *command,
 
   /* Set the default file and line, also get them.  */
   set_default_source_symtab_and_line ();
-  st = get_current_source_symtab_and_line ();
+  symtab_and_line st
+    = get_current_source_symtab_and_line (current_program_space);
 
   /* We should always get a symtab.  Apparently, filename does not
      need to be tested for NULL.  The documentation in symtab.h
index ffa730120f57b13001e3065e2102e2cbc0237143..67021581d3caa7a2bc7f27a8fc02995f656f0264 100644 (file)
@@ -561,7 +561,8 @@ objfile::~objfile ()
      and if so, call clear_current_source_symtab_and_line.  */
 
   {
-    struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+    symtab_and_line cursal
+      = get_current_source_symtab_and_line (this->pspace ());
 
     if (cursal.symtab && cursal.symtab->compunit ()->objfile () == this)
       clear_current_source_symtab_and_line (this->pspace ());
index c10b09af485e823d9b413d2819669d8077e0fa7c..2541a2eb143fdbc06ea1f8781640d9f2d9c6da75 100644 (file)
@@ -375,8 +375,8 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
 
       if (!expression_context_block)
        {
-         struct symtab_and_line cursal
-           = get_current_source_symtab_and_line ();
+         symtab_and_line cursal
+           = get_current_source_symtab_and_line (current_program_space);
 
          if (cursal.symtab)
            expression_context_block
index e9092b4d994366a6bd6524fa19584c22056900ee..d86a031ee95dc56a7625d54ccd9f105dc78caedd 100644 (file)
@@ -963,7 +963,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
       else
        {
          set_default_source_symtab_and_line ();
-         def_sal = get_current_source_symtab_and_line ();
+         def_sal = get_current_source_symtab_and_line (current_program_space);
          sals = def_sal;
        }
     }
index bdbe67d19f5ac8b6fb89db0015b5db7ea0a644a3..25d6e7183a723df65e22b8f0dfcadb97435c8de7 100644 (file)
@@ -231,16 +231,15 @@ get_source_location (program_space *pspace)
   return loc;
 }
 
-/* Return the current source file for listing and next line to list.
-   NOTE: The returned sal pc and end fields are not valid.  */
+/* See source.h.  */
    
-struct symtab_and_line
-get_current_source_symtab_and_line (void)
+symtab_and_line
+get_current_source_symtab_and_line (program_space *pspace)
 {
   symtab_and_line cursal;
-  current_source_location *loc = get_source_location (current_program_space);
+  current_source_location *loc = get_source_location (pspace);
 
-  cursal.pspace = current_program_space;
+  cursal.pspace = pspace;
   cursal.symtab = loc->symtab ();
   cursal.line = loc->line ();
   cursal.pc = 0;
index 4eb1793789931213df8dd4521c8c7a2969dc955c..541ee3b7a1248bbfed4eddd52e5258407b644c0c 100644 (file)
@@ -23,6 +23,7 @@
 
 struct program_space;
 struct symtab;
+struct symtab_and_line;
 
 /* See openp function definition for their description.  */
 
@@ -108,7 +109,8 @@ extern int get_lines_to_list (void);
 
 /* Return the current source file for listing and next line to list.
    NOTE: The returned sal pc and end fields are not valid.  */
-extern struct symtab_and_line get_current_source_symtab_and_line (void);
+extern symtab_and_line get_current_source_symtab_and_line
+  (program_space *pspace);
 
 /* If the current source file for listing is not set, try and get a default.
    Usually called before get_current_source_symtab_and_line() is called.
index 2f25fedbcab34ce4243ff0d75a537aa352a4e3a2..53be866187e2ad11d8e1fbf152303ae8940166f8 100644 (file)
@@ -393,7 +393,8 @@ tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
          || have_partial_symbols (current_program_space))
        {
          set_default_source_symtab_and_line ();
-         struct symtab_and_line sal = get_current_source_symtab_and_line ();
+         symtab_and_line sal
+           = get_current_source_symtab_and_line (current_program_space);
 
          if (sal.symtab != nullptr)
            find_line_pc (sal.symtab, sal.line, &addr);
index e6673ab650d8534280dfe82b21d3261bcf85bc0d..25358d08352bc8f64ba2641546870d1d79e58c41 100644 (file)
@@ -127,7 +127,8 @@ tui_refresh_frame_and_register_information ()
       /* Make sure that the source window is displayed.  */
       tui_add_win_to_layout (SRC_WIN);
 
-      struct symtab_and_line sal = get_current_source_symtab_and_line ();
+      symtab_and_line sal
+       = get_current_source_symtab_and_line (current_program_space);
       tui_update_source_windows_with_line (sal);
     }
 }
index 444c0f7a90e6aaeb292e13ab6488a71868c695f9..ee64e4172b51c372793a6a343a45f211abffcbf3 100644 (file)
@@ -136,7 +136,8 @@ tui_source_window::do_scroll_vertical (int num_to_scroll)
   if (!m_content.empty ())
     {
       struct symtab *s;
-      struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+      symtab_and_line cursal
+       = get_current_source_symtab_and_line (current_program_space);
       struct gdbarch *arch = m_gdbarch;
 
       if (cursal.symtab == NULL)
@@ -220,7 +221,7 @@ void
 tui_source_window::display_start_addr (struct gdbarch **gdbarch_p,
                                       CORE_ADDR *addr_p)
 {
-  struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+  symtab_and_line cursal = get_current_source_symtab_and_line (current_program_space);
 
   *gdbarch_p = m_gdbarch;
   find_line_pc (cursal.symtab, m_start_line_or_addr.u.line_no, addr_p);
index 80297e59dd60dfc64cef249dd886504797d9c0b4..b08fca7a7e3e7cebdae8a48505f32b77314fe525 100644 (file)
@@ -440,8 +440,8 @@ tui_source_window_base::rerender ()
 
   if (!m_content.empty ())
     {
-      struct symtab_and_line cursal
-       = get_current_source_symtab_and_line ();
+      symtab_and_line cursal
+       = get_current_source_symtab_and_line (current_program_space);
 
       if (m_start_line_or_addr.loa == LOA_LINE)
        cursal.line = m_start_line_or_addr.u.line_no;
@@ -451,8 +451,8 @@ tui_source_window_base::rerender ()
     }
   else if (deprecated_safe_get_selected_frame () != NULL)
     {
-      struct symtab_and_line cursal
-       = get_current_source_symtab_and_line ();
+      symtab_and_line cursal
+       = get_current_source_symtab_and_line (current_program_space);
       frame_info_ptr frame = deprecated_safe_get_selected_frame ();
       struct gdbarch *gdbarch = get_frame_arch (frame);
 
@@ -492,7 +492,7 @@ tui_source_window_base::refill ()
 
   if (this == tui_src_win ())
     {
-      sal = get_current_source_symtab_and_line ();
+      sal = get_current_source_symtab_and_line (current_program_space);
       if (sal.symtab == NULL)
        {
          frame_info_ptr fi = deprecated_safe_get_selected_frame ();