public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed] Minor Ada-related cleanups
@ 2021-03-03 19:04 Tom Tromey
  2021-03-03 21:38 ` Christian Biesinger
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2021-03-03 19:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch addresses some review comments that I forgot to deal with
in an earlier patch.  See the comments here:

https://sourceware.org/pipermail/gdb-patches/2021-February/176278.html

For the most part this is fixing up comments, but it also includes
adding a constructor and initializers to "match_data".

Regression tested on x86-64 Fedora 32.

gdb/ChangeLog
2021-03-03  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (ada_resolve_function): Update comment.
	(is_nonfunction, add_symbols_from_enclosing_procs)
	(remove_extra_symbols): Likewise.
	(struct match_data): Add constructor, initializers.
	(add_nonlocal_symbols): Remove memset.
	(aux_add_nonlocal_symbols): Update comment.
	(ada_add_block_renamings, add_nonlocal_symbols)
	(ada_add_all_symbols): Likewise.
	* ada-exp.y (write_var_or_type): Clean up trailing whitespace.
---
 gdb/ChangeLog  | 12 ++++++++++++
 gdb/ada-exp.y  |  2 +-
 gdb/ada-lang.c | 34 ++++++++++++++++++----------------
 3 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index a7e0ccbe5b1..36375d9b8b3 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -1297,7 +1297,7 @@ write_var_or_type (struct parser_state *par_state,
 	      write_selectors (par_state, encoded_name + tail_index);
 	      return NULL;
 	    }
-	  else if (syms.empty ()) 
+	  else if (syms.empty ())
 	    {
 	      struct bound_minimal_symbol msym
 		= ada_lookup_simple_minsym (encoded_name);
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7d94586c7f2..f8bf407fa6c 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3903,7 +3903,7 @@ return_match (struct type *func_type, struct type *context_type)
 }
 
 
-/* Returns the index in SYMS[0..NSYMS-1] that contains  the symbol for the
+/* Returns the index in SYMS that contains the symbol for the
    function (if any) that matches the types of the NARGS arguments in
    ARGS.  If CONTEXT_TYPE is non-null and there is at least one match
    that returns that type, then eliminate matches that don't.  If
@@ -4684,7 +4684,7 @@ standard_lookup (const char *name, const struct block *block,
 
 
 /* Non-zero iff there is at least one non-function/non-enumeral symbol
-   in the symbol fields of SYMS[0..N-1].  We treat enumerals as functions, 
+   in the symbol fields of SYMS.  We treat enumerals as functions, 
    since they contend in overloading in the same way.  */
 static int
 is_nonfunction (const std::vector<struct block_symbol> &syms)
@@ -4838,7 +4838,7 @@ ada_lookup_simple_minsym (const char *name)
 
 /* For all subprograms that statically enclose the subprogram of the
    selected frame, add symbols matching identifier NAME in DOMAIN
-   and their blocks to the list of data in OBSTACKP, as for
+   and their blocks to the list of data in RESULT, as for
    ada_add_block_symbols (q.v.).   If WILD_MATCH_P, treat as NAME
    with a wildcard prefix.  */
 
@@ -4966,8 +4966,7 @@ symbols_are_identical_enums (const std::vector<struct block_symbol> &syms)
    duplicate other symbols in the list (The only case I know of where
    this happens is when object files containing stabs-in-ecoff are
    linked with files containing ordinary ecoff debugging symbols (or no
-   debugging symbols)).  Modifies SYMS to squeeze out deleted entries.
-   Returns the number of items in the modified list.  */
+   debugging symbols)).  Modifies SYMS to squeeze out deleted entries.  */
 
 static void
 remove_extra_symbols (std::vector<struct block_symbol> *syms)
@@ -5291,15 +5290,21 @@ ada_add_local_symbols (std::vector<struct block_symbol> &result,
 
 struct match_data
 {
-  struct objfile *objfile;
+  explicit match_data (std::vector<struct block_symbol> *rp)
+    : resultp (rp)
+  {
+  }
+  DISABLE_COPY_AND_ASSIGN (match_data);
+
+  struct objfile *objfile = nullptr;
   std::vector<struct block_symbol> *resultp;
-  struct symbol *arg_sym;
-  int found_sym;
+  struct symbol *arg_sym = nullptr;
+  int found_sym = 0;
 };
 
 /* A callback for add_nonlocal_symbols that adds symbol, found in BSYM,
    to a list of symbols.  DATA is a pointer to a struct match_data *
-   containing the obstack that collects the symbol list, the file that SYM
+   containing the vector that collects the symbol list, the file that SYM
    must come from, a flag indicating whether a non-argument symbol has
    been found in the current block, and the last argument symbol
    passed in SYM within the current block (if any).  When SYM is null,
@@ -5341,7 +5346,7 @@ aux_add_nonlocal_symbols (struct block_symbol *bsym,
 
 /* Helper for add_nonlocal_symbols.  Find symbols in DOMAIN which are
    targeted by renamings matching LOOKUP_NAME in BLOCK.  Add these
-   symbols to OBSTACKP.  Return whether we found such symbols.  */
+   symbols to RESULT.  Return whether we found such symbols.  */
 
 static int
 ada_add_block_renamings (std::vector<struct block_symbol> &result,
@@ -5490,7 +5495,7 @@ ada_lookup_name (const lookup_name_info &lookup_name)
   return lookup_name.ada ().lookup_name ().c_str ();
 }
 
-/* Add to OBSTACKP all non-local symbols whose name and domain match
+/* Add to RESULT all non-local symbols whose name and domain match
    LOOKUP_NAME and DOMAIN respectively.  The search is performed on
    GLOBAL_BLOCK symbols if GLOBAL is non-zero, or on STATIC_BLOCK
    symbols otherwise.  */
@@ -5500,10 +5505,7 @@ add_nonlocal_symbols (std::vector<struct block_symbol> &result,
 		      const lookup_name_info &lookup_name,
 		      domain_enum domain, int global)
 {
-  struct match_data data;
-
-  memset (&data, 0, sizeof data);
-  data.resultp = &result;
+  struct match_data data (&result);
 
   bool is_wild_match = lookup_name.ada ().wild_match_p ();
 
@@ -5552,7 +5554,7 @@ add_nonlocal_symbols (std::vector<struct block_symbol> &result,
 
 /* Find symbols in DOMAIN matching LOOKUP_NAME, in BLOCK and, if
    FULL_SEARCH is non-zero, enclosing scope and in global scopes,
-   returning the number of matches.  Add these to OBSTACKP.
+   returning the number of matches.  Add these to RESULT.
 
    When FULL_SEARCH is non-zero, any non-function/non-enumeral
    symbol match within the nest of blocks whose innermost member is BLOCK,
-- 
2.26.2


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

* Re: [pushed] Minor Ada-related cleanups
  2021-03-03 19:04 [pushed] Minor Ada-related cleanups Tom Tromey
@ 2021-03-03 21:38 ` Christian Biesinger
  2021-03-04 14:32   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Biesinger @ 2021-03-03 21:38 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Wed, Mar 3, 2021 at 8:04 PM Tom Tromey <tromey@adacore.com> wrote:
>  struct match_data
>  {
> -  struct objfile *objfile;
> +  explicit match_data (std::vector<struct block_symbol> *rp)
> +    : resultp (rp)
> +  {
> +  }
> +  DISABLE_COPY_AND_ASSIGN (match_data);
> +
> +  struct objfile *objfile = nullptr;
>    std::vector<struct block_symbol> *resultp;
> -  struct symbol *arg_sym;
> -  int found_sym;
> +  struct symbol *arg_sym = nullptr;
> +  int found_sym = 0;

Would be nice to change this to bool while you're changing it?

Christian

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

* Re: [pushed] Minor Ada-related cleanups
  2021-03-03 21:38 ` Christian Biesinger
@ 2021-03-04 14:32   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2021-03-04 14:32 UTC (permalink / raw)
  To: Christian Biesinger; +Cc: Tom Tromey, gdb-patches

>> +  int found_sym = 0;

Christian> Would be nice to change this to bool while you're changing it?

Good idea, I've pushed a patch to do this.

Tom

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

end of thread, other threads:[~2021-03-04 14:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 19:04 [pushed] Minor Ada-related cleanups Tom Tromey
2021-03-03 21:38 ` Christian Biesinger
2021-03-04 14:32   ` 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).