050-debian-subset.patch 21 KB

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