public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Remove parameter from select_source_symtab
@ 2023-04-17 21:24 Tom Tromey
  2023-04-24 15:45 ` Bruno Larsen
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2023-04-17 21:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed that select_source_symtab is only ever called with nullptr
as an argument, so this patch removes the parameter and associated
logic.
---
 gdb/source.c | 16 ++++------------
 gdb/source.h | 14 ++++++--------
 2 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/gdb/source.c b/gdb/source.c
index 4d297c82ea9..98d02d45448 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -266,7 +266,7 @@ set_default_source_symtab_and_line (void)
   /* Pull in a current source symtab if necessary.  */
   current_source_location *loc = get_source_location (current_program_space);
   if (loc->symtab () == nullptr)
-    select_source_symtab (0);
+    select_source_symtab ();
 }
 
 /* Return the current default file for listing and next line to list
@@ -307,16 +307,8 @@ clear_current_source_symtab_and_line (void)
 /* See source.h.  */
 
 void
-select_source_symtab (struct symtab *s)
+select_source_symtab ()
 {
-  if (s)
-    {
-      current_source_location *loc
-	= get_source_location (s->compunit ()->objfile ()->pspace);
-      loc->set (s, 1);
-      return;
-    }
-
   current_source_location *loc = get_source_location (current_program_space);
   if (loc->symtab () != nullptr)
     return;
@@ -363,7 +355,7 @@ select_source_symtab (struct symtab *s)
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      s = objfile->find_last_source_symtab ();
+      symtab *s = objfile->find_last_source_symtab ();
       if (s)
 	new_symtab = s;
     }
@@ -1617,7 +1609,7 @@ search_command_helper (const char *regex, int from_tty, bool forward)
   current_source_location *loc
     = get_source_location (current_program_space);
   if (loc->symtab () == nullptr)
-    select_source_symtab (0);
+    select_source_symtab ();
 
   if (!source_open)
     error (_("source code access disabled"));
diff --git a/gdb/source.h b/gdb/source.h
index d3e612ceaa1..8fbc365680d 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -202,13 +202,11 @@ extern void print_source_lines (struct symtab *s, source_lines_range r,
    may be found in a different directory now.  */
 extern void forget_cached_source_info (void);
 
-/* Set the source file default for the "list" command to be S.
-
-   If S is NULL, and we don't have a default, find one.  This
-   should only be called when the user actually tries to use the
-   default, since we produce an error if we can't find a reasonable
-   default.  Also, since this can cause symbols to be read, doing it
-   before we need to would make things slower than necessary.  */
-extern void select_source_symtab (struct symtab *s);
+/* Find a source file default for the "list" command.  This should
+   only be called when the user actually tries to use the default,
+   since we produce an error if we can't find a reasonable default.
+   Also, since this can cause symbols to be read, doing it before we
+   need to would make things slower than necessary.  */
+extern void select_source_symtab ();
 
 #endif
-- 
2.39.2


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

* Re: [PATCH] Remove parameter from select_source_symtab
  2023-04-17 21:24 [PATCH] Remove parameter from select_source_symtab Tom Tromey
@ 2023-04-24 15:45 ` Bruno Larsen
  2023-05-07 19:03   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Bruno Larsen @ 2023-04-24 15:45 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 17/04/2023 23:24, Tom Tromey wrote:
> I noticed that select_source_symtab is only ever called with nullptr
> as an argument, so this patch removes the parameter and associated
> logic.
> ---

Hi Tom,

Looks alright to me!

Reviewed-By: Bruno Larsen <blarsen@redhat.com>

-- 
Cheers,
Bruno


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

* Re: [PATCH] Remove parameter from select_source_symtab
  2023-04-24 15:45 ` Bruno Larsen
@ 2023-05-07 19:03   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2023-05-07 19:03 UTC (permalink / raw)
  To: Bruno Larsen via Gdb-patches; +Cc: Tom Tromey, Bruno Larsen

>>>>> Bruno Larsen via Gdb-patches <gdb-patches@sourceware.org> writes:

> On 17/04/2023 23:24, Tom Tromey wrote:
>> I noticed that select_source_symtab is only ever called with nullptr
>> as an argument, so this patch removes the parameter and associated
>> logic.
>> ---

> Looks alright to me!

> Reviewed-By: Bruno Larsen <blarsen@redhat.com>

Thanks, I'm checking it in.

Tom

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

end of thread, other threads:[~2023-05-07 19:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-17 21:24 [PATCH] Remove parameter from select_source_symtab Tom Tromey
2023-04-24 15:45 ` Bruno Larsen
2023-05-07 19:03   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).