(start_remote): Use STOP_QUIETLY_REMOTE.
(handle_inferior_event): Do not condition TARGET_WAITKIND_LOADED
support on a SOLIB_ADD definition. Update breakpoints_inserted.
Update to match shared library event breakpoint support. Only
resume if appropriate. Handle STOP_QUIETLY_REMOTE.
(normal_stop): Handle TARGET_WAITKIND_LOADED.
* fork-child.c (startup_inferior): Do not set
inferior_ignoring_startup_exec_events
* inferior.h (inferior_ignoring_startup_exec_events): Delete
declaration.
(enum stop_kind): Improve documentation. Add STOP_QUIETLY_REMOTE.
* config/gdbserver.exp (gdb_reconnect): New.
* gdb.base/so-disc-shr.c, gdb.base/solib-disc.c,
gdb.base/solib-disc.exp: New files.
* lib/gdb.exp (gdb_test_multiple): Allow tests to match "Ending
remote debugging".
(gdb_compile): Add shlib_load flag.
* lib/gdbserver-support.exp (gdbserver_run): Save the protocol and
port.
(gdbserver_reconnect): New.
+2007-07-02 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * infrun.c (inferior_ignoring_startup_exec_events): Delete.
+ (start_remote): Use STOP_QUIETLY_REMOTE.
+ (handle_inferior_event): Do not condition TARGET_WAITKIND_LOADED
+ support on a SOLIB_ADD definition. Update breakpoints_inserted.
+ Update to match shared library event breakpoint support. Only
+ resume if appropriate. Handle STOP_QUIETLY_REMOTE.
+ (normal_stop): Handle TARGET_WAITKIND_LOADED.
+ * fork-child.c (startup_inferior): Do not set
+ inferior_ignoring_startup_exec_events
+ * inferior.h (inferior_ignoring_startup_exec_events): Delete
+ declaration.
+ (enum stop_kind): Improve documentation. Add STOP_QUIETLY_REMOTE.
+
2007-07-02 Markus Deuling <deuling@de.ibm.com>
* breakpoint.c (insert_bp_location): Remove dead code
init_wait_for_inferior ();
- if (STARTUP_WITH_SHELL)
- inferior_ignoring_startup_exec_events = ntraps;
- else
- inferior_ignoring_startup_exec_events = 0;
inferior_ignoring_leading_exec_events =
target_reported_exec_events_per_exec_call () - 1;
redisplay the prompt until the execution is actually over. */
extern int sync_execution;
-/* This is only valid when inferior_ptid is non-zero.
-
- If this is 0, then exec events should be noticed and responded to
- by the debugger (i.e., be reported to the user).
-
- If this is > 0, then that many subsequent exec events should be
- ignored (i.e., not be reported to the user).
- */
-extern int inferior_ignoring_startup_exec_events;
-
-/* This is only valid when inferior_ignoring_startup_exec_events is
- zero.
-
- Some targets (stupidly) report more than one exec event per actual
+/* Some targets (stupidly) report more than one exec event per actual
call to an event() system call. If only the last such exec event
need actually be noticed and responded to by the debugger (i.e.,
be reported to the user), then this is the number of "leading"
extern int step_multi;
-/* Nonzero means expecting a trap and caller will handle it
- themselves. It is used when running in the shell before the child
- program has been exec'd; and when running some kinds of remote
- stuff (FIXME?). */
+/* Anything but NO_STOP_QUIETLY means we expect a trap and the caller
+ will handle it themselves. STOP_QUIETLY is used when running in
+ the shell before the child program has been exec'd and when running
+ through shared library loading. STOP_QUIETLY_REMOTE is used when
+ setting up a remote connection; it is like STOP_QUIETLY_NO_SIGSTOP
+ except that there is no need to hide a signal. */
/* It is also used after attach, due to attaching to a process. This
is a bit trickier. When doing an attach, the kernel stops the
{
NO_STOP_QUIETLY = 0,
STOP_QUIETLY,
+ STOP_QUIETLY_REMOTE,
STOP_QUIETLY_NO_SIGSTOP
};
void _initialize_infrun (void);
-int inferior_ignoring_startup_exec_events = 0;
int inferior_ignoring_leading_exec_events = 0;
/* When set, stop the 'step' command if we enter a function which has
{
init_thread_list ();
init_wait_for_inferior ();
- stop_soon = STOP_QUIETLY;
+ stop_soon = STOP_QUIETLY_REMOTE;
trap_expected = 0;
/* Always go on waiting for the target, regardless of the mode. */
case TARGET_WAITKIND_LOADED:
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_LOADED\n");
- /* Ignore gracefully during startup of the inferior, as it
- might be the shell which has just loaded some objects,
- otherwise add the symbols for the newly loaded objects. */
-#ifdef SOLIB_ADD
+ /* Ignore gracefully during startup of the inferior, as it might
+ be the shell which has just loaded some objects, otherwise
+ add the symbols for the newly loaded objects. Also ignore at
+ the beginning of an attach or remote session; we will query
+ the full list of libraries once the connection is
+ established. */
if (stop_soon == NO_STOP_QUIETLY)
{
+ int breakpoints_were_inserted;
+
/* Remove breakpoints, SOLIB_ADD might adjust
breakpoint addresses via breakpoint_re_set. */
+ breakpoints_were_inserted = breakpoints_inserted;
if (breakpoints_inserted)
remove_breakpoints ();
+ breakpoints_inserted = 0;
/* Check for any newly added shared libraries if we're
supposed to be adding them automatically. Switch
exec/process stratum, instead relying on the target stack
to propagate relevant changes (stop, section table
changed, ...) up to other layers. */
+#ifdef SOLIB_ADD
SOLIB_ADD (NULL, 0, ¤t_target, auto_solib_add);
+#else
+ solib_add (NULL, 0, ¤t_target, auto_solib_add);
+#endif
target_terminal_inferior ();
+ /* Try to reenable shared library breakpoints, additional
+ code segments in shared libraries might be mapped in now. */
+ re_enable_breakpoints_in_shlibs ();
+
+ /* If requested, stop when the dynamic linker notifies
+ gdb of events. This allows the user to get control
+ and place breakpoints in initializer routines for
+ dynamically loaded objects (among other things). */
+ if (stop_on_solib_events)
+ {
+ stop_stepping (ecs);
+ return;
+ }
+
+ /* NOTE drow/2007-05-11: This might be a good place to check
+ for "catch load". */
+
/* Reinsert breakpoints and continue. */
- if (breakpoints_inserted)
- insert_breakpoints ();
+ if (breakpoints_were_inserted)
+ {
+ insert_breakpoints ();
+ breakpoints_inserted = 1;
+ }
}
-#endif
- resume (0, TARGET_SIGNAL_0);
- prepare_to_wait (ecs);
- return;
+
+ /* If we are skipping through a shell, or through shared library
+ loading that we aren't interested in, resume the program. If
+ we're running the program normally, also resume. But stop if
+ we're attaching or setting up a remote connection. */
+ if (stop_soon == STOP_QUIETLY || stop_soon == NO_STOP_QUIETLY)
+ {
+ resume (0, TARGET_SIGNAL_0);
+ prepare_to_wait (ecs);
+ return;
+ }
+
+ break;
case TARGET_WAITKIND_SPURIOUS:
if (debug_infrun)
&& (stop_signal == TARGET_SIGNAL_ILL
|| stop_signal == TARGET_SIGNAL_SEGV
|| stop_signal == TARGET_SIGNAL_EMT))
- || stop_soon == STOP_QUIETLY || stop_soon == STOP_QUIETLY_NO_SIGSTOP)
+ || stop_soon == STOP_QUIETLY || stop_soon == STOP_QUIETLY_NO_SIGSTOP
+ || stop_soon == STOP_QUIETLY_REMOTE)
{
if (stop_signal == TARGET_SIGNAL_TRAP && stop_after_trap)
{
/* This is originated from start_remote(), start_inferior() and
shared libraries hook functions. */
- if (stop_soon == STOP_QUIETLY)
+ if (stop_soon == STOP_QUIETLY || stop_soon == STOP_QUIETLY_REMOTE)
{
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, "infrun: quietly stopped\n");
switch (bpstat_ret)
{
case PRINT_UNKNOWN:
+ /* If we had hit a shared library event breakpoint,
+ bpstat_print would print out this message. If we hit
+ an OS-level shared library event, do the same
+ thing. */
+ if (last.kind == TARGET_WAITKIND_LOADED)
+ {
+ printf_filtered (_("Stopped due to shared library event\n"));
+ source_flag = SRC_LINE; /* something bogus */
+ do_frame_printing = 0;
+ break;
+ }
+
/* FIXME: cagney/2002-12-01: Given that a frame ID does
(or should) carry around the function and does (or
should) use that when doing a frame comparison. */
+2007-07-02 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * config/gdbserver.exp (gdb_reconnect): New.
+ * gdb.base/so-disc-shr.c, gdb.base/solib-disc.c,
+ gdb.base/solib-disc.exp: New files.
+ * lib/gdb.exp (gdb_test_multiple): Allow tests to match "Ending
+ remote debugging".
+ (gdb_compile): Add shlib_load flag.
+ * lib/gdbserver-support.exp (gdbserver_run): Save the protocol and
+ port.
+ (gdbserver_reconnect): New.
+
2007-07-01 Nick Roberts <nickrob@snap.net.nz>
Daniel Jacobowitz <dan@codesourcery.com>
proc gdb_reload { } {
return [gdbserver_run ""]
}
+
+proc gdb_reconnect { } {
+ return [gdbserver_reconnect]
+}
--- /dev/null
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2007 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#include <stdio.h>
+
+void shrfunc (void)
+{
+ printf ("in shrfunc\n");
+}
--- /dev/null
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2007 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef __WIN32__
+#include <windows.h>
+#define dlopen(name, mode) LoadLibrary (name)
+#define dlsym(handle, func) GetProcAddress (handle, func)
+#define dlclose(handle) FreeLibrary (handle)
+#define dlerror() "an error occurred"
+#else
+#include <dlfcn.h>
+#endif
+
+int main()
+{
+ void *handle;
+ void (*func) (void);
+
+ handle = dlopen (SHLIB_NAME, RTLD_LAZY);
+ if (!handle)
+ {
+ fprintf (stderr, dlerror ());
+ exit (1);
+ }
+
+ func = (void (*)(void)) dlsym (handle, "shrfunc");
+ if (!func)
+ {
+ fprintf (stderr, dlerror ());
+ exit (1);
+ }
+
+ func ();
+
+ dlclose (handle);
+
+ return 0;
+}
--- /dev/null
+# Copyright 2007 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+# Test connecting and disconnecting at shared library events.
+
+if {[skip_shlib_tests]} {
+ return 0
+}
+
+if { [info proc gdb_reconnect] == "" } {
+ return 0
+}
+
+set testfile solib-disc
+set libfile so-disc-shr
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+set libsrc "${srcdir}/${subdir}/${libfile}.c"
+set libname "${libfile}.so"
+set libobj "${objdir}/${subdir}/${libname}"
+set execsrc "${srcdir}/${subdir}/${srcfile}"
+
+remote_exec build "rm -f ${binfile}"
+
+if [get_compiler_info ${binfile}] {
+ return -1
+}
+
+set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME\=\"${libname}\"]
+
+if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
+ || [gdb_compile $execsrc ${binfile} executable $exec_opts] != "" } {
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+gdb_load_shlibs $libobj
+
+if ![runto_main] then {
+ fail "Can't run to main"
+ return 0
+}
+
+gdb_test "set stop-on-solib-events 1" ""
+
+gdb_test "continue" "Stopped due to shared library event" "continue to load"
+
+set msg "save \$pc after load"
+set saved_pc ""
+gdb_test_multiple "print/x \$pc" $msg {
+ -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
+ set saved_pc $expect_out(1,string)
+ pass $msg
+ }
+}
+
+gdb_test "disconnect" "Ending remote debugging\\." "disconnect after load"
+if { [gdb_reconnect] == 0 } {
+ pass "reconnect after load"
+} else {
+ fail "reconnect after load"
+ return 0
+}
+
+gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after load"
+
+
+gdb_test "continue" "Stopped due to shared library event" "continue to unload"
+
+set msg "save \$pc after unload"
+set saved_pc ""
+gdb_test_multiple "print/x \$pc" $msg {
+ -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
+ set saved_pc $expect_out(1,string)
+ pass $msg
+ }
+}
+
+gdb_test "disconnect" "Ending remote debugging\\." "disconnect after unload"
+if { [gdb_reconnect] == 0 } {
+ pass "reconnect after unload"
+} else {
+ fail "reconnect after unload"
+ return 0
+}
+
+gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after unload"
gdb_suppress_entire_file "GDB died";
set result -1;
}
+ }
+ append code $processed_code
+ append code {
-re "Ending remote debugging.*$gdb_prompt $" {
if ![isnative] then {
warning "Can`t communicate to remote target."
gdb_start
set result -1
}
- }
- append code $processed_code
- append code {
-re "Undefined\[a-z\]* command:.*$gdb_prompt $" {
perror "Undefined command \"$command\"."
fail "$message"
lappend options "additional_flags=-rpath ${objdir}/${subdir}"
}
}
+ } elseif { $opt == "shlib_load" } {
+ if { ([istarget "*-*-mingw*"]
+ || [istarget *-*-cygwin*]
+ || [istarget *-*-pe*]
+ || [istarget arm*-*-symbianelf*]
+ || [istarget hppa*-*-hpux*])} {
+ # Do not need anything.
+ } else {
+ lappend new_options "libs=-ldl"
+ lappend new_options "additional_flags=-Wl,-rpath,\\\$ORIGIN"
+ }
} else {
lappend new_options $opt
}
# to it. Return 0 on success, or non-zero on failure.
proc gdbserver_run { child_args } {
+ global gdbserver_protocol
+ global gdbserver_gdbport
+
# Kill anything running before we try to start gdbserver, in case
# we are sharing a serial connection.
global gdb_prompt
}
set res [gdbserver_spawn $child_args]
- set protocol [lindex $res 0]
- set gdbport [lindex $res 1]
+ set gdbserver_protocol [lindex $res 0]
+ set gdbserver_gdbport [lindex $res 1]
+
+ return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
+}
+
+# Reconnect to the previous gdbserver session.
+
+proc gdbserver_reconnect { } {
+ global gdbserver_protocol
+ global gdbserver_gdbport
- return [gdb_target_cmd $protocol $gdbport]
+ return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
}