* [patch] Fix crash on `info files' with gdbserver
@ 2012-02-08 20:50 Jan Kratochvil
2012-02-08 21:21 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2012-02-08 20:50 UTC (permalink / raw)
To: gdb-patches
Hi,
while playing with gdbserver GDB just crashed for me.
The problem is exec_ops get pushed to the target stack for the loaded shared
libraries despite exec_bfd remains NULL which is not expected by exec.c.
Breakpoint 1, add_target_sections (sections=0x21372e0, sections_end=0x2137580) at exec.c:471
471 push_target (&exec_ops);
(gdb) bt
#0 add_target_sections (sections=0x21372e0, sections_end=0x2137580) at exec.c:471
#1 in solib_map_sections (so=0x21cd6f0) at solib.c:507
#2 in update_solib_list (from_tty=1, target=0x1d8fee0) at solib.c:804
#3 in solib_add (pattern=0x0, from_tty=1, target=0x1d8fee0, readsyms=1) at solib.c:889
#4 in enable_break (info=0x210f000, from_tty=1) at solib-svr4.c:1624
#5 in svr4_solib_create_inferior_hook (from_tty=1) at solib-svr4.c:2234
#6 in solib_create_inferior_hook (from_tty=1) at solib.c:1172
#7 in reload_shared_libraries (ignored=0x0, from_tty=1, e=0x1fc5cd0) at solib.c:1308
So it is questionable whether to keep exec_ops unpushed or whether to handle
NULL exec_bfd there. I chose the latter.
The set_section_command part has no code change effect, just there was a bug.
No regressions on {x86_64,x86_64-m32,i686}-fedorarawhide-linux-gnu and with
non-extended gdbserver.
I will check it in.
Thanks,
Jan
gdb/
2012-02-08 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix crash on loaded shlibs without loaded exec_bfd.
* exec.c (exec_files_info): Do not crash on NULL EXEC_BFD.
(set_section_command): Replace exec_bfd by p->bfd.
gdb/testsuite/
2012-02-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.server/server-exec-info.exp: New file.
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -761,7 +761,10 @@ print_section_info (struct target_section_table *t, bfd *abfd)
static void
exec_files_info (struct target_ops *t)
{
- print_section_info (current_target_sections, exec_bfd);
+ if (exec_bfd)
+ print_section_info (current_target_sections, exec_bfd);
+ else
+ puts_filtered (_("\t<no file loaded>\n"));
if (vmap)
{
@@ -813,9 +816,9 @@ set_section_command (char *args, int from_tty)
table = current_target_sections;
for (p = table->sections; p < table->sections_end; p++)
{
- if (!strncmp (secname, bfd_section_name (exec_bfd,
+ if (!strncmp (secname, bfd_section_name (p->bfd,
p->the_bfd_section), seclen)
- && bfd_section_name (exec_bfd, p->the_bfd_section)[seclen] == '\0')
+ && bfd_section_name (p->bfd, p->the_bfd_section)[seclen] == '\0')
{
offset = secaddr - p->addr;
p->addr += offset;
--- /dev/null
+++ b/gdb/testsuite/gdb.server/server-exec-info.exp
@@ -0,0 +1,29 @@
+# Copyright (C) 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib gdbserver-support.exp
+
+set testfile "no-execfile-info"
+set srcfile "server.c"
+#if { [build_executable ${testfile}.exp ${testfile} ${srcfile}] == -1} {
+if [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] {
+ return -1
+}
+
+gdb_test "file" ".*" "file" \
+ {Discard symbol table from `.*'\? \(y or n\) } "y"
+gdbserver_run ""
+gdb_test "set sysroot remote:"
+gdb_test "info files" "\r\nLocal exec file:\r\n\t<no file loaded>"
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Fix crash on `info files' with gdbserver
2012-02-08 20:50 [patch] Fix crash on `info files' with gdbserver Jan Kratochvil
@ 2012-02-08 21:21 ` Pedro Alves
2012-02-12 19:16 ` [commit] " Jan Kratochvil
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2012-02-08 21:21 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
On 02/08/2012 08:49 PM, Jan Kratochvil wrote:
> while playing with gdbserver GDB just crashed for me.
>
> The problem is exec_ops get pushed to the target stack for the loaded shared
> libraries despite exec_bfd remains NULL which is not expected by exec.c.
>
> Breakpoint 1, add_target_sections (sections=0x21372e0, sections_end=0x2137580) at exec.c:471
> 471 push_target (&exec_ops);
> (gdb) bt
> #0 add_target_sections (sections=0x21372e0, sections_end=0x2137580) at exec.c:471
> #1 in solib_map_sections (so=0x21cd6f0) at solib.c:507
> #2 in update_solib_list (from_tty=1, target=0x1d8fee0) at solib.c:804
> #3 in solib_add (pattern=0x0, from_tty=1, target=0x1d8fee0, readsyms=1) at solib.c:889
> #4 in enable_break (info=0x210f000, from_tty=1) at solib-svr4.c:1624
> #5 in svr4_solib_create_inferior_hook (from_tty=1) at solib-svr4.c:2234
> #6 in solib_create_inferior_hook (from_tty=1) at solib.c:1172
> #7 in reload_shared_libraries (ignored=0x0, from_tty=1, e=0x1fc5cd0) at solib.c:1308
>
> So it is questionable whether to keep exec_ops unpushed or whether to handle
> NULL exec_bfd there. I chose the latter.
That's the right choice. The exec target nowadays handles reading memory
from all target sections, no matter whether they came from the executable
or from shared libraries. So e.g., "set trust-readonly-sections" works
with the DSOs target sections too.
--
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
* [commit] [patch] Fix crash on `info files' with gdbserver
2012-02-08 21:21 ` Pedro Alves
@ 2012-02-12 19:16 ` Jan Kratochvil
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2012-02-12 19:16 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On Wed, 08 Feb 2012 22:21:12 +0100, Pedro Alves wrote:
> That's the right choice. The exec target nowadays handles reading memory
> from all target sections, no matter whether they came from the executable
> or from shared libraries. So e.g., "set trust-readonly-sections" works
> with the DSOs target sections too.
Checked in:
http://sourceware.org/ml/gdb-cvs/2012-02/msg00065.html
Thanks for the review.
Jan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-02-12 19:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-08 20:50 [patch] Fix crash on `info files' with gdbserver Jan Kratochvil
2012-02-08 21:21 ` Pedro Alves
2012-02-12 19:16 ` [commit] " Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox