This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[intercu] Make the max cache age user-settable
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Mon, 19 Apr 2004 16:34:39 -0400
- Subject: [intercu] Make the max cache age user-settable
This patch just changes a #define into a user-settable parameter: "maint set
dwarf2 max-cache-age". It's a maint command because the default is
generally fine; it's settable because, as systems and compilers change,
a different value may become better than the current default.
Committed to the intercu branch.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2004-04-19 Daniel Jacobowitz <drow@mvista.com>
* Makefile.in (dwarf2read.o): Update dependencies.
* dwarf2read.c: Include "command.h" and "gdbcmd.h".
(MAX_CACHE_AGE): Remove.
(dwarf2_max_cache_age): New variable.
(free_comp_units_worker): Update.
(set_dwarf2_cmdlist, show_dwarf2_cmdlist, set_dwarf2_cmd)
(show_dwarf2_cmd): New.
(_initialize_dwarf2_read): Provide "maint set dwarf2 max-cache-age"
and "maint show dwarf2 max-cache-age".
* gdbcmd.h (maintenance_set_cmdlist, maintenance_show_cmdlist): New
externs.
* maint.c (maintenance_set_cmdlist, maintenance_show_cmdlist): Make
global.
2004-04-19 Daniel Jacobowitz <drow@mvista.com>
* gdb.texinfo (Maintenance Commands): Document "maint set dwarf2
max-cache-age" and "maint show dwarf2 max-cache-age".
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.512.2.4
diff -u -p -r1.512.2.4 Makefile.in
--- Makefile.in 2 Apr 2004 16:47:43 -0000 1.512.2.4
+++ Makefile.in 19 Apr 2004 20:02:24 -0000
@@ -1724,7 +1724,7 @@ dwarf2read.o: dwarf2read.c $(defs_h) $(b
$(expression_h) $(filenames_h) $(macrotab_h) $(language_h) \
$(complaints_h) $(bcache_h) $(dwarf2expr_h) $(dwarf2loc_h) \
$(cp_support_h) $(gdb_string_h) $(gdb_assert_h) \
- $(splay_tree_h) $(hashtab_h)
+ $(splay_tree_h) $(hashtab_h) $(command_h) $(gdbcmd_h)
dwarfread.o: dwarfread.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(objfiles_h) \
$(elf_dwarf_h) $(buildsym_h) $(demangle_h) $(expression_h) \
$(language_h) $(complaints_h) $(gdb_string_h)
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.135.2.41
diff -u -p -r1.135.2.41 dwarf2read.c
--- dwarf2read.c 19 Apr 2004 03:37:36 -0000 1.135.2.41
+++ dwarf2read.c 19 Apr 2004 20:02:25 -0000
@@ -46,6 +46,8 @@
#include "cp-support.h"
#include "splay-tree.h"
#include "hashtab.h"
+#include "command.h"
+#include "gdbcmd.h"
#include <fcntl.h>
#include "gdb_string.h"
@@ -66,13 +68,6 @@
can be used for any other data associated to the objfile (symbol
names, type names, location expressions to name a few). */
-/* Loaded secondary compilation units are kept in memory until they
- have not been referenced for the processing of this many
- compilation units. Set this to zero to disable caching. Cache
- sizes of up to at least twenty will improve startup time for
- typical inter-CU-reference binaries, at an obvious memory cost. */
-#define MAX_CACHE_AGE 5
-
#ifndef DWARF2_REG_TO_REGNUM
#define DWARF2_REG_TO_REGNUM(REG) (REG)
#endif
@@ -646,6 +641,13 @@ struct field_info
int nfnfields;
};
+/* Loaded secondary compilation units are kept in memory until they
+ have not been referenced for the processing of this many
+ compilation units. Set this to zero to disable caching. Cache
+ sizes of up to at least twenty will improve startup time for
+ typical inter-CU-reference binaries, at an obvious memory cost. */
+static unsigned int dwarf2_max_cache_age = 5;
+
/* Various complaints about symbol reading that don't abort the process */
static void
@@ -9153,7 +9155,7 @@ free_comp_units_worker (struct dwarf2_cu
while (per_cu != NULL)
{
per_cu->cu->last_used ++;
- if (per_cu->cu->last_used <= MAX_CACHE_AGE)
+ if (per_cu->cu->last_used <= dwarf2_max_cache_age)
dwarf2_mark (per_cu->cu);
per_cu = per_cu->cu->read_in_chain;
}
@@ -9417,10 +9419,51 @@ partial_die_eq (const void *item_lhs, co
return part_die_lhs->offset == part_die_rhs->offset;
}
+static struct cmd_list_element *set_dwarf2_cmdlist;
+static struct cmd_list_element *show_dwarf2_cmdlist;
+
+static void
+set_dwarf2_cmd (char *args, int from_tty)
+{
+ help_list (set_dwarf2_cmdlist, "maintenance set dwarf2 ", -1, gdb_stdout);
+}
+
+static void
+show_dwarf2_cmd (char *args, int from_tty)
+{
+ cmd_show_list (show_dwarf2_cmdlist, from_tty, "");
+}
+
void _initialize_dwarf2_read (void);
void
_initialize_dwarf2_read (void)
{
dwarf2_objfile_data_key = register_objfile_data ();
+
+ add_prefix_cmd ("dwarf2", class_maintenance, set_dwarf2_cmd,
+ "Set DWARF 2 specific variables.\n"
+ "Configure DWARF 2 variables such as the cache size",
+ &set_dwarf2_cmdlist, "maintenance set dwarf2 ",
+ 0/*allow-unknown*/, &maintenance_set_cmdlist);
+
+ add_prefix_cmd ("dwarf2", class_maintenance, show_dwarf2_cmd,
+ "Show DWARF 2 specific variables\n"
+ "Show DWARF 2 variables such as the cache size",
+ &show_dwarf2_cmdlist, "maintenance show dwarf2 ",
+ 0/*allow-unknown*/, &maintenance_show_cmdlist);
+
+ add_setshow_uinteger_cmd ("max-cache-age", class_obscure,
+ &dwarf2_max_cache_age,
+ "Set an upper bound on the age of cached "
+ "compilation units.\n"
+ "A higher limit means that cached "
+ "compilation units will be stored\n"
+ "in memory longer, and more total memory will "
+ "be used. Zero disables\n"
+ "caching, which can slow down startup.",
+ "Show the upper bound on the age of cached "
+ "dwarf2 compilation units.",
+ NULL, NULL, &set_dwarf2_cmdlist,
+ &show_dwarf2_cmdlist);
}
Index: gdbcmd.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbcmd.h,v
retrieving revision 1.10
diff -u -p -r1.10 gdbcmd.h
--- gdbcmd.h 7 May 2003 21:42:47 -0000 1.10
+++ gdbcmd.h 19 Apr 2004 20:02:25 -0000
@@ -98,6 +98,14 @@ extern struct cmd_list_element *maintena
extern struct cmd_list_element *maintenanceprintlist;
+/* Chain containing all defined "maintenance set" subcommands. */
+
+extern struct cmd_list_element *maintenance_set_cmdlist;
+
+/* Chain containing all defined "maintenance show" subcommands. */
+
+extern struct cmd_list_element *maintenance_show_cmdlist;
+
extern struct cmd_list_element *setprintlist;
extern struct cmd_list_element *showprintlist;
Index: maint.c
===================================================================
RCS file: /cvs/src/src/gdb/maint.c,v
retrieving revision 1.41
diff -u -p -r1.41 maint.c
--- maint.c 19 Jan 2004 01:20:11 -0000 1.41
+++ maint.c 19 Apr 2004 20:02:26 -0000
@@ -609,8 +609,8 @@ maintenance_do_deprecate (char *text, in
/* Maintenance set/show framework. */
-static struct cmd_list_element *maintenance_set_cmdlist;
-static struct cmd_list_element *maintenance_show_cmdlist;
+struct cmd_list_element *maintenance_set_cmdlist;
+struct cmd_list_element *maintenance_show_cmdlist;
static void
maintenance_set_cmd (char *args, int from_tty)
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.195.2.2
diff -u -p -r1.195.2.2 gdb.texinfo
--- doc/gdb.texinfo 2 Apr 2004 16:47:49 -0000 1.195.2.2
+++ doc/gdb.texinfo 19 Apr 2004 20:32:35 -0000
@@ -19499,6 +19499,19 @@ data in a @file{gmon.out} file, be sure
Configuring with @samp{--enable-profiling} arranges for @value{GDBN} to be
compiled with the @samp{-pg} compiler option.
+@kindex maint set dwarf2 max-cache-age
+@kindex maint show dwarf2 max-cache-age
+@item maint set dwarf2 max-cache-age
+@itemx maint show dwarf2 max-cache-age
+Control the DWARF 2 compilation unit cache.
+
+In object files with inter-compilation-unit references, such as those
+produced by the GCC option @samp{-feliminate-dwarf2-dups}, the DWARF 2
+reader needs to frequently refer to previously read compilation units.
+This setting controls how long a compilation unit will remain in the cache
+if it is not referenced. Setting it to zero disables caching, which will
+slow down @value{GDBN} startup but reduce memory consumption.
+
@end table