summaryrefslogtreecommitdiffstats
path: root/sources/gdb/5.3/050-debian-subset.patch
blob: e44b15ccdf2252d50ebdbb1084197aeac1eacfb7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
Patch pending upstream, probably acceptable.
--------------------------------------------



Daniel Jacobowitz <drow@mvista.com> writes:
> I like this.  The way func_frame_chain_valid should really be used is
> by something like:
> 
>   /* NOTE: tm-i386nw.h and tm-i386v4.h override this.  */
>   set_gdbarch_frame_chain_valid (gdbarch, file_frame_chain_valid);
> 
> (copied from i386-tdep.c).
> 
> Does this patch work for you?

Yes, thanks.  I've included a revised version of my patch below.

> I'm curious as to why we can't just set this universally, or at least a
> little more globally.  Most things that have a main () use it as a
> normal main ().  I'd propose that we set it as the default frame chain,
> and provide/document an option to ignore inside_main_func.

Well, gdbarch is never supposed to change the default behavior of
macros; this helps us convert pre-gdbarch targets incrementally.
Simply turning on gdbarch for one's target ideally wouldn't change its
behavior at all.


[Patch revised for Debian snapshot]
--- snap/gdb/i386-linux-tdep.c.orig	2002-08-18 19:53:57.000000000 -0400
+++ snap/gdb/i386-linux-tdep.c	2002-08-18 19:54:31.000000000 -0400
@@ -452,6 +452,9 @@
 
   set_solib_svr4_fetch_link_map_offsets (gdbarch,
 				       i386_linux_svr4_fetch_link_map_offsets);
+
+  set_gdbarch_frame_chain_valid (gdbarch,
+				 generic_func_frame_chain_valid);
 }
 
 /* Provide a prototype to silence -Wmissing-prototypes.  */
[Hurd needs 6.  Take 8, since it does no real harm.]


Package: gdb
Severity: normal
Tags: patch, sid

Hello,

GDB will crash on the Hurd after issuing the 'show' and hitting enter
a few times:

../../gdb/ui-out.c:130: gdb-internal-error: push_level: Assertion       +`uiout->level >= 0 && uiout->level < MAX_UI_OUT_LEVELS' failed.

the problem is that MAX_UI_OUT_LEVELS is not high enough for the extra
option we have on the Hurd, it should be rised to 6 then, which works
fine:

--- gdb-5.2.cvs20020401/gdb/ui-out.c~   Fri May  3 02:19:20 2002
+++ gdb-5.2.cvs20020401/gdb/ui-out.c    Fri May  3 02:19:32 2002
@@ -45,7 +45,7 @@
    is always available.  Stack/nested level 0 is reserved for the
    top-level result. */
 
-enum { MAX_UI_OUT_LEVELS = 5 };
+enum { MAX_UI_OUT_LEVELS = 8 };
 
 struct ui_out_level
   {

-- 
Robert Millan

"5 years from now everyone will be running
free GNU on their 200 MIPS, 64M SPARCstation-5"

              Andrew S. Tanenbaum, 30 Jan 1992


Submitted upstream, not liked very much.  It's a hack, but it will do for
now.

2002-07-31  Daniel Jacobowitz  <drow@mvista.com>

	Fix PR gdb/568
	* thread-db.c (lwp_from_thread): Only warn if unable to find
	the thread.

Index: thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/thread-db.c,v
retrieving revision 1.22
diff -u -p -r1.22 thread-db.c
--- gdb/gdb/thread-db.c	23 Mar 2002 17:38:13 -0000	1.22
+++ gdb/gdb/thread-db.c	31 Jul 2002 16:29:52 -0000
@@ -260,6 +260,12 @@ lwp_from_thread (ptid_t ptid)
     return ptid;
 
   err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th);
+  if (err == TD_ERR)
+    {
+      warning ("Cannot find thread %ld: %s",
+	       (long) GET_THREAD (ptid), thread_db_err_str (err));
+      return ptid;
+    }
   if (err != TD_OK)
     error ("Cannot find thread %ld: %s",
 	   (long) GET_THREAD (ptid), thread_db_err_str (err));
From Michael Fedrowitz <michaelf@debian.org>.  Not submitted to FSF yet.

 Hi,

gdb fails to build from source on m68k because some definitions have
been removed from tm-m68k.h. The patch below readds them.

-Michael


diff -urN gdb-5.2.cvs20020818.orig/gdb/config/m68k/tm-m68k.h gdb-5.2.cvs20020818/gdb/config/m68k/tm-m68k.h
--- gdb-5.2.cvs20020818.orig/gdb/config/m68k/tm-m68k.h	2002-07-10 19:01:38.000000000 +0200
+++ gdb-5.2.cvs20020818/gdb/config/m68k/tm-m68k.h	2002-10-06 18:01:59.000000000 +0200
@@ -26,8 +26,11 @@
 /* Generic 68000 stuff, to be included by other tm-*.h files.  */
 
 /* D0_REGNM and A0_REGNUM must be defined here because they are
-   used by the monitor.  */
+   used by the monitor. FPC_REGNUM, FPS_REGNUM and FPI_REGNUM are
+   defined here because they are used by m68klinux-nat.c.  */
 
 #define D0_REGNUM 0
 #define A0_REGNUM 8
-
+#define FPC_REGNUM 26
+#define FPS_REGNUM 27
+#define FPI_REGNUM 28


2002-11-24  Daniel Jacobowitz  <drow@mvista.com>

	* doublest.c (convert_floatformat_to_doublest): Cast exp_bias to int.
	* config/alpha/alpha-linux.mh (MH_CFLAGS): Add -mieee.

--- gdb-5.2.debian90.cvs20021120/gdb/doublest.c.orig	2002-11-24 17:48:16.000000000 -0500
+++ gdb-5.2.debian90.cvs20021120/gdb/doublest.c	2002-11-24 17:48:25.000000000 -0500
@@ -177,7 +177,7 @@
   if (!special_exponent)
     exponent -= fmt->exp_bias;
   else if (exponent == 0)
-    exponent = 1 - fmt->exp_bias;
+    exponent = 1 - (int)fmt->exp_bias;
 
   /* Build the result algebraically.  Might go infinite, underflow, etc;
      who cares. */
--- gdb-5.2.debian90.cvs20021120/gdb/config/alpha/alpha-linux.mh.orig	2002-11-24 17:50:30.000000000 -0500
+++ gdb-5.2.debian90.cvs20021120/gdb/config/alpha/alpha-linux.mh	2002-11-24 17:50:41.000000000 -0500
@@ -8,3 +8,5 @@
 
 MMALLOC = 
 MMALLOC_CFLAGS = -DNO_MMALLOC 
+
+MH_CFLAGS = -mieee
In CVS but not in 5.3 branch...

2002-10-23  Daniel Jacobowitz  <drow@mvista.com>

	* lin-lwp.c (lin_lwp_resume): Remove resume_all test for !step.

Index: lin-lwp.c
===================================================================
RCS file: /cvs/src/src/gdb/lin-lwp.c,v
retrieving revision 1.35
diff -u -p -r1.35 lin-lwp.c
--- gdb-5.2.90/gdb/lin-lwp.c	27 Aug 2002 22:37:06 -0000	1.35
+++ gdb-5.2.90/gdb/lin-lwp.c	23 Oct 2002 04:23:13 -0000
@@ -579,11 +579,8 @@ lin_lwp_resume (ptid_t ptid, int step, e
   struct lwp_info *lp;
   int resume_all;
 
-  /* Apparently the interpretation of PID is dependent on STEP: If
-     STEP is non-zero, a specific PID means `step only this process
-     id'.  But if STEP is zero, then PID means `continue *all*
-     processes, but give the signal only to this one'.  */
-  resume_all = (PIDGET (ptid) == -1) || !step;
+  /* A specific PTID means `step only this process id'.  */
+  resume_all = (PIDGET (ptid) == -1);
 
   if (resume_all)
     iterate_over_lwps (resume_set_callback, NULL);

Not submitted yet, testing.

--- gdb-5.2.90/gdb/alpha-tdep.c.orig	Sun Nov 24 21:42:53 2002
+++ gdb-5.2.90/gdb/alpha-tdep.c	Sun Nov 24 21:48:26 2002
@@ -99,10 +99,12 @@
 
 static alpha_extra_func_info_t heuristic_proc_desc (CORE_ADDR,
 						    CORE_ADDR,
-						    struct frame_info *);
+						    struct frame_info *,
+						    int);
 
 static alpha_extra_func_info_t find_proc_desc (CORE_ADDR,
-					       struct frame_info *);
+					       struct frame_info *,
+					       int);
 
 #if 0
 static int alpha_in_lenient_prologue (CORE_ADDR, CORE_ADDR);
@@ -512,7 +514,7 @@
   if (tmp != 0)
     pc = tmp;
 
-  proc_desc = find_proc_desc (pc, frame->next);
+  proc_desc = find_proc_desc (pc, frame->next, 1);
   pcreg = proc_desc ? PROC_PC_REG (proc_desc) : ALPHA_RA_REGNUM;
 
   if (frame->signal_handler_caller)
@@ -596,10 +598,10 @@
 
 static alpha_extra_func_info_t
 heuristic_proc_desc (CORE_ADDR start_pc, CORE_ADDR limit_pc,
-		     struct frame_info *next_frame)
+		     struct frame_info *next_frame, int read_sp_p)
 {
-  CORE_ADDR sp = read_next_frame_reg (next_frame, SP_REGNUM);
-  CORE_ADDR vfp = sp;
+  CORE_ADDR sp;
+  CORE_ADDR vfp;
   CORE_ADDR cur_pc;
   int frame_size;
   int has_frame_reg = 0;
@@ -607,6 +609,11 @@
   int pcreg = -1;
   int regno;
 
+  if (read_sp_p)
+    vfp = sp = read_next_frame_reg (next_frame, SP_REGNUM);
+  else
+    vfp = sp = 0;
+
   if (start_pc == 0)
     return NULL;
   memset (&temp_proc_desc, '\0', sizeof (temp_proc_desc));
@@ -761,7 +768,7 @@
   CORE_ADDR func_addr, func_end;
 
   if (!proc_desc)
-    proc_desc = find_proc_desc (pc, NULL);
+    proc_desc = find_proc_desc (pc, NULL, 0);
 
   if (proc_desc)
     {
@@ -807,7 +814,7 @@
 }
 
 static alpha_extra_func_info_t
-find_proc_desc (CORE_ADDR pc, struct frame_info *next_frame)
+find_proc_desc (CORE_ADDR pc, struct frame_info *next_frame, int read_sp_p)
 {
   alpha_extra_func_info_t proc_desc;
   struct block *b;
@@ -879,7 +886,7 @@
 	    {
 	      alpha_extra_func_info_t found_heuristic =
 	      heuristic_proc_desc (PROC_LOW_ADDR (proc_desc),
-				   pc, next_frame);
+				   pc, next_frame, read_sp_p);
 	      if (found_heuristic)
 		{
 		  PROC_LOCALOFF (found_heuristic) =
@@ -921,7 +928,7 @@
 	startaddr = heuristic_proc_start (pc);
 
       proc_desc =
-	heuristic_proc_desc (startaddr, pc, next_frame);
+	heuristic_proc_desc (startaddr, pc, next_frame, read_sp_p);
     }
   return proc_desc;
 }
@@ -937,7 +944,7 @@
   if (saved_pc == 0 || inside_entry_file (saved_pc))
     return 0;
 
-  proc_desc = find_proc_desc (saved_pc, frame);
+  proc_desc = find_proc_desc (saved_pc, frame, 1);
   if (!proc_desc)
     return 0;
 
@@ -979,7 +986,7 @@
 {
   /* Use proc_desc calculated in frame_chain */
   alpha_extra_func_info_t proc_desc =
-  frame->next ? cached_proc_desc : find_proc_desc (frame->pc, frame->next);
+  frame->next ? cached_proc_desc : find_proc_desc (frame->pc, frame->next, 1);
 
   frame->extra_info = (struct frame_extra_info *)
     frame_obstack_alloc (sizeof (struct frame_extra_info));
@@ -1291,7 +1298,7 @@
   /* we need proc_desc to know how to restore the registers;
      if it is NULL, construct (a temporary) one */
   if (proc_desc == NULL)
-    proc_desc = find_proc_desc (frame->pc, frame->next);
+    proc_desc = find_proc_desc (frame->pc, frame->next, 1);
 
   /* Question: should we copy this proc_desc and save it in
      frame->proc_desc?  If we do, who will free it?
Not yet submitted upstream.  This requires some serious thinking about. 
If the target stack worked in any logical way, this wouldn't be necessary...
ending up with roughly:
  thread_stratum: thread-db (silent reference to lin-lwp)
  core_stratum: corelow
  exec_stratum: exec
  dummy_stratum: dummy
just makes no sense.

This patch fixes debugging threaded applications which are statically linked
without breaking debugging threaded core files.  It also fixes the PIDs in
generate-core-file'd corefiles.  Mostly.

diff -x '*~' -ur o/gdb-5.2.debian90.cvs20021120/gdb/corelow.c gdb-5.2.debian90.cvs20021120/gdb/corelow.c
--- o/gdb-5.2.debian90.cvs20021120/gdb/corelow.c	2002-09-18 13:23:15.000000000 -0400
+++ gdb-5.2.debian90.cvs20021120/gdb/corelow.c	2002-12-03 14:03:32.000000000 -0500
@@ -350,7 +350,7 @@
   bfd_map_over_sections (core_bfd, add_to_thread_list,
 			 bfd_get_section_by_name (core_bfd, ".reg"));
 
-  if (ontop)
+  if (ontop || 1)
     {
       /* Fetch all registers from core file.  */
       target_fetch_registers (-1);
diff -x '*~' -ur o/gdb-5.2.debian90.cvs20021120/gdb/linux-proc.c gdb-5.2.debian90.cvs20021120/gdb/linux-proc.c
--- o/gdb-5.2.debian90.cvs20021120/gdb/linux-proc.c	2002-12-03 14:13:52.000000000 -0500
+++ gdb-5.2.debian90.cvs20021120/gdb/linux-proc.c	2002-12-03 13:56:34.000000000 -0500
@@ -177,7 +177,7 @@
 #ifdef FILL_FPXREGSET
   gdb_fpxregset_t fpxregs;
 #endif
-  unsigned long merged_pid = ptid_get_tid (ptid) << 16 | ptid_get_pid (ptid);
+  unsigned long merged_pid = ptid_get_tid (ptid) << 16; /*  | ptid_get_pid (ptid); */
 
   fill_gregset (&gregs, -1);
   note_data = (char *) elfcore_write_prstatus (obfd, 
diff -x '*~' -ur o/gdb-5.2.debian90.cvs20021120/gdb/target.c gdb-5.2.debian90.cvs20021120/gdb/target.c
--- o/gdb-5.2.debian90.cvs20021120/gdb/target.c	2002-09-18 13:23:22.000000000 -0400
+++ gdb-5.2.debian90.cvs20021120/gdb/target.c	2002-12-03 14:06:07.000000000 -0500
@@ -1589,6 +1589,7 @@
   dummy_target.to_find_memory_regions = dummy_find_memory_regions;
   dummy_target.to_make_corefile_notes = dummy_make_corefile_notes;
   dummy_target.to_magic = OPS_MAGIC;
+  cleanup_target (&dummy_target);
 }
 
 
diff -x '*~' -ur o/gdb-5.2.debian90.cvs20021120/gdb/thread-db.c gdb-5.2.debian90.cvs20021120/gdb/thread-db.c
--- o/gdb-5.2.debian90.cvs20021120/gdb/thread-db.c	2002-12-03 14:13:50.000000000 -0500
+++ gdb-5.2.debian90.cvs20021120/gdb/thread-db.c	2002-12-03 13:39:54.000000000 -0500
@@ -57,6 +57,31 @@
 /* Non-zero if we're using this module's target vector.  */
 static int using_thread_db;
 
+/* Macros to pass an event to the next target if we should not be handling it
+   here in the thread_stratum.  */
+#define FIND_NEXT_TARGET(METHOD_NAME)			\
+  struct target_ops *next_target = &thread_db_ops;	\
+  while (1)						\
+    {							\
+      next_target = find_target_beneath (next_target);	\
+      if (next_target->METHOD_NAME != NULL)		\
+	break;						\
+    }
+
+#define MAYBE_HAND_DOWN(METHOD_NAME,ARGS)		\
+  if (proc_handle.pid == 0)				\
+    {							\
+      FIND_NEXT_TARGET (METHOD_NAME);			\
+      (*next_target->METHOD_NAME) ARGS;			\
+      return;						\
+    }
+#define MAYBE_HAND_DOWN_RETURN(METHOD_NAME,ARGS)	\
+  if (proc_handle.pid == 0)				\
+    {							\
+      FIND_NEXT_TARGET (METHOD_NAME);			\
+      return (*next_target->METHOD_NAME) ARGS;		\
+    }
+
 /* Non-zero if we have to keep this module's target vector active
    across re-runs.  */
 static int keep_thread_db;
@@ -489,9 +514,7 @@
 {
   td_err_e err;
 
-  /* Don't attempt to use thread_db on targets which can not run
-     (core files).  */
-  if (objfile == NULL || !target_has_execution)
+  if (objfile == NULL)
     {
       /* All symbols have been discarded.  If the thread_db target is
          active, deactivate it now.  */
@@ -515,7 +538,10 @@
   /* Initialize the structure that identifies the child process.  Note
      that at this point there is no guarantee that we actually have a
      child process.  */
-  proc_handle.pid = GET_PID (inferior_ptid);
+  if (target_has_execution)
+    proc_handle.pid = GET_PID (inferior_ptid);
+  else
+    proc_handle.pid = 0;
 
   /* Now attempt to open a connection to the thread library.  */
   err = td_ta_new_p (&proc_handle, &thread_agent);
@@ -758,6 +784,9 @@
   struct cleanup *old_chain = save_inferior_ptid ();
   int xfer;
 
+  MAYBE_HAND_DOWN_RETURN (to_xfer_memory, (memaddr, myaddr, len, write,
+					   attrib, target));
+
   if (is_thread (inferior_ptid))
     {
       /* FIXME: This seems to be necessary to make sure breakpoints
@@ -782,6 +811,8 @@
   gdb_prfpregset_t fpregset;
   td_err_e err;
 
+  MAYBE_HAND_DOWN (to_fetch_registers, (regno));
+
   if (!is_thread (inferior_ptid))
     {
       /* Pass the request to the target beneath us.  */
@@ -819,6 +850,8 @@
   gdb_prfpregset_t fpregset;
   td_err_e err;
 
+  MAYBE_HAND_DOWN (to_store_registers, (regno));
+
   if (!is_thread (inferior_ptid))
     {
       /* Pass the request to the target beneath us.  */
@@ -908,6 +941,8 @@
   td_thrinfo_t ti;
   td_err_e err;
 
+  MAYBE_HAND_DOWN_RETURN (to_thread_alive, (ptid));
+
   if (is_thread (ptid))
     {
       err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th);
@@ -961,6 +996,8 @@
 {
   td_err_e err;
 
+  MAYBE_HAND_DOWN (to_find_new_threads, ());
+
   /* Iterate over all user-space threads to discover new threads.  */
   err = td_ta_thr_iter_p (thread_agent, find_new_threads_callback, NULL,
 			  TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY,
@@ -972,6 +1009,8 @@
 static char *
 thread_db_pid_to_str (ptid_t ptid)
 {
+  MAYBE_HAND_DOWN_RETURN (to_pid_to_str, (ptid));
+
   if (is_thread (ptid))
     {
       static char buf[64];
Trivial.  Need to submit this.

--- gdb-5.2.debian90.cvs20021120/gdb/tracepoint.c.orig	2002-12-03 14:35:44.000000000 -0500
+++ gdb-5.2.debian90.cvs20021120/gdb/tracepoint.c	2002-12-03 14:43:02.000000000 -0500
@@ -861,6 +861,8 @@
       else
 	line = gdb_readline (0);
 
+      if (line == NULL || *line == EOF)
+	break;
       linetype = validate_actionline (&line, t);
       if (linetype == BADLINE)
 	continue;		/* already warned -- collect another line */
Fix build on Sparc.

--- gdb-5.3/gdb/sparc-nat.c.orig	2003-01-04 00:11:28.000000000 -0500
+++ gdb-5.3/gdb/sparc-nat.c	2003-01-04 00:12:42.000000000 -0500
@@ -33,6 +33,13 @@
 #include <sys/ptrace.h>
 #include <sys/wait.h>
 #ifdef __linux__
+/* Sadly, <sys/ucontext.h> conflicts with <asm/reg.h> on Linux.  And
+   -D_GNU_SOURCE brings in <sys/ucontext.h> implicitly with <signal.h>.
+   Hack around this.  */
+#undef FPU_REGS_TYPE
+#define fpu asm_reg_fpu
+#define fq asm_reg_fq
+#define fpq asm_reg_fpq
 #include <asm/reg.h>
 #else
 #include <machine/reg.h>
diff -urN gdb-5.3/gdb/gdbserver.orig/gdbreplay.c gdb-5.3/gdb/gdbserver/gdbreplay.c
--- gdb-5.3/gdb/gdbserver.orig/gdbreplay.c	2002-07-09 11:38:58.000000000 -0600
+++ gdb-5.3/gdb/gdbserver/gdbreplay.c	2003-08-20 08:44:20.000000000 -0600
@@ -54,14 +54,15 @@
 perror_with_name (char *string)
 {
 #ifndef STDC_HEADERS
-  extern int sys_nerr;
   extern char *sys_errlist[];
   extern int errno;
 #endif
   const char *err;
   char *combined;
 
-  err = (errno < sys_nerr) ? sys_errlist[errno] : "unknown error";
+  err = strerror (errno);
+  if (err == NULL)
+    err = "unknown error";
   combined = (char *) alloca (strlen (err) + strlen (string) + 3);
   strcpy (combined, string);
   strcat (combined, ": ");
diff -urN gdb-5.3/gdb/gdbserver.orig/low-hppabsd.c gdb-5.3/gdb/gdbserver/low-hppabsd.c
--- gdb-5.3/gdb/gdbserver.orig/low-hppabsd.c	2002-01-17 14:13:49.000000000 -0700
+++ gdb-5.3/gdb/gdbserver/low-hppabsd.c	2003-08-20 08:46:04.000000000 -0600
@@ -61,7 +61,7 @@
       execv (program, allargs);
 
       fprintf (stderr, "Cannot exec %s: %s.\n", program,
-	       errno < sys_nerr ? sys_errlist[errno] : "unknown error");
+	       strerror (errno));
       fflush (stderr);
       _exit (0177);
     }
diff -urN gdb-5.3/gdb/gdbserver.orig/low-lynx.c gdb-5.3/gdb/gdbserver/low-lynx.c
--- gdb-5.3/gdb/gdbserver.orig/low-lynx.c	2002-01-17 14:13:49.000000000 -0700
+++ gdb-5.3/gdb/gdbserver/low-lynx.c	2003-08-20 08:46:18.000000000 -0600
@@ -79,7 +79,7 @@
 
       fprintf (stderr, "GDBserver (process %d):  Cannot exec %s: %s.\n",
 	       getpid (), program,
-	       errno < sys_nerr ? sys_errlist[errno] : "unknown error");
+	       strerror (errno));
       fflush (stderr);
       _exit (0177);
     }
diff -urN gdb-5.3/gdb/gdbserver.orig/low-nbsd.c gdb-5.3/gdb/gdbserver/low-nbsd.c
--- gdb-5.3/gdb/gdbserver.orig/low-nbsd.c	2002-01-17 14:13:49.000000000 -0700
+++ gdb-5.3/gdb/gdbserver/low-nbsd.c	2003-08-20 08:46:27.000000000 -0600
@@ -137,7 +137,7 @@
       execv (program, allargs);
 
       fprintf (stderr, "Cannot exec %s: %s.\n", program,
-	       errno < sys_nerr ? sys_errlist[errno] : "unknown error");
+	       strerror (errno));
       fflush (stderr);
       _exit (0177);
     }
diff -urN gdb-5.3/gdb/gdbserver.orig/low-sparc.c gdb-5.3/gdb/gdbserver/low-sparc.c
--- gdb-5.3/gdb/gdbserver.orig/low-sparc.c	2002-01-17 14:13:50.000000000 -0700
+++ gdb-5.3/gdb/gdbserver/low-sparc.c	2003-08-20 08:46:38.000000000 -0600
@@ -44,7 +44,6 @@
 #include <sys/ptrace.h>
 #include <sys/reg.h>
 
-extern int sys_nerr;
 extern char **sys_errlist;
 extern int errno;
 
@@ -67,7 +66,7 @@
       execv (program, allargs);
 
       fprintf (stderr, "Cannot exec %s: %s.\n", program,
-	       errno < sys_nerr ? sys_errlist[errno] : "unknown error");
+	       strerror (errno));
       fflush (stderr);
       _exit (0177);
     }
diff -urN gdb-5.3/gdb/gdbserver.orig/low-sun3.c gdb-5.3/gdb/gdbserver/low-sun3.c
--- gdb-5.3/gdb/gdbserver.orig/low-sun3.c	2002-01-17 14:13:50.000000000 -0700
+++ gdb-5.3/gdb/gdbserver/low-sun3.c	2003-08-20 08:46:51.000000000 -0600
@@ -41,7 +41,6 @@
 #include <sys/ptrace.h>
 #include <machine/reg.h>
 
-extern int sys_nerr;
 extern char **sys_errlist;
 extern int errno;
 
@@ -64,7 +63,7 @@
       execv (program, allargs);
 
       fprintf (stderr, "Cannot exec %s: %s.\n", program,
-	       errno < sys_nerr ? sys_errlist[errno] : "unknown error");
+	       strerror (errno));
       fflush (stderr);
       _exit (0177);
     }
diff -urN gdb-5.3/gdb/gdbserver.orig/utils.c gdb-5.3/gdb/gdbserver/utils.c
--- gdb-5.3/gdb/gdbserver.orig/utils.c	2003-08-20 08:47:56.000000000 -0600
+++ gdb-5.3/gdb/gdbserver/utils.c	2003-08-20 08:48:15.000000000 -0600
@@ -33,16 +33,13 @@
 perror_with_name (char *string)
 {
 #ifndef STDC_HEADERS
-  extern int sys_nerr;
-  extern char *sys_errlist[];
   extern int errno;
 #endif
   const char *err;
   char *combined;
 
-  if (errno < sys_nerr)
-    err = sys_errlist[errno];
-  else
+  err = strerror (errno);
+  if (err == NULL)
     err = "unknown error";
 
   combined = (char *) alloca (strlen (err) + strlen (string) + 3);
diff -urN gdb-5.3/gdb/gdbserver.orig/linux-low.c.orig gdb-5.3/gdb/gdbserver/linux-low.c.orig
--- gdb-5.3/gdb/gdbserver.orig/linux-low.c	2003-08-20 08:40:27.000000000 -0600
+++ gdb-5.3/gdb/gdbserver/linux-low.c	2003-08-20 08:44:54.000000000 -0600
@@ -175,8 +175,7 @@
   if (ptrace (PTRACE_ATTACH, pid, 0, 0) != 0)
     {
       fprintf (stderr, "Cannot attach to process %d: %s (%d)\n", pid,
-	       errno < sys_nerr ? sys_errlist[errno] : "unknown error",
-	       errno);
+	       strerror (errno), errno);
       fflush (stderr);
 
       /* If we fail to attach to an LWP, just return.  */