Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew STUBBS <andrew.stubbs@st.com>
To: GDB Patches <gdb-patches@sourceware.org>
Subject: [PATCH] fix symbol-file crash
Date: Thu, 01 Dec 2005 18:04:00 -0000	[thread overview]
Message-ID: <438F3A67.1070700@st.com> (raw)

[-- 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 ();
 

             reply	other threads:[~2005-12-01 18:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-01 18:04 Andrew STUBBS [this message]
2005-12-02  1:17 ` Jim Blandy
2005-12-02 11:48   ` Andrew STUBBS

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=438F3A67.1070700@st.com \
    --to=andrew.stubbs@st.com \
    --cc=gdb-patches@sourceware.org \
    /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