Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] fix symbol-file crash
@ 2005-12-01 18:04 Andrew STUBBS
  2005-12-02  1:17 ` Jim Blandy
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew STUBBS @ 2005-12-01 18:04 UTC (permalink / raw)
  To: GDB Patches

[-- Attachment #1: Type: text/plain, Size: 1237 bytes --]

Hi,

The attached patch fixes a bug which causes a crash clearing the symbol 
tables.

The problem occurs as follows:

(gdb) add-symbol-file ~/hello
add symbol table from file "/home/afra/users/stubbsa/hello" at
(y or n) y
Reading symbols from /home/afra/users/stubbsa/hello...done.
Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) symbol-file
Segmentation fault

The problem does not occur when the commands are executed from a script.

The cause is symbol-file asking permission to clear the symbol tables 
using the name of the object file without first checking there is an 
object file. If symbol-file was used to load the symbols then all is 
well. If add-symbol-file was used (which seems to work equally well in 
all other ways) then there is no main object file and it all goes 
horribly wrong.

Note that this is the second problem mentioned in bug #858 and also in 
bug #878, which appears to be a duplicate.

I have fixed this by testing the pointer before dereferencing it and 
using '<unknown>' if there is no object file name. Perhaps there is 
something more intelligent that could be done here, but this fixes the 
problem at hand.

I have also added a missing _() to the query string.

Andrew Stubbs

[-- Attachment #2: symbol-file.patch --]
[-- Type: text/plain, Size: 781 bytes --]

2005-12-01  Andrew Stubbs  <andrew.stubbs@st.com>

	* symfile.c (symbol_file_clear): Test symfile_objfile is not NULL
	before dereferencing it.
	Gettextize the query.

Index: src/gdb/symfile.c
===================================================================
--- src.orig/gdb/symfile.c	2005-12-01 12:05:58.000000000 +0000
+++ src/gdb/symfile.c	2005-12-01 15:21:17.000000000 +0000
@@ -1085,8 +1085,8 @@ symbol_file_clear (int from_tty)
 {
   if ((have_full_symbols () || have_partial_symbols ())
       && from_tty
-      && !query ("Discard symbol table from `%s'? ",
-		 symfile_objfile->name))
+      && !query (_("Discard symbol table from `%s'? "),
+		 symfile_objfile ? symfile_objfile->name : _("<unknown>")))
     error (_("Not confirmed."));
     free_all_objfiles ();
 

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

end of thread, other threads:[~2005-12-02 11:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-01 18:04 [PATCH] fix symbol-file crash Andrew STUBBS
2005-12-02  1:17 ` Jim Blandy
2005-12-02 11:48   ` Andrew STUBBS

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox