Clear Ada symbol cache

Message ID 20240904163338.1101543-1-tromey@adacore.com
State New
Headers
Series Clear Ada symbol cache |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom Tromey Sept. 4, 2024, 4:33 p.m. UTC
  This patch changes "maint flush symbol-cache" to also flush the
Ada-specific symbol cache.  This can be helpful when working on the
Ada code.
---
 gdb/ada-lang.c | 4 ++--
 gdb/ada-lang.h | 4 ++++
 gdb/symtab.c   | 1 +
 3 files changed, 7 insertions(+), 2 deletions(-)
  

Comments

Tom de Vries Sept. 6, 2024, 3:14 p.m. UTC | #1
On 9/4/24 18:33, Tom Tromey wrote:
> This patch changes "maint flush symbol-cache" to also flush the
> Ada-specific symbol cache.  This can be helpful when working on the
> Ada code.

Hi Tom,

Makes sense to me.

Approved-By: Tom de Vries <tdevries@suse.de>

Thanks,
- Tom

> ---
>   gdb/ada-lang.c | 4 ++--
>   gdb/ada-lang.h | 4 ++++
>   gdb/symtab.c   | 1 +
>   3 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
> index 83794f97825..93aa78c0c39 100644
> --- a/gdb/ada-lang.c
> +++ b/gdb/ada-lang.c
> @@ -4690,9 +4690,9 @@ make_array_descriptor (struct type *type, struct value *arr)
>      even in this case, some expensive name-based symbol searches are still
>      sometimes necessary - to find an XVZ variable, mostly.  */
>   
> -/* Clear all entries from the symbol cache.  */
> +/* See ada-lang.h.  */
>   
> -static void
> +void
>   ada_clear_symbol_cache (program_space *pspace)
>   {
>     ada_pspace_data_handle.clear (pspace);
> diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
> index 77193ef78b4..050d2980203 100644
> --- a/gdb/ada-lang.h
> +++ b/gdb/ada-lang.h
> @@ -433,4 +433,8 @@ extern block_symbol ada_resolve_variable (struct symbol *sym,
>   extern struct type *ada_index_type (struct type *type, int n,
>   				    const char *name);
>   
> +/* Clear the Ada symbol cache.  */
> +
> +extern void ada_clear_symbol_cache (program_space *pspace);
> +
>   #endif
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index ce5e2520bd1..b955cc873e2 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -1563,6 +1563,7 @@ symbol_cache_mark_not_found (struct block_symbol_cache *bsc,
>   static void
>   symbol_cache_flush (struct program_space *pspace)
>   {
> +  ada_clear_symbol_cache (pspace);
>     struct symbol_cache *cache = symbol_cache_key.get (pspace);
>     int pass;
>
  

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 83794f97825..93aa78c0c39 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4690,9 +4690,9 @@  make_array_descriptor (struct type *type, struct value *arr)
    even in this case, some expensive name-based symbol searches are still
    sometimes necessary - to find an XVZ variable, mostly.  */
 
-/* Clear all entries from the symbol cache.  */
+/* See ada-lang.h.  */
 
-static void
+void
 ada_clear_symbol_cache (program_space *pspace)
 {
   ada_pspace_data_handle.clear (pspace);
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 77193ef78b4..050d2980203 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -433,4 +433,8 @@  extern block_symbol ada_resolve_variable (struct symbol *sym,
 extern struct type *ada_index_type (struct type *type, int n,
 				    const char *name);
 
+/* Clear the Ada symbol cache.  */
+
+extern void ada_clear_symbol_cache (program_space *pspace);
+
 #endif
diff --git a/gdb/symtab.c b/gdb/symtab.c
index ce5e2520bd1..b955cc873e2 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1563,6 +1563,7 @@  symbol_cache_mark_not_found (struct block_symbol_cache *bsc,
 static void
 symbol_cache_flush (struct program_space *pspace)
 {
+  ada_clear_symbol_cache (pspace);
   struct symbol_cache *cache = symbol_cache_key.get (pspace);
   int pass;