• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修訂6301c13d9ebeab1b0470573b530fb181ad11526c (tree)
時間2004-03-24 05:28:36
作者Elena Zannoni <ezannoni@kwik...>
CommiterElena Zannoni

Log Message

merge mainline chenges into branch

Change Summary

差異

--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,114 @@
1+2004-03-12 Daniel Jacobowitz <drow@mvista.com>
2+
3+ * linux-low.c: Include <errno.h>. Remove extern declaration of
4+ errno.
5+
6+2004-03-12 Daniel Jacobowitz <drow@mvista.com>
7+
8+ * gdbreplay.c, server.h, utils.c: Update copyright years.
9+
10+2004-03-04 Nathan J. Williams <nathanw@wasabisystems.com>
11+
12+ * server.c (main): Print child status or termination signal from
13+ variable 'signal', not 'sig'.
14+
15+2004-03-04 Nathan J. Williams <nathanw@wasabisystems.com>
16+
17+ * linux-low.c (linux_read_memory): Change return type to
18+ int. Check for and return error from ptrace().
19+ * target.c (read_inferior_memory): Change return type to int. Pass
20+ back return status from the_target->read_memory().
21+ * target.h (struct target_ops): Adapt *read_memory() prototype.
22+ Update comment.
23+ (read_inferior_memory): Adapt prototype.
24+ * server.c (main): Return an error packet if
25+ read_inferior_memory() returns an error.
26+
27+2004-03-04 Daniel Jacobowitz <drow@mvista.com>
28+
29+ * Makefile.in (distclean): Remove config.h, stamp-h, and config.log.
30+ Unify with other clean targets.
31+
32+2004-02-29 Daniel Jacobowitz <drow@mvista.com>
33+
34+ * server.c (handle_v_cont): Call set_desired_inferior.
35+
36+2004-02-29 Daniel Jacobowitz <drow@mvista.com>
37+
38+ * remote-utils.c (prepare_resume_reply): Always supply "thread:".
39+
40+2004-02-29 Daniel Jacobowitz <drow@mvista.com>
41+
42+ * linux-low.c (linux_wait): Unblock async I/O.
43+ (linux_resume): Block and enable async I/O.
44+ * remote-utils.c (block_async_io, unblock_async_io): New functions.
45+ * server.h (block_async_io, unblock_async_io): Add prototypes.
46+
47+2004-02-29 Daniel Jacobowitz <drow@mvista.com>
48+
49+ * remote-utils.c (remote_open): Print a status notice after
50+ opening a TCP port.
51+ * server.c (attach_inferior): Print a status notice after
52+ attaching.
53+
54+2004-02-29 Daniel Jacobowitz <drow@mvista.com>
55+
56+ * linux-arm-low.c (arm_get_pc): Print out stop PC in debug mode.
57+
58+2004-02-26 Daniel Jacobowitz <drow@mvista.com>
59+
60+ * remote-utils.c (write_enn): Use "E01" instead of "ENN" for the
61+ error packet.
62+ * server.c, target.h: Update copyright years.
63+
64+2004-02-25 Roland McGrath <roland@redhat.com>
65+
66+ * target.h (struct target_ops): New member `read_auxv'.
67+ * server.c (handle_query): Handle qPart:auxv:read: query using that.
68+ * linux-low.c (linux_read_auxv): New function.
69+ (linux_target_ops): Initialize `read_auxv' member to that.
70+
71+2004-02-17 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
72+
73+ Committed by Jim Blandy <jimb@redhat.com>.
74+
75+ * linux-s390-low.c (s390_num_regs): Update.
76+ (s390_regmap): Remove control registers. Use __s390x__ predefine
77+ instead of GPR_SIZE to distiguish s390 and s390x targets.
78+
79+2004-01-31 Daniel Jacobowitz <drow@mvista.com>
80+
81+ * linux-low.c: Update copyright year.
82+ (check_removed_breakpoint): Clear pending_is_breakpoint.
83+ (linux_set_resume_request, linux_queue_one_thread)
84+ (resume_status_pending_p): New functions.
85+ (linux_continue_one_thread): Use process->resume.
86+ (linux_resume): Only resume threads if there are no pending events.
87+ * linux-low.h (struct process_info): Add resume request
88+ pointer.
89+
90+2004-01-30 Daniel Jacobowitz <drow@mvista.com>
91+
92+ * regcache.c (new_register_cache): Clear the allocated register
93+ buffer. Suggested by Atsushi Nemoto <anemo@mba.ocn.ne.jp>.
94+
95+2003-10-13 Daniel Jacobowitz <drow@mvista.com>
96+
97+ * linux-low.c (linux_resume): Take a struct thread_resume *
98+ argument.
99+ (linux_wait): Update call.
100+ (resume_ptr): New static variable.
101+ (linux_continue_one_thread): Renamed from
102+ linux_continue_one_process. Use resume_ptr.
103+ (linux_resume): Use linux_continue_one_thread.
104+ * server.c (handle_v_cont, handle_v_requests): New functions.
105+ (myresume): New function.
106+ (main): Handle 'v' case.
107+ * target.h (struct thread_resume): New type.
108+ (struct target_ops): Change argument of "resume" to struct
109+ thread_resume *.
110+ (myresume): Delete macro.
111+
1112 2003-08-08 H.J. Lu <hongjiu.lu@intel.com>
2113
3114 * Makefile.in (install-only): Create dest dir. Support DESTDIR.
@@ -112,7 +223,7 @@ Mon Jul 21 20:09:34 UTC 2003 Brendan Conoboy <blc@redhat.com>
112223 for create_inferior.
113224 * server.c (signal_pid): New variable.
114225 (create_inferior): Set signal_pid. Block SIGTTOU and SIGTTIN in
115- gdbserver. Set the child to be the foreground process group.
226+ gdbserver. Set the child to be the foreground process group.
116227 (attach_inferior): Set signal_pid.
117228
118229 2002-08-23 Daniel Jacobowitz <drow@mvista.com>
@@ -141,7 +252,7 @@ Mon Jul 21 20:09:34 UTC 2003 Brendan Conoboy <blc@redhat.com>
141252
142253 2002-07-04 Michal Ludvig <mludvig@suse.cz>
143254
144- * linux-x86-64-low.c (x86_64_regmap): Make it an array of
255+ * linux-x86-64-low.c (x86_64_regmap): Make it an array of
145256 byte offsets instead of an array of indexes.
146257 (x86_64_store_gregset, x86_64_store_fpregset): Parameter made const.
147258
@@ -526,4 +637,3 @@ Mon Jul 21 20:09:34 UTC 2003 Brendan Conoboy <blc@redhat.com>
526637 * server.h: Add ATTR_NORETURN and ATTR_FORMAT. Update prototypes.
527638 * utils.c (error): Remove NORETURN.
528639 (fatal): Likewise.
529-
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -1,5 +1,5 @@
11 # Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
2-# 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
2+# 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
33
44 # This file is part of GDB.
55
@@ -200,12 +200,8 @@ clean:
200200 rm -f reg-arm.c reg-i386.c reg-ia64.c reg-m68k.c reg-mips.c
201201 rm -f reg-ppc.c reg-sh.c reg-x86-64.c reg-i386-linux.c
202202
203-distclean: clean
204- rm -f nm.h tm.h xm.h config.status
205- rm -f Makefile
206-
207-maintainer-clean realclean: clean
208- rm -f nm.h tm.h xm.h config.status
203+maintainer-clean realclean distclean: clean
204+ rm -f nm.h tm.h xm.h config.status config.h stamp-h config.log
209205 rm -f Makefile
210206
211207 STAGESTUFF=${OBS} ${TSOBS} ${NTSOBS} ${ADD_FILES} init.c init.o version.c gdb
--- a/gdb/gdbserver/gdbreplay.c
+++ b/gdb/gdbserver/gdbreplay.c
@@ -1,5 +1,5 @@
11 /* Replay a remote debug session logfile for GDB.
2- Copyright 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
2+ Copyright 1996, 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
33 Written by Fred Fish (fnf@cygnus.com) from pieces of gdbserver.
44
55 This file is part of GDB.
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -1,5 +1,5 @@
11 /* GNU/Linux/ARM specific low level interface, for the remote server for GDB.
2- Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002
2+ Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004
33 Free Software Foundation, Inc.
44
55 This file is part of GDB.
@@ -47,11 +47,15 @@ arm_cannot_fetch_register (int regno)
4747 return (regno >= arm_num_regs);
4848 }
4949
50+extern int debug_threads;
51+
5052 static CORE_ADDR
5153 arm_get_pc ()
5254 {
5355 unsigned long pc;
5456 collect_register_by_name ("pc", &pc);
57+ if (debug_threads)
58+ fprintf (stderr, "stop pc is %08lx\n", pc);
5559 return pc;
5660 }
5761
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -1,5 +1,5 @@
11 /* Low level interface to ptrace, for the remote server for GDB.
2- Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002
2+ Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004
33 Free Software Foundation, Inc.
44
55 This file is part of GDB.
@@ -34,6 +34,7 @@
3434 #include <string.h>
3535 #include <stdlib.h>
3636 #include <unistd.h>
37+#include <errno.h>
3738
3839 /* ``all_threads'' is keyed by the LWP ID - it should be the thread ID instead,
3940 however. This requires changing the ID in place when we go from !using_threads
@@ -52,7 +53,7 @@ int using_threads;
5253
5354 static void linux_resume_one_process (struct inferior_list_entry *entry,
5455 int step, int signal);
55-static void linux_resume (int step, int signal);
56+static void linux_resume (struct thread_resume *resume_info);
5657 static void stop_all_processes (void);
5758 static int linux_wait_for_event (struct thread_info *child);
5859
@@ -69,8 +70,6 @@ struct pending_signals
6970 static int use_regsets_p = 1;
7071 #endif
7172
72-extern int errno;
73-
7473 int debug_threads = 0;
7574
7675 #define pid_of(proc) ((proc)->head.id)
@@ -316,6 +315,7 @@ check_removed_breakpoint (struct process_info *event_child)
316315 (*the_low_target.set_pc) (stop_pc);
317316
318317 /* We consumed the pending SIGTRAP. */
318+ event_child->pending_is_breakpoint = 0;
319319 event_child->status_pending_p = 0;
320320 event_child->status_pending = 0;
321321
@@ -596,7 +596,7 @@ linux_wait_for_event (struct thread_info *child)
596596
597597 /* If we were single-stepping, we definitely want to report the
598598 SIGTRAP. The single-step operation has completed, so also
599- clear the stepping flag; in general this does not matter,
599+ clear the stepping flag; in general this does not matter,
600600 because the SIGTRAP will be reported to the client, which
601601 will give us a new action for this thread, but clear it for
602602 consistency anyway. It's safe to clear the stepping flag
@@ -652,10 +652,16 @@ retry:
652652
653653 /* No stepping, no signal - unless one is pending already, of course. */
654654 if (child == NULL)
655- linux_resume (0, 0);
655+ {
656+ struct thread_resume resume_info;
657+ resume_info.thread = -1;
658+ resume_info.step = resume_info.sig = resume_info.leave_stopped = 0;
659+ linux_resume (&resume_info);
660+ }
656661 }
657662
658663 enable_async_io ();
664+ unblock_async_io ();
659665 w = linux_wait_for_event (child);
660666 stop_all_processes ();
661667 disable_async_io ();
@@ -835,7 +841,7 @@ linux_resume_one_process (struct inferior_list_entry *entry,
835841
836842 check_removed_breakpoint (process);
837843
838- if (debug_threads && the_low_target.get_pc != NULL)
844+ if (debug_threads && the_low_target.get_pc != NULL)
839845 {
840846 fprintf (stderr, " ");
841847 (long) (*the_low_target.get_pc) ();
@@ -868,33 +874,154 @@ linux_resume_one_process (struct inferior_list_entry *entry,
868874 perror_with_name ("ptrace");
869875 }
870876
871-/* This function is called once per process other than the first
872- one. The first process we are told the signal to continue
873- with, and whether to step or continue; for all others, any
874- existing signals will be marked in status_pending_p to be
875- reported momentarily, and we preserve the stepping flag. */
877+static struct thread_resume *resume_ptr;
878+
879+/* This function is called once per thread. We look up the thread
880+ in RESUME_PTR, and mark the thread with a pointer to the appropriate
881+ resume request.
882+
883+ This algorithm is O(threads * resume elements), but resume elements
884+ is small (and will remain small at least until GDB supports thread
885+ suspension). */
876886 static void
877-linux_continue_one_process (struct inferior_list_entry *entry)
887+linux_set_resume_request (struct inferior_list_entry *entry)
878888 {
879889 struct process_info *process;
890+ struct thread_info *thread;
891+ int ndx;
880892
881- process = (struct process_info *) entry;
882- linux_resume_one_process (entry, process->stepping, 0);
893+ thread = (struct thread_info *) entry;
894+ process = get_thread_process (thread);
895+
896+ ndx = 0;
897+ while (resume_ptr[ndx].thread != -1 && resume_ptr[ndx].thread != entry->id)
898+ ndx++;
899+
900+ process->resume = &resume_ptr[ndx];
883901 }
884902
903+/* This function is called once per thread. We check the thread's resume
904+ request, which will tell us whether to resume, step, or leave the thread
905+ stopped; and what signal, if any, it should be sent. For threads which
906+ we aren't explicitly told otherwise, we preserve the stepping flag; this
907+ is used for stepping over gdbserver-placed breakpoints. */
908+
885909 static void
886-linux_resume (int step, int signal)
910+linux_continue_one_thread (struct inferior_list_entry *entry)
887911 {
888912 struct process_info *process;
913+ struct thread_info *thread;
914+ int step;
915+
916+ thread = (struct thread_info *) entry;
917+ process = get_thread_process (thread);
918+
919+ if (process->resume->leave_stopped)
920+ return;
921+
922+ if (process->resume->thread == -1)
923+ step = process->stepping || process->resume->step;
924+ else
925+ step = process->resume->step;
926+
927+ linux_resume_one_process (&process->head, step, process->resume->sig);
928+
929+ process->resume = NULL;
930+}
931+
932+/* This function is called once per thread. We check the thread's resume
933+ request, which will tell us whether to resume, step, or leave the thread
934+ stopped; and what signal, if any, it should be sent. We queue any needed
935+ signals, since we won't actually resume. We already have a pending event
936+ to report, so we don't need to preserve any step requests; they should
937+ be re-issued if necessary. */
938+
939+static void
940+linux_queue_one_thread (struct inferior_list_entry *entry)
941+{
942+ struct process_info *process;
943+ struct thread_info *thread;
944+
945+ thread = (struct thread_info *) entry;
946+ process = get_thread_process (thread);
947+
948+ if (process->resume->leave_stopped)
949+ return;
950+
951+ /* If we have a new signal, enqueue the signal. */
952+ if (process->resume->sig != 0)
953+ {
954+ struct pending_signals *p_sig;
955+ p_sig = malloc (sizeof (*p_sig));
956+ p_sig->prev = process->pending_signals;
957+ p_sig->signal = process->resume->sig;
958+ process->pending_signals = p_sig;
959+ }
960+
961+ process->resume = NULL;
962+}
963+
964+/* Set DUMMY if this process has an interesting status pending. */
965+static int
966+resume_status_pending_p (struct inferior_list_entry *entry, void *flag_p)
967+{
968+ struct process_info *process = (struct process_info *) entry;
969+
970+ /* Processes which will not be resumed are not interesting, because
971+ we might not wait for them next time through linux_wait. */
972+ if (process->resume->leave_stopped)
973+ return 0;
889974
890- process = get_thread_process (current_inferior);
975+ /* If this thread has a removed breakpoint, we won't have any
976+ events to report later, so check now. check_removed_breakpoint
977+ may clear status_pending_p. We avoid calling check_removed_breakpoint
978+ for any thread that we are not otherwise going to resume - this
979+ lets us preserve stopped status when two threads hit a breakpoint.
980+ GDB removes the breakpoint to single-step a particular thread
981+ past it, then re-inserts it and resumes all threads. We want
982+ to report the second thread without resuming it in the interim. */
983+ if (process->status_pending_p)
984+ check_removed_breakpoint (process);
985+
986+ if (process->status_pending_p)
987+ * (int *) flag_p = 1;
988+
989+ return 0;
990+}
991+
992+static void
993+linux_resume (struct thread_resume *resume_info)
994+{
995+ int pending_flag;
996+
997+ /* Yes, the use of a global here is rather ugly. */
998+ resume_ptr = resume_info;
891999
892- /* If the current process has a status pending, this signal will
893- be enqueued and sent later. */
894- linux_resume_one_process (&process->head, step, signal);
1000+ for_each_inferior (&all_threads, linux_set_resume_request);
8951001
896- if (cont_thread == 0 || cont_thread == -1)
897- for_each_inferior (&all_processes, linux_continue_one_process);
1002+ /* If there is a thread which would otherwise be resumed, which
1003+ has a pending status, then don't resume any threads - we can just
1004+ report the pending status. Make sure to queue any signals
1005+ that would otherwise be sent. */
1006+ pending_flag = 0;
1007+ find_inferior (&all_processes, resume_status_pending_p, &pending_flag);
1008+
1009+ if (debug_threads)
1010+ {
1011+ if (pending_flag)
1012+ fprintf (stderr, "Not resuming, pending status\n");
1013+ else
1014+ fprintf (stderr, "Resuming, no pending status\n");
1015+ }
1016+
1017+ if (pending_flag)
1018+ for_each_inferior (&all_threads, linux_queue_one_thread);
1019+ else
1020+ {
1021+ block_async_io ();
1022+ enable_async_io ();
1023+ for_each_inferior (&all_threads, linux_continue_one_thread);
1024+ }
8981025 }
8991026
9001027 #ifdef HAVE_LINUX_USRREGS
@@ -1153,28 +1280,33 @@ linux_store_registers (int regno)
11531280 /* Copy LEN bytes from inferior's memory starting at MEMADDR
11541281 to debugger memory starting at MYADDR. */
11551282
1156-static void
1283+static int
11571284 linux_read_memory (CORE_ADDR memaddr, char *myaddr, int len)
11581285 {
11591286 register int i;
11601287 /* Round starting address down to longword boundary. */
11611288 register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_XFER_TYPE);
11621289 /* Round ending address up; get number of longwords that makes. */
1163- register int count
1164- = (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1)
1290+ register int count
1291+ = (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1)
11651292 / sizeof (PTRACE_XFER_TYPE);
11661293 /* Allocate buffer of that many longwords. */
1167- register PTRACE_XFER_TYPE *buffer
1294+ register PTRACE_XFER_TYPE *buffer
11681295 = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE));
11691296
11701297 /* Read all the longwords */
11711298 for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
11721299 {
1300+ errno = 0;
11731301 buffer[i] = ptrace (PTRACE_PEEKTEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
1302+ if (errno)
1303+ return errno;
11741304 }
11751305
11761306 /* Copy appropriate bytes out of the buffer. */
11771307 memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)), len);
1308+
1309+ return 0;
11781310 }
11791311
11801312 /* Copy LEN bytes of data from debugger memory at MYADDR
@@ -1258,6 +1390,32 @@ linux_send_signal (int signum)
12581390 kill (signal_pid, signum);
12591391 }
12601392
1393+/* Copy LEN bytes from inferior's auxiliary vector starting at OFFSET
1394+ to debugger memory starting at MYADDR. */
1395+
1396+static int
1397+linux_read_auxv (CORE_ADDR offset, char *myaddr, unsigned int len)
1398+{
1399+ char filename[PATH_MAX];
1400+ int fd, n;
1401+
1402+ snprintf (filename, sizeof filename, "/proc/%d/auxv", inferior_pid);
1403+
1404+ fd = open (filename, O_RDONLY);
1405+ if (fd < 0)
1406+ return -1;
1407+
1408+ if (offset != (CORE_ADDR) 0
1409+ && lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)
1410+ n = -1;
1411+ else
1412+ n = read (fd, myaddr, len);
1413+
1414+ close (fd);
1415+
1416+ return n;
1417+}
1418+
12611419
12621420 static struct target_ops linux_target_ops = {
12631421 linux_create_inferior,
@@ -1273,6 +1431,7 @@ static struct target_ops linux_target_ops = {
12731431 linux_write_memory,
12741432 linux_look_up_symbols,
12751433 linux_send_signal,
1434+ linux_read_auxv,
12761435 };
12771436
12781437 static void
--- a/gdb/gdbserver/linux-low.h
+++ b/gdb/gdbserver/linux-low.h
@@ -1,5 +1,5 @@
11 /* Internal interfaces for the GNU/Linux specific target code for gdbserver.
2- Copyright 2002, Free Software Foundation, Inc.
2+ Copyright 2002, 2004 Free Software Foundation, Inc.
33
44 This file is part of GDB.
55
@@ -106,7 +106,13 @@ struct process_info
106106 /* If this is non-zero, it points to a chain of signals which need to
107107 be delivered to this process. */
108108 struct pending_signals *pending_signals;
109+
110+ /* A link used when resuming. It is initialized from the resume request,
111+ and then processed and cleared in linux_resume_one_process. */
112+
113+ struct thread_resume *resume;
109114 };
115+
110116 extern struct inferior_list all_processes;
111117
112118 void linux_attach_lwp (int pid, int tid);
--- a/gdb/gdbserver/linux-s390-low.c
+++ b/gdb/gdbserver/linux-s390-low.c
@@ -27,7 +27,7 @@
2727
2828 #include <asm/ptrace.h>
2929
30-#define s390_num_regs 67
30+#define s390_num_regs 51
3131
3232 static int s390_regmap[] = {
3333 PT_PSWMASK, PT_PSWADDR,
@@ -42,15 +42,9 @@ static int s390_regmap[] = {
4242 PT_ACR8, PT_ACR9, PT_ACR10, PT_ACR11,
4343 PT_ACR12, PT_ACR13, PT_ACR14, PT_ACR15,
4444
45- -1, -1, -1, -1,
46- -1, -1, -1, -1,
47- -1, PT_CR_9, PT_CR_10, PT_CR_11,
48- -1, -1, -1, -1,
49-
5045 PT_FPC,
5146
52-/* <asm/ptrace.h> defines GPR_SIZE. */
53-#if GPR_SIZE == 4
47+#ifndef __s390x__
5448 PT_FPR0_HI, PT_FPR1_HI, PT_FPR2_HI, PT_FPR3_HI,
5549 PT_FPR4_HI, PT_FPR5_HI, PT_FPR6_HI, PT_FPR7_HI,
5650 PT_FPR8_HI, PT_FPR9_HI, PT_FPR10_HI, PT_FPR11_HI,
--- a/gdb/gdbserver/regcache.c
+++ b/gdb/gdbserver/regcache.c
@@ -1,5 +1,5 @@
11 /* Register support routines for the remote server for GDB.
2- Copyright 2001, 2002
2+ Copyright 2001, 2002, 2004
33 Free Software Foundation, Inc.
44
55 This file is part of GDB.
@@ -101,7 +101,10 @@ new_register_cache (void)
101101
102102 regcache = malloc (sizeof (*regcache));
103103
104- regcache->registers = malloc (register_bytes);
104+ /* Make sure to zero-initialize the register cache when it is created,
105+ in case there are registers the target never fetches. This way they'll
106+ read as zero instead of garbage. */
107+ regcache->registers = calloc (1, register_bytes);
105108 if (regcache->registers == NULL)
106109 fatal ("Could not allocate register cache.");
107110
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -1,6 +1,6 @@
11 /* Remote utility routines for the remote server for GDB.
22 Copyright 1986, 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3- 2002
3+ 2002, 2003, 2004
44 Free Software Foundation, Inc.
55
66 This file is part of GDB.
@@ -135,6 +135,8 @@ remote_open (char *name)
135135 || listen (tmp_desc, 1))
136136 perror_with_name ("Can't bind address");
137137
138+ fprintf (stderr, "Listening on port %d\n", port);
139+
138140 tmp = sizeof (sockaddr);
139141 remote_desc = accept (tmp_desc, (struct sockaddr *) &sockaddr, &tmp);
140142 if (remote_desc == -1)
@@ -366,6 +368,24 @@ input_interrupt (int unused)
366368 }
367369
368370 void
371+block_async_io (void)
372+{
373+ sigset_t sigio_set;
374+ sigemptyset (&sigio_set);
375+ sigaddset (&sigio_set, SIGIO);
376+ sigprocmask (SIG_BLOCK, &sigio_set, NULL);
377+}
378+
379+void
380+unblock_async_io (void)
381+{
382+ sigset_t sigio_set;
383+ sigemptyset (&sigio_set);
384+ sigaddset (&sigio_set, SIGIO);
385+ sigprocmask (SIG_UNBLOCK, &sigio_set, NULL);
386+}
387+
388+void
369389 enable_async_io (void)
370390 {
371391 signal (SIGIO, input_interrupt);
@@ -487,9 +507,10 @@ write_ok (char *buf)
487507 void
488508 write_enn (char *buf)
489509 {
510+ /* Some day, we should define the meanings of the error codes... */
490511 buf[0] = 'E';
491- buf[1] = 'N';
492- buf[2] = 'N';
512+ buf[1] = '0';
513+ buf[2] = '1';
493514 buf[3] = '\0';
494515 }
495516
@@ -609,7 +630,11 @@ prepare_resume_reply (char *buf, char status, unsigned char signo)
609630 thread_from_wait = ((struct inferior_list_entry *)current_inferior)->id;
610631 if (debug_threads)
611632 fprintf (stderr, "Writing resume reply for %d\n\n", thread_from_wait);
612- if (old_thread_from_wait != thread_from_wait)
633+ /* This if (1) ought to be unnecessary. But remote_wait in GDB
634+ will claim this event belongs to inferior_ptid if we do not
635+ specify a thread, and there's no way for gdbserver to know
636+ what inferior_ptid is. */
637+ if (1 || old_thread_from_wait != thread_from_wait)
613638 {
614639 general_thread = thread_from_wait;
615640 sprintf (buf, "thread:%x;", thread_from_wait);
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -1,5 +1,5 @@
11 /* Main code for remote server for GDB.
2- Copyright 1989, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2002
2+ Copyright 1989, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2002, 2003, 2004
33 Free Software Foundation, Inc.
44
55 This file is part of GDB.
@@ -70,6 +70,8 @@ attach_inferior (int pid, char *statusptr, unsigned char *sigptr)
7070 if (myattach (pid) != 0)
7171 return -1;
7272
73+ fprintf (stderr, "Attached; pid = %d\n", pid);
74+
7375 /* FIXME - It may be that we should get the SIGNAL_PID from the
7476 attach function, so that it can be the main thread instead of
7577 whichever we were told to attach to. */
@@ -104,7 +106,7 @@ handle_query (char *own_buf)
104106 thread_ptr = thread_ptr->next;
105107 return;
106108 }
107-
109+
108110 if (strcmp ("qsThreadInfo", own_buf) == 0)
109111 {
110112 if (thread_ptr != NULL)
@@ -119,10 +121,180 @@ handle_query (char *own_buf)
119121 return;
120122 }
121123 }
122-
124+
125+ if (the_target->read_auxv != NULL
126+ && strncmp ("qPart:auxv:read::", own_buf, 17) == 0)
127+ {
128+ char data[(PBUFSIZ - 1) / 2];
129+ CORE_ADDR ofs;
130+ unsigned int len;
131+ int n;
132+ decode_m_packet (&own_buf[17], &ofs, &len); /* "OFS,LEN" */
133+ if (len > sizeof data)
134+ len = sizeof data;
135+ n = (*the_target->read_auxv) (ofs, data, len);
136+ if (n == 0)
137+ write_ok (own_buf);
138+ else if (n < 0)
139+ write_enn (own_buf);
140+ else
141+ convert_int_to_ascii (data, own_buf, n);
142+ return;
143+ }
144+
145+ /* Otherwise we didn't know what packet it was. Say we didn't
146+ understand it. */
147+ own_buf[0] = 0;
148+}
149+
150+/* Parse vCont packets. */
151+void
152+handle_v_cont (char *own_buf, char *status, unsigned char *signal)
153+{
154+ char *p, *q;
155+ int n = 0, i = 0;
156+ struct thread_resume *resume_info, default_action;
157+
158+ /* Count the number of semicolons in the packet. There should be one
159+ for every action. */
160+ p = &own_buf[5];
161+ while (p)
162+ {
163+ n++;
164+ p++;
165+ p = strchr (p, ';');
166+ }
167+ /* Allocate room for one extra action, for the default remain-stopped
168+ behavior; if no default action is in the list, we'll need the extra
169+ slot. */
170+ resume_info = malloc ((n + 1) * sizeof (resume_info[0]));
171+
172+ default_action.thread = -1;
173+ default_action.leave_stopped = 1;
174+ default_action.step = 0;
175+ default_action.sig = 0;
176+
177+ p = &own_buf[5];
178+ i = 0;
179+ while (*p)
180+ {
181+ p++;
182+
183+ resume_info[i].leave_stopped = 0;
184+
185+ if (p[0] == 's' || p[0] == 'S')
186+ resume_info[i].step = 1;
187+ else if (p[0] == 'c' || p[0] == 'C')
188+ resume_info[i].step = 0;
189+ else
190+ goto err;
191+
192+ if (p[0] == 'S' || p[0] == 'C')
193+ {
194+ int sig;
195+ sig = strtol (p + 1, &q, 16);
196+ if (p == q)
197+ goto err;
198+ p = q;
199+
200+ if (!target_signal_to_host_p (sig))
201+ goto err;
202+ resume_info[i].sig = target_signal_to_host (sig);
203+ }
204+ else
205+ {
206+ resume_info[i].sig = 0;
207+ p = p + 1;
208+ }
209+
210+ if (p[0] == 0)
211+ {
212+ resume_info[i].thread = -1;
213+ default_action = resume_info[i];
214+
215+ /* Note: we don't increment i here, we'll overwrite this entry
216+ the next time through. */
217+ }
218+ else if (p[0] == ':')
219+ {
220+ resume_info[i].thread = strtol (p + 1, &q, 16);
221+ if (p == q)
222+ goto err;
223+ p = q;
224+ if (p[0] != ';' && p[0] != 0)
225+ goto err;
226+
227+ i++;
228+ }
229+ }
230+
231+ resume_info[i] = default_action;
232+
233+ /* Still used in occasional places in the backend. */
234+ if (n == 1 && resume_info[0].thread != -1)
235+ cont_thread = resume_info[0].thread;
236+ else
237+ cont_thread = -1;
238+ set_desired_inferior (0);
239+
240+ (*the_target->resume) (resume_info);
241+
242+ free (resume_info);
243+
244+ *signal = mywait (status, 1);
245+ prepare_resume_reply (own_buf, *status, *signal);
246+ return;
247+
248+err:
249+ /* No other way to report an error... */
250+ strcpy (own_buf, "");
251+ free (resume_info);
252+ return;
253+}
254+
255+/* Handle all of the extended 'v' packets. */
256+void
257+handle_v_requests (char *own_buf, char *status, unsigned char *signal)
258+{
259+ if (strncmp (own_buf, "vCont;", 6) == 0)
260+ {
261+ handle_v_cont (own_buf, status, signal);
262+ return;
263+ }
264+
265+ if (strncmp (own_buf, "vCont?", 6) == 0)
266+ {
267+ strcpy (own_buf, "vCont;c;C;s;S");
268+ return;
269+ }
270+
123271 /* Otherwise we didn't know what packet it was. Say we didn't
124272 understand it. */
125273 own_buf[0] = 0;
274+ return;
275+}
276+
277+void
278+myresume (int step, int sig)
279+{
280+ struct thread_resume resume_info[2];
281+ int n = 0;
282+
283+ if (step || sig || cont_thread > 0)
284+ {
285+ resume_info[0].thread
286+ = ((struct inferior_list_entry *) current_inferior)->id;
287+ resume_info[0].step = step;
288+ resume_info[0].sig = sig;
289+ resume_info[0].leave_stopped = 0;
290+ n++;
291+ }
292+ resume_info[n].thread = -1;
293+ resume_info[n].step = 0;
294+ resume_info[n].sig = 0;
295+ resume_info[n].leave_stopped = (cont_thread > 0);
296+
297+ (*the_target->resume) (resume_info);
126298 }
127299
128300 static int attached;
@@ -222,7 +394,7 @@ main (int argc, char *argv[])
222394 detach_inferior ();
223395 write_ok (own_buf);
224396 putpkt (own_buf);
225- remote_close ();
397+ remote_close ();
226398
227399 /* If we are attached, then we can exit. Otherwise, we need to
228400 hang around doing nothing, until the child is gone. */
@@ -290,8 +462,10 @@ main (int argc, char *argv[])
290462 break;
291463 case 'm':
292464 decode_m_packet (&own_buf[1], &mem_addr, &len);
293- read_inferior_memory (mem_addr, mem_buf, len);
294- convert_int_to_ascii (mem_buf, own_buf, len);
465+ if (read_inferior_memory (mem_addr, mem_buf, len) == 0)
466+ convert_int_to_ascii (mem_buf, own_buf, len);
467+ else
468+ write_enn (own_buf);
295469 break;
296470 case 'M':
297471 decode_M_packet (&own_buf[1], &mem_addr, &len, mem_buf);
@@ -383,6 +557,10 @@ main (int argc, char *argv[])
383557 own_buf[0] = '\0';
384558 break;
385559 }
560+ case 'v':
561+ /* Extended (long) request. */
562+ handle_v_requests (own_buf, &status, &signal);
563+ break;
386564 default:
387565 /* It is a request we don't understand. Respond with an
388566 empty packet so that gdb knows that we don't support this
@@ -395,9 +573,10 @@ main (int argc, char *argv[])
395573
396574 if (status == 'W')
397575 fprintf (stderr,
398- "\nChild exited with status %d\n", sig);
576+ "\nChild exited with status %d\n", signal);
399577 if (status == 'X')
400- fprintf (stderr, "\nChild terminated with signal = 0x%x\n", sig);
578+ fprintf (stderr, "\nChild terminated with signal = 0x%x\n",
579+ signal);
401580 if (status == 'W' || status == 'X')
402581 {
403582 if (extended_protocol)
--- a/gdb/gdbserver/server.h
+++ b/gdb/gdbserver/server.h
@@ -1,5 +1,5 @@
11 /* Common definitions for remote server for GDB.
2- Copyright 1993, 1995, 1997, 1998, 1999, 2000, 2002
2+ Copyright 1993, 1995, 1997, 1998, 1999, 2000, 2002, 2003, 2004
33 Free Software Foundation, Inc.
44
55 This file is part of GDB.
@@ -134,6 +134,8 @@ void write_ok (char *buf);
134134 void write_enn (char *buf);
135135 void enable_async_io (void);
136136 void disable_async_io (void);
137+void unblock_async_io (void);
138+void block_async_io (void);
137139 void convert_ascii_to_int (char *from, char *to, int n);
138140 void convert_int_to_ascii (char *from, char *to, int n);
139141 void new_thread_notify (int id);
--- a/gdb/gdbserver/target.c
+++ b/gdb/gdbserver/target.c
@@ -1,5 +1,5 @@
11 /* Target operations for the remote server for GDB.
2- Copyright 2002
2+ Copyright 2002, 2004
33 Free Software Foundation, Inc.
44
55 Contributed by MontaVista Software.
@@ -57,11 +57,13 @@ set_desired_inferior (int use_general)
5757 current_inferior = found;
5858 }
5959
60-void
60+int
6161 read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
6262 {
63- (*the_target->read_memory) (memaddr, myaddr, len);
63+ int res;
64+ res = (*the_target->read_memory) (memaddr, myaddr, len);
6465 check_mem_read (memaddr, myaddr, len);
66+ return res;
6567 }
6668
6769 int
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -1,5 +1,5 @@
11 /* Target operations for the remote server for GDB.
2- Copyright 2002
2+ Copyright 2002, 2003, 2004
33 Free Software Foundation, Inc.
44
55 Contributed by MontaVista Software.
@@ -24,6 +24,25 @@
2424 #ifndef TARGET_H
2525 #define TARGET_H
2626
27+/* This structure describes how to resume a particular thread (or
28+ all threads) based on the client's request. If thread is -1, then
29+ this entry applies to all threads. These are generally passed around
30+ as an array, and terminated by a thread == -1 entry. */
31+
32+struct thread_resume
33+{
34+ int thread;
35+
36+ /* If non-zero, leave this thread stopped. */
37+ int leave_stopped;
38+
39+ /* If non-zero, we want to single-step. */
40+ int step;
41+
42+ /* If non-zero, send this signal when we resume. */
43+ int sig;
44+};
45+
2746 struct target_ops
2847 {
2948 /* Start a new process.
@@ -56,14 +75,9 @@ struct target_ops
5675
5776 int (*thread_alive) (int pid);
5877
59- /* Resume the inferior process.
60-
61- If STEP is non-zero, we want to single-step.
62-
63- If SIGNAL is nonzero, send the process that signal as we resume it.
64- */
78+ /* Resume the inferior process. */
6579
66- void (*resume) (int step, int signo);
80+ void (*resume) (struct thread_resume *resume_info);
6781
6882 /* Wait for the inferior process to change state.
6983
@@ -78,7 +92,7 @@ struct target_ops
7892 If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */
7993
8094 void (*fetch_registers) (int regno);
81-
95+
8296 /* Store registers to the inferior process.
8397
8498 If REGNO is -1, store all registers; otherwise, store at least REGNO. */
@@ -88,9 +102,11 @@ struct target_ops
88102 /* Read memory from the inferior process. This should generally be
89103 called through read_inferior_memory, which handles breakpoint shadowing.
90104
91- Read LEN bytes at MEMADDR into a buffer at MYADDR. */
105+ Read LEN bytes at MEMADDR into a buffer at MYADDR.
106+
107+ Returns 0 on success and errno on failure. */
92108
93- void (*read_memory) (CORE_ADDR memaddr, char *myaddr, int len);
109+ int (*read_memory) (CORE_ADDR memaddr, char *myaddr, int len);
94110
95111 /* Write memory to the inferior process. This should generally be
96112 called through write_inferior_memory, which handles breakpoint shadowing.
@@ -111,6 +127,12 @@ struct target_ops
111127
112128 /* Send a signal to the inferior process, however is appropriate. */
113129 void (*send_signal) (int);
130+
131+ /* Read auxiliary vector data from the inferior process.
132+
133+ Read LEN bytes at OFFSET into a buffer at MYADDR. */
134+
135+ int (*read_auxv) (CORE_ADDR offset, char *myaddr, unsigned int len);
114136 };
115137
116138 extern struct target_ops *the_target;
@@ -132,9 +154,6 @@ void set_target_ops (struct target_ops *);
132154 #define mythread_alive(pid) \
133155 (*the_target->thread_alive) (pid)
134156
135-#define myresume(step,signo) \
136- (*the_target->resume) (step, signo)
137-
138157 #define fetch_inferior_registers(regno) \
139158 (*the_target->fetch_registers) (regno)
140159
@@ -143,7 +162,7 @@ void set_target_ops (struct target_ops *);
143162
144163 unsigned char mywait (char *statusp, int connected_wait);
145164
146-void read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len);
165+int read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len);
147166
148167 int write_inferior_memory (CORE_ADDR memaddr, const char *myaddr, int len);
149168
--- a/gdb/gdbserver/utils.c
+++ b/gdb/gdbserver/utils.c
@@ -1,5 +1,5 @@
11 /* General utility routines for the remote server for GDB.
2- Copyright 1986, 1989, 1993, 1995, 1996, 1997, 1999, 2000, 2002
2+ Copyright 1986, 1989, 1993, 1995, 1996, 1997, 1999, 2000, 2002, 2003
33 Free Software Foundation, Inc.
44
55 This file is part of GDB.