Initial revision
[openwrt.git] / toolchain / gdb / 5.3 / 050-debian-subset.patch
1 Patch pending upstream, probably acceptable.
2 --------------------------------------------
3
4
5
6 Daniel Jacobowitz <drow@mvista.com> writes:
7 > I like this.  The way func_frame_chain_valid should really be used is
8 > by something like:
9
10 >   /* NOTE: tm-i386nw.h and tm-i386v4.h override this.  */
11 >   set_gdbarch_frame_chain_valid (gdbarch, file_frame_chain_valid);
12
13 > (copied from i386-tdep.c).
14
15 > Does this patch work for you?
16
17 Yes, thanks.  I've included a revised version of my patch below.
18
19 > I'm curious as to why we can't just set this universally, or at least a
20 > little more globally.  Most things that have a main () use it as a
21 > normal main ().  I'd propose that we set it as the default frame chain,
22 > and provide/document an option to ignore inside_main_func.
23
24 Well, gdbarch is never supposed to change the default behavior of
25 macros; this helps us convert pre-gdbarch targets incrementally.
26 Simply turning on gdbarch for one's target ideally wouldn't change its
27 behavior at all.
28
29
30 [Patch revised for Debian snapshot]
31 --- snap/gdb/i386-linux-tdep.c.orig     2002-08-18 19:53:57.000000000 -0400
32 +++ snap/gdb/i386-linux-tdep.c  2002-08-18 19:54:31.000000000 -0400
33 @@ -452,6 +452,9 @@
34  
35    set_solib_svr4_fetch_link_map_offsets (gdbarch,
36                                        i386_linux_svr4_fetch_link_map_offsets);
37 +
38 +  set_gdbarch_frame_chain_valid (gdbarch,
39 +                                generic_func_frame_chain_valid);
40  }
41  
42  /* Provide a prototype to silence -Wmissing-prototypes.  */
43 [Hurd needs 6.  Take 8, since it does no real harm.]
44
45
46 Package: gdb
47 Severity: normal
48 Tags: patch, sid
49
50 Hello,
51
52 GDB will crash on the Hurd after issuing the 'show' and hitting enter
53 a few times:
54
55 ../../gdb/ui-out.c:130: gdb-internal-error: push_level: Assertion       +`uiout->level >= 0 && uiout->level < MAX_UI_OUT_LEVELS' failed.
56
57 the problem is that MAX_UI_OUT_LEVELS is not high enough for the extra
58 option we have on the Hurd, it should be rised to 6 then, which works
59 fine:
60
61 --- gdb-5.2.cvs20020401/gdb/ui-out.c~   Fri May  3 02:19:20 2002
62 +++ gdb-5.2.cvs20020401/gdb/ui-out.c    Fri May  3 02:19:32 2002
63 @@ -45,7 +45,7 @@
64     is always available.  Stack/nested level 0 is reserved for the
65     top-level result. */
66  
67 -enum { MAX_UI_OUT_LEVELS = 5 };
68 +enum { MAX_UI_OUT_LEVELS = 8 };
69  
70  struct ui_out_level
71    {
72
73 -- 
74 Robert Millan
75
76 "5 years from now everyone will be running
77 free GNU on their 200 MIPS, 64M SPARCstation-5"
78
79               Andrew S. Tanenbaum, 30 Jan 1992
80
81
82 Submitted upstream, not liked very much.  It's a hack, but it will do for
83 now.
84
85 2002-07-31  Daniel Jacobowitz  <drow@mvista.com>
86
87         Fix PR gdb/568
88         * thread-db.c (lwp_from_thread): Only warn if unable to find
89         the thread.
90
91 Index: thread-db.c
92 ===================================================================
93 RCS file: /cvs/src/src/gdb/thread-db.c,v
94 retrieving revision 1.22
95 diff -u -p -r1.22 thread-db.c
96 --- gdb/gdb/thread-db.c 23 Mar 2002 17:38:13 -0000      1.22
97 +++ gdb/gdb/thread-db.c 31 Jul 2002 16:29:52 -0000
98 @@ -260,6 +260,12 @@ lwp_from_thread (ptid_t ptid)
99      return ptid;
100  
101    err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th);
102 +  if (err == TD_ERR)
103 +    {
104 +      warning ("Cannot find thread %ld: %s",
105 +              (long) GET_THREAD (ptid), thread_db_err_str (err));
106 +      return ptid;
107 +    }
108    if (err != TD_OK)
109      error ("Cannot find thread %ld: %s",
110            (long) GET_THREAD (ptid), thread_db_err_str (err));
111 From Michael Fedrowitz <michaelf@debian.org>.  Not submitted to FSF yet.
112
113  Hi,
114
115 gdb fails to build from source on m68k because some definitions have
116 been removed from tm-m68k.h. The patch below readds them.
117
118 -Michael
119
120
121 diff -urN gdb-5.2.cvs20020818.orig/gdb/config/m68k/tm-m68k.h gdb-5.2.cvs20020818/gdb/config/m68k/tm-m68k.h
122 --- gdb-5.2.cvs20020818.orig/gdb/config/m68k/tm-m68k.h  2002-07-10 19:01:38.000000000 +0200
123 +++ gdb-5.2.cvs20020818/gdb/config/m68k/tm-m68k.h       2002-10-06 18:01:59.000000000 +0200
124 @@ -26,8 +26,11 @@
125  /* Generic 68000 stuff, to be included by other tm-*.h files.  */
126  
127  /* D0_REGNM and A0_REGNUM must be defined here because they are
128 -   used by the monitor.  */
129 +   used by the monitor. FPC_REGNUM, FPS_REGNUM and FPI_REGNUM are
130 +   defined here because they are used by m68klinux-nat.c.  */
131  
132  #define D0_REGNUM 0
133  #define A0_REGNUM 8
134 -
135 +#define FPC_REGNUM 26
136 +#define FPS_REGNUM 27
137 +#define FPI_REGNUM 28
138
139
140 2002-11-24  Daniel Jacobowitz  <drow@mvista.com>
141
142         * doublest.c (convert_floatformat_to_doublest): Cast exp_bias to int.
143         * config/alpha/alpha-linux.mh (MH_CFLAGS): Add -mieee.
144
145 --- gdb-5.2.debian90.cvs20021120/gdb/doublest.c.orig    2002-11-24 17:48:16.000000000 -0500
146 +++ gdb-5.2.debian90.cvs20021120/gdb/doublest.c 2002-11-24 17:48:25.000000000 -0500
147 @@ -177,7 +177,7 @@
148    if (!special_exponent)
149      exponent -= fmt->exp_bias;
150    else if (exponent == 0)
151 -    exponent = 1 - fmt->exp_bias;
152 +    exponent = 1 - (int)fmt->exp_bias;
153  
154    /* Build the result algebraically.  Might go infinite, underflow, etc;
155       who cares. */
156 --- gdb-5.2.debian90.cvs20021120/gdb/config/alpha/alpha-linux.mh.orig   2002-11-24 17:50:30.000000000 -0500
157 +++ gdb-5.2.debian90.cvs20021120/gdb/config/alpha/alpha-linux.mh        2002-11-24 17:50:41.000000000 -0500
158 @@ -8,3 +8,5 @@
159  
160  MMALLOC = 
161  MMALLOC_CFLAGS = -DNO_MMALLOC 
162 +
163 +MH_CFLAGS = -mieee
164 In CVS but not in 5.3 branch...
165
166 2002-10-23  Daniel Jacobowitz  <drow@mvista.com>
167
168         * lin-lwp.c (lin_lwp_resume): Remove resume_all test for !step.
169
170 Index: lin-lwp.c
171 ===================================================================
172 RCS file: /cvs/src/src/gdb/lin-lwp.c,v
173 retrieving revision 1.35
174 diff -u -p -r1.35 lin-lwp.c
175 --- gdb-5.2.90/gdb/lin-lwp.c    27 Aug 2002 22:37:06 -0000      1.35
176 +++ gdb-5.2.90/gdb/lin-lwp.c    23 Oct 2002 04:23:13 -0000
177 @@ -579,11 +579,8 @@ lin_lwp_resume (ptid_t ptid, int step, e
178    struct lwp_info *lp;
179    int resume_all;
180  
181 -  /* Apparently the interpretation of PID is dependent on STEP: If
182 -     STEP is non-zero, a specific PID means `step only this process
183 -     id'.  But if STEP is zero, then PID means `continue *all*
184 -     processes, but give the signal only to this one'.  */
185 -  resume_all = (PIDGET (ptid) == -1) || !step;
186 +  /* A specific PTID means `step only this process id'.  */
187 +  resume_all = (PIDGET (ptid) == -1);
188  
189    if (resume_all)
190      iterate_over_lwps (resume_set_callback, NULL);
191
192 Not submitted yet, testing.
193
194 --- gdb-5.2.90/gdb/alpha-tdep.c.orig    Sun Nov 24 21:42:53 2002
195 +++ gdb-5.2.90/gdb/alpha-tdep.c Sun Nov 24 21:48:26 2002
196 @@ -99,10 +99,12 @@
197  
198  static alpha_extra_func_info_t heuristic_proc_desc (CORE_ADDR,
199                                                     CORE_ADDR,
200 -                                                   struct frame_info *);
201 +                                                   struct frame_info *,
202 +                                                   int);
203  
204  static alpha_extra_func_info_t find_proc_desc (CORE_ADDR,
205 -                                              struct frame_info *);
206 +                                              struct frame_info *,
207 +                                              int);
208  
209  #if 0
210  static int alpha_in_lenient_prologue (CORE_ADDR, CORE_ADDR);
211 @@ -512,7 +514,7 @@
212    if (tmp != 0)
213      pc = tmp;
214  
215 -  proc_desc = find_proc_desc (pc, frame->next);
216 +  proc_desc = find_proc_desc (pc, frame->next, 1);
217    pcreg = proc_desc ? PROC_PC_REG (proc_desc) : ALPHA_RA_REGNUM;
218  
219    if (frame->signal_handler_caller)
220 @@ -596,10 +598,10 @@
221  
222  static alpha_extra_func_info_t
223  heuristic_proc_desc (CORE_ADDR start_pc, CORE_ADDR limit_pc,
224 -                    struct frame_info *next_frame)
225 +                    struct frame_info *next_frame, int read_sp_p)
226  {
227 -  CORE_ADDR sp = read_next_frame_reg (next_frame, SP_REGNUM);
228 -  CORE_ADDR vfp = sp;
229 +  CORE_ADDR sp;
230 +  CORE_ADDR vfp;
231    CORE_ADDR cur_pc;
232    int frame_size;
233    int has_frame_reg = 0;
234 @@ -607,6 +609,11 @@
235    int pcreg = -1;
236    int regno;
237  
238 +  if (read_sp_p)
239 +    vfp = sp = read_next_frame_reg (next_frame, SP_REGNUM);
240 +  else
241 +    vfp = sp = 0;
242 +
243    if (start_pc == 0)
244      return NULL;
245    memset (&temp_proc_desc, '\0', sizeof (temp_proc_desc));
246 @@ -761,7 +768,7 @@
247    CORE_ADDR func_addr, func_end;
248  
249    if (!proc_desc)
250 -    proc_desc = find_proc_desc (pc, NULL);
251 +    proc_desc = find_proc_desc (pc, NULL, 0);
252  
253    if (proc_desc)
254      {
255 @@ -807,7 +814,7 @@
256  }
257  
258  static alpha_extra_func_info_t
259 -find_proc_desc (CORE_ADDR pc, struct frame_info *next_frame)
260 +find_proc_desc (CORE_ADDR pc, struct frame_info *next_frame, int read_sp_p)
261  {
262    alpha_extra_func_info_t proc_desc;
263    struct block *b;
264 @@ -879,7 +886,7 @@
265             {
266               alpha_extra_func_info_t found_heuristic =
267               heuristic_proc_desc (PROC_LOW_ADDR (proc_desc),
268 -                                  pc, next_frame);
269 +                                  pc, next_frame, read_sp_p);
270               if (found_heuristic)
271                 {
272                   PROC_LOCALOFF (found_heuristic) =
273 @@ -921,7 +928,7 @@
274         startaddr = heuristic_proc_start (pc);
275  
276        proc_desc =
277 -       heuristic_proc_desc (startaddr, pc, next_frame);
278 +       heuristic_proc_desc (startaddr, pc, next_frame, read_sp_p);
279      }
280    return proc_desc;
281  }
282 @@ -937,7 +944,7 @@
283    if (saved_pc == 0 || inside_entry_file (saved_pc))
284      return 0;
285  
286 -  proc_desc = find_proc_desc (saved_pc, frame);
287 +  proc_desc = find_proc_desc (saved_pc, frame, 1);
288    if (!proc_desc)
289      return 0;
290  
291 @@ -979,7 +986,7 @@
292  {
293    /* Use proc_desc calculated in frame_chain */
294    alpha_extra_func_info_t proc_desc =
295 -  frame->next ? cached_proc_desc : find_proc_desc (frame->pc, frame->next);
296 +  frame->next ? cached_proc_desc : find_proc_desc (frame->pc, frame->next, 1);
297  
298    frame->extra_info = (struct frame_extra_info *)
299      frame_obstack_alloc (sizeof (struct frame_extra_info));
300 @@ -1291,7 +1298,7 @@
301    /* we need proc_desc to know how to restore the registers;
302       if it is NULL, construct (a temporary) one */
303    if (proc_desc == NULL)
304 -    proc_desc = find_proc_desc (frame->pc, frame->next);
305 +    proc_desc = find_proc_desc (frame->pc, frame->next, 1);
306  
307    /* Question: should we copy this proc_desc and save it in
308       frame->proc_desc?  If we do, who will free it?
309 Not yet submitted upstream.  This requires some serious thinking about. 
310 If the target stack worked in any logical way, this wouldn't be necessary...
311 ending up with roughly:
312   thread_stratum: thread-db (silent reference to lin-lwp)
313   core_stratum: corelow
314   exec_stratum: exec
315   dummy_stratum: dummy
316 just makes no sense.
317
318 This patch fixes debugging threaded applications which are statically linked
319 without breaking debugging threaded core files.  It also fixes the PIDs in
320 generate-core-file'd corefiles.  Mostly.
321
322 diff -x '*~' -ur o/gdb-5.2.debian90.cvs20021120/gdb/corelow.c gdb-5.2.debian90.cvs20021120/gdb/corelow.c
323 --- o/gdb-5.2.debian90.cvs20021120/gdb/corelow.c        2002-09-18 13:23:15.000000000 -0400
324 +++ gdb-5.2.debian90.cvs20021120/gdb/corelow.c  2002-12-03 14:03:32.000000000 -0500
325 @@ -350,7 +350,7 @@
326    bfd_map_over_sections (core_bfd, add_to_thread_list,
327                          bfd_get_section_by_name (core_bfd, ".reg"));
328  
329 -  if (ontop)
330 +  if (ontop || 1)
331      {
332        /* Fetch all registers from core file.  */
333        target_fetch_registers (-1);
334 diff -x '*~' -ur o/gdb-5.2.debian90.cvs20021120/gdb/linux-proc.c gdb-5.2.debian90.cvs20021120/gdb/linux-proc.c
335 --- o/gdb-5.2.debian90.cvs20021120/gdb/linux-proc.c     2002-12-03 14:13:52.000000000 -0500
336 +++ gdb-5.2.debian90.cvs20021120/gdb/linux-proc.c       2002-12-03 13:56:34.000000000 -0500
337 @@ -177,7 +177,7 @@
338  #ifdef FILL_FPXREGSET
339    gdb_fpxregset_t fpxregs;
340  #endif
341 -  unsigned long merged_pid = ptid_get_tid (ptid) << 16 | ptid_get_pid (ptid);
342 +  unsigned long merged_pid = ptid_get_tid (ptid) << 16; /*  | ptid_get_pid (ptid); */
343  
344    fill_gregset (&gregs, -1);
345    note_data = (char *) elfcore_write_prstatus (obfd, 
346 diff -x '*~' -ur o/gdb-5.2.debian90.cvs20021120/gdb/target.c gdb-5.2.debian90.cvs20021120/gdb/target.c
347 --- o/gdb-5.2.debian90.cvs20021120/gdb/target.c 2002-09-18 13:23:22.000000000 -0400
348 +++ gdb-5.2.debian90.cvs20021120/gdb/target.c   2002-12-03 14:06:07.000000000 -0500
349 @@ -1589,6 +1589,7 @@
350    dummy_target.to_find_memory_regions = dummy_find_memory_regions;
351    dummy_target.to_make_corefile_notes = dummy_make_corefile_notes;
352    dummy_target.to_magic = OPS_MAGIC;
353 +  cleanup_target (&dummy_target);
354  }
355  \f
356  
357 diff -x '*~' -ur o/gdb-5.2.debian90.cvs20021120/gdb/thread-db.c gdb-5.2.debian90.cvs20021120/gdb/thread-db.c
358 --- o/gdb-5.2.debian90.cvs20021120/gdb/thread-db.c      2002-12-03 14:13:50.000000000 -0500
359 +++ gdb-5.2.debian90.cvs20021120/gdb/thread-db.c        2002-12-03 13:39:54.000000000 -0500
360 @@ -57,6 +57,31 @@
361  /* Non-zero if we're using this module's target vector.  */
362  static int using_thread_db;
363  
364 +/* Macros to pass an event to the next target if we should not be handling it
365 +   here in the thread_stratum.  */
366 +#define FIND_NEXT_TARGET(METHOD_NAME)                  \
367 +  struct target_ops *next_target = &thread_db_ops;     \
368 +  while (1)                                            \
369 +    {                                                  \
370 +      next_target = find_target_beneath (next_target); \
371 +      if (next_target->METHOD_NAME != NULL)            \
372 +       break;                                          \
373 +    }
374 +
375 +#define MAYBE_HAND_DOWN(METHOD_NAME,ARGS)              \
376 +  if (proc_handle.pid == 0)                            \
377 +    {                                                  \
378 +      FIND_NEXT_TARGET (METHOD_NAME);                  \
379 +      (*next_target->METHOD_NAME) ARGS;                        \
380 +      return;                                          \
381 +    }
382 +#define MAYBE_HAND_DOWN_RETURN(METHOD_NAME,ARGS)       \
383 +  if (proc_handle.pid == 0)                            \
384 +    {                                                  \
385 +      FIND_NEXT_TARGET (METHOD_NAME);                  \
386 +      return (*next_target->METHOD_NAME) ARGS;         \
387 +    }
388 +
389  /* Non-zero if we have to keep this module's target vector active
390     across re-runs.  */
391  static int keep_thread_db;
392 @@ -489,9 +514,7 @@
393  {
394    td_err_e err;
395  
396 -  /* Don't attempt to use thread_db on targets which can not run
397 -     (core files).  */
398 -  if (objfile == NULL || !target_has_execution)
399 +  if (objfile == NULL)
400      {
401        /* All symbols have been discarded.  If the thread_db target is
402           active, deactivate it now.  */
403 @@ -515,7 +538,10 @@
404    /* Initialize the structure that identifies the child process.  Note
405       that at this point there is no guarantee that we actually have a
406       child process.  */
407 -  proc_handle.pid = GET_PID (inferior_ptid);
408 +  if (target_has_execution)
409 +    proc_handle.pid = GET_PID (inferior_ptid);
410 +  else
411 +    proc_handle.pid = 0;
412  
413    /* Now attempt to open a connection to the thread library.  */
414    err = td_ta_new_p (&proc_handle, &thread_agent);
415 @@ -758,6 +784,9 @@
416    struct cleanup *old_chain = save_inferior_ptid ();
417    int xfer;
418  
419 +  MAYBE_HAND_DOWN_RETURN (to_xfer_memory, (memaddr, myaddr, len, write,
420 +                                          attrib, target));
421 +
422    if (is_thread (inferior_ptid))
423      {
424        /* FIXME: This seems to be necessary to make sure breakpoints
425 @@ -782,6 +811,8 @@
426    gdb_prfpregset_t fpregset;
427    td_err_e err;
428  
429 +  MAYBE_HAND_DOWN (to_fetch_registers, (regno));
430 +
431    if (!is_thread (inferior_ptid))
432      {
433        /* Pass the request to the target beneath us.  */
434 @@ -819,6 +850,8 @@
435    gdb_prfpregset_t fpregset;
436    td_err_e err;
437  
438 +  MAYBE_HAND_DOWN (to_store_registers, (regno));
439 +
440    if (!is_thread (inferior_ptid))
441      {
442        /* Pass the request to the target beneath us.  */
443 @@ -908,6 +941,8 @@
444    td_thrinfo_t ti;
445    td_err_e err;
446  
447 +  MAYBE_HAND_DOWN_RETURN (to_thread_alive, (ptid));
448 +
449    if (is_thread (ptid))
450      {
451        err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th);
452 @@ -961,6 +996,8 @@
453  {
454    td_err_e err;
455  
456 +  MAYBE_HAND_DOWN (to_find_new_threads, ());
457 +
458    /* Iterate over all user-space threads to discover new threads.  */
459    err = td_ta_thr_iter_p (thread_agent, find_new_threads_callback, NULL,
460                           TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY,
461 @@ -972,6 +1009,8 @@
462  static char *
463  thread_db_pid_to_str (ptid_t ptid)
464  {
465 +  MAYBE_HAND_DOWN_RETURN (to_pid_to_str, (ptid));
466 +
467    if (is_thread (ptid))
468      {
469        static char buf[64];
470 Trivial.  Need to submit this.
471
472 --- gdb-5.2.debian90.cvs20021120/gdb/tracepoint.c.orig  2002-12-03 14:35:44.000000000 -0500
473 +++ gdb-5.2.debian90.cvs20021120/gdb/tracepoint.c       2002-12-03 14:43:02.000000000 -0500
474 @@ -861,6 +861,8 @@
475        else
476         line = gdb_readline (0);
477  
478 +      if (line == NULL || *line == EOF)
479 +       break;
480        linetype = validate_actionline (&line, t);
481        if (linetype == BADLINE)
482         continue;               /* already warned -- collect another line */
483 Fix build on Sparc.
484
485 --- gdb-5.3/gdb/sparc-nat.c.orig        2003-01-04 00:11:28.000000000 -0500
486 +++ gdb-5.3/gdb/sparc-nat.c     2003-01-04 00:12:42.000000000 -0500
487 @@ -33,6 +33,13 @@
488  #include <sys/ptrace.h>
489  #include <sys/wait.h>
490  #ifdef __linux__
491 +/* Sadly, <sys/ucontext.h> conflicts with <asm/reg.h> on Linux.  And
492 +   -D_GNU_SOURCE brings in <sys/ucontext.h> implicitly with <signal.h>.
493 +   Hack around this.  */
494 +#undef FPU_REGS_TYPE
495 +#define fpu asm_reg_fpu
496 +#define fq asm_reg_fq
497 +#define fpq asm_reg_fpq
498  #include <asm/reg.h>
499  #else
500  #include <machine/reg.h>
501 diff -urN gdb-5.3/gdb/gdbserver.orig/gdbreplay.c gdb-5.3/gdb/gdbserver/gdbreplay.c
502 --- gdb-5.3/gdb/gdbserver.orig/gdbreplay.c      2002-07-09 11:38:58.000000000 -0600
503 +++ gdb-5.3/gdb/gdbserver/gdbreplay.c   2003-08-20 08:44:20.000000000 -0600
504 @@ -54,14 +54,15 @@
505  perror_with_name (char *string)
506  {
507  #ifndef STDC_HEADERS
508 -  extern int sys_nerr;
509    extern char *sys_errlist[];
510    extern int errno;
511  #endif
512    const char *err;
513    char *combined;
514  
515 -  err = (errno < sys_nerr) ? sys_errlist[errno] : "unknown error";
516 +  err = strerror (errno);
517 +  if (err == NULL)
518 +    err = "unknown error";
519    combined = (char *) alloca (strlen (err) + strlen (string) + 3);
520    strcpy (combined, string);
521    strcat (combined, ": ");
522 diff -urN gdb-5.3/gdb/gdbserver.orig/low-hppabsd.c gdb-5.3/gdb/gdbserver/low-hppabsd.c
523 --- gdb-5.3/gdb/gdbserver.orig/low-hppabsd.c    2002-01-17 14:13:49.000000000 -0700
524 +++ gdb-5.3/gdb/gdbserver/low-hppabsd.c 2003-08-20 08:46:04.000000000 -0600
525 @@ -61,7 +61,7 @@
526        execv (program, allargs);
527  
528        fprintf (stderr, "Cannot exec %s: %s.\n", program,
529 -              errno < sys_nerr ? sys_errlist[errno] : "unknown error");
530 +              strerror (errno));
531        fflush (stderr);
532        _exit (0177);
533      }
534 diff -urN gdb-5.3/gdb/gdbserver.orig/low-lynx.c gdb-5.3/gdb/gdbserver/low-lynx.c
535 --- gdb-5.3/gdb/gdbserver.orig/low-lynx.c       2002-01-17 14:13:49.000000000 -0700
536 +++ gdb-5.3/gdb/gdbserver/low-lynx.c    2003-08-20 08:46:18.000000000 -0600
537 @@ -79,7 +79,7 @@
538  
539        fprintf (stderr, "GDBserver (process %d):  Cannot exec %s: %s.\n",
540                getpid (), program,
541 -              errno < sys_nerr ? sys_errlist[errno] : "unknown error");
542 +              strerror (errno));
543        fflush (stderr);
544        _exit (0177);
545      }
546 diff -urN gdb-5.3/gdb/gdbserver.orig/low-nbsd.c gdb-5.3/gdb/gdbserver/low-nbsd.c
547 --- gdb-5.3/gdb/gdbserver.orig/low-nbsd.c       2002-01-17 14:13:49.000000000 -0700
548 +++ gdb-5.3/gdb/gdbserver/low-nbsd.c    2003-08-20 08:46:27.000000000 -0600
549 @@ -137,7 +137,7 @@
550        execv (program, allargs);
551  
552        fprintf (stderr, "Cannot exec %s: %s.\n", program,
553 -              errno < sys_nerr ? sys_errlist[errno] : "unknown error");
554 +              strerror (errno));
555        fflush (stderr);
556        _exit (0177);
557      }
558 diff -urN gdb-5.3/gdb/gdbserver.orig/low-sparc.c gdb-5.3/gdb/gdbserver/low-sparc.c
559 --- gdb-5.3/gdb/gdbserver.orig/low-sparc.c      2002-01-17 14:13:50.000000000 -0700
560 +++ gdb-5.3/gdb/gdbserver/low-sparc.c   2003-08-20 08:46:38.000000000 -0600
561 @@ -44,7 +44,6 @@
562  #include <sys/ptrace.h>
563  #include <sys/reg.h>
564  
565 -extern int sys_nerr;
566  extern char **sys_errlist;
567  extern int errno;
568  
569 @@ -67,7 +66,7 @@
570        execv (program, allargs);
571  
572        fprintf (stderr, "Cannot exec %s: %s.\n", program,
573 -              errno < sys_nerr ? sys_errlist[errno] : "unknown error");
574 +              strerror (errno));
575        fflush (stderr);
576        _exit (0177);
577      }
578 diff -urN gdb-5.3/gdb/gdbserver.orig/low-sun3.c gdb-5.3/gdb/gdbserver/low-sun3.c
579 --- gdb-5.3/gdb/gdbserver.orig/low-sun3.c       2002-01-17 14:13:50.000000000 -0700
580 +++ gdb-5.3/gdb/gdbserver/low-sun3.c    2003-08-20 08:46:51.000000000 -0600
581 @@ -41,7 +41,6 @@
582  #include <sys/ptrace.h>
583  #include <machine/reg.h>
584  
585 -extern int sys_nerr;
586  extern char **sys_errlist;
587  extern int errno;
588  
589 @@ -64,7 +63,7 @@
590        execv (program, allargs);
591  
592        fprintf (stderr, "Cannot exec %s: %s.\n", program,
593 -              errno < sys_nerr ? sys_errlist[errno] : "unknown error");
594 +              strerror (errno));
595        fflush (stderr);
596        _exit (0177);
597      }
598 diff -urN gdb-5.3/gdb/gdbserver.orig/utils.c gdb-5.3/gdb/gdbserver/utils.c
599 --- gdb-5.3/gdb/gdbserver.orig/utils.c  2003-08-20 08:47:56.000000000 -0600
600 +++ gdb-5.3/gdb/gdbserver/utils.c       2003-08-20 08:48:15.000000000 -0600
601 @@ -33,16 +33,13 @@
602  perror_with_name (char *string)
603  {
604  #ifndef STDC_HEADERS
605 -  extern int sys_nerr;
606 -  extern char *sys_errlist[];
607    extern int errno;
608  #endif
609    const char *err;
610    char *combined;
611  
612 -  if (errno < sys_nerr)
613 -    err = sys_errlist[errno];
614 -  else
615 +  err = strerror (errno);
616 +  if (err == NULL)
617      err = "unknown error";
618  
619    combined = (char *) alloca (strlen (err) + strlen (string) + 3);
620 diff -urN gdb-5.3/gdb/gdbserver.orig/linux-low.c.orig gdb-5.3/gdb/gdbserver/linux-low.c.orig
621 --- gdb-5.3/gdb/gdbserver.orig/linux-low.c      2003-08-20 08:40:27.000000000 -0600
622 +++ gdb-5.3/gdb/gdbserver/linux-low.c   2003-08-20 08:44:54.000000000 -0600
623 @@ -175,8 +175,7 @@
624    if (ptrace (PTRACE_ATTACH, pid, 0, 0) != 0)
625      {
626        fprintf (stderr, "Cannot attach to process %d: %s (%d)\n", pid,
627 -              errno < sys_nerr ? sys_errlist[errno] : "unknown error",
628 -              errno);
629 +              strerror (errno), errno);
630        fflush (stderr);
631  
632        /* If we fail to attach to an LWP, just return.  */
633