From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sources.redhat.com
Subject: [RFC/RFA] Set current language when dumping symtab
Date: Wed, 04 May 2005 00:20:00 -0000 [thread overview]
Message-ID: <20050504001955.GE2439@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1355 bytes --]
Hello,
One of our users tried to use the "maint print symbols syms" command
to dump all the symbols in a text format, and that caused a crash on
x86-windows. The reason for the crash is that dump_symtab() indirectly
uses the current language vector to analyze the symbols and then do
the printing. The symtab language may be different from the current
language, so the current language needs to be temporarily adjusted
during the printing. This is what the attached patch does.
2005-05-02 Joel Brobecker <brobecker@adacore.com>
* symmisc.c (dump_symtab_1): Renamed from dump_symtab.
(dump_symtab): New function.
* Makefile.in (symmisc.o): Add dependency on ui-out.h.
Tested on x86-linux, no regression.
You'll notice that I formally tested the change on x86-linux, as
running the testsuite on x86-windows just takes forever (I never had
the patience to wait till the end), but I did verify that this fixes
the problem, and that the output using the language assocated to each
symtab we're printing.
Also, I think we need to do the same for print_msymbols() and
print_psymbols(). I'm a bit in a rush at the moment, so I'm sending
this patch as is for now. I'll understand if I need to rework it later
to include the minsyms and psyms. I thought it might already be useful
to others as is. Just let me know.
Thanks,
--
Joel
[-- Attachment #2: symmisc.c.diff --]
[-- Type: text/plain, Size: 2248 bytes --]
Index: symmisc.c
===================================================================
RCS file: /cvs/src/src/gdb/symmisc.c,v
retrieving revision 1.38
diff -u -p -r1.38 symmisc.c
--- symmisc.c 14 Feb 2005 14:37:38 -0000 1.38
+++ symmisc.c 4 May 2005 00:10:06 -0000
@@ -37,6 +37,7 @@
#include "gdb_regex.h"
#include "gdb_stat.h"
#include "dictionary.h"
+#include "ui-out.h"
#include "gdb_string.h"
#include "readline/readline.h"
@@ -440,8 +441,8 @@ dump_psymtab (struct objfile *objfile, s
}
static void
-dump_symtab (struct objfile *objfile, struct symtab *symtab,
- struct ui_file *outfile)
+dump_symtab_1 (struct objfile *objfile, struct symtab *symtab,
+ struct ui_file *outfile)
{
int i;
struct dict_iterator iter;
@@ -533,6 +534,26 @@ dump_symtab (struct objfile *objfile, st
}
}
+static void
+dump_symtab (struct objfile *objfile, struct symtab *symtab,
+ struct ui_file *outfile)
+{
+ enum language saved_lang;
+ volatile struct gdb_exception except;
+
+ /* Set the current language to the language of the symtab we're dumping
+ because certain routines used during dump_symtab() use the current
+ language to print an image of the symbol. We'll restore it later. */
+ saved_lang = set_language (symtab->language);
+
+ TRY_CATCH (except, RETURN_MASK_ERROR)
+ {
+ dump_symtab_1 (objfile, symtab, outfile);
+ }
+
+ set_language (saved_lang);
+}
+
void
maintenance_print_symbols (char *args, int from_tty)
{
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.726
diff -u -p -r1.726 Makefile.in
--- Makefile.in 2 May 2005 12:05:11 -0000 1.726
+++ Makefile.in 4 May 2005 00:10:31 -0000
@@ -2643,7 +2643,7 @@ symmisc.o: symmisc.c $(defs_h) $(symtab_
$(symfile_h) $(objfiles_h) $(breakpoint_h) $(command_h) \
$(gdb_obstack_h) $(exceptions_h) $(language_h) $(bcache_h) \
$(block_h) $(gdb_regex_h) $(dictionary_h) $(gdb_string_h) \
- $(readline_h)
+ $(readline_h) $(ui_out_h)
symtab.o: symtab.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(gdbcore_h) \
$(frame_h) $(target_h) $(value_h) $(symfile_h) $(objfiles_h) \
$(gdbcmd_h) $(call_cmds_h) $(gdb_regex_h) $(expression_h) \
next reply other threads:[~2005-05-04 0:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-04 0:20 Joel Brobecker [this message]
2005-05-29 0:09 ` Daniel Jacobowitz
2005-05-29 2:54 ` Joel Brobecker
2005-05-29 2:57 ` Daniel Jacobowitz
2005-05-30 15:59 ` Joel Brobecker
2005-05-30 19:55 ` Joel Brobecker
2005-05-30 20:06 ` Daniel Jacobowitz
2005-06-01 1:29 ` Joel Brobecker
2005-06-01 2:00 ` Daniel Jacobowitz
2005-06-03 0:10 ` Joel Brobecker
2005-06-03 19:14 ` Daniel Jacobowitz
2005-06-03 23:27 ` Joel Brobecker
2005-06-02 16:54 ` Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050504001955.GE2439@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox