2
1

400-mips-nptl-support.patch 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. 2005-03-17 Daniel Jacobowitz <dan@codesourcery.com>
  2. * linux-mips-low.c: Include "gdb_proc_service.h".
  3. (PTRACE_GET_THREAD_AREA): Define.
  4. (ps_get_thread_area): New function.
  5. * Makefile.in: Update dependencies for linux-mips-low.o,
  6. linux-i386-low.o, and linux-x86-64-low.o.
  7. 2005-03-17 Daniel Jacobowitz <dan@codesourcery.com>
  8. * linux-mips-low.c: Include "gdb_proc_service.h".
  9. (PTRACE_GET_THREAD_AREA): Define.
  10. (ps_get_thread_area): New function.
  11. * Makefile.in (mips-linux-nat.o): Update dependencies.
  12. --
  13. diff -urN gdb-6.3.50.20050915/gdb/Makefile.in gdb-6.3.50.20050915-patched/gdb/Makefile.in
  14. --- gdb-6.3.50.20050915/gdb/Makefile.in 2005-09-10 13:11:01.000000000 -0500
  15. +++ gdb-6.3.50.20050915-patched/gdb/Makefile.in 2005-09-15 19:24:39.000000000 -0500
  16. @@ -2282,7 +2282,7 @@
  17. $(gdb_string_h) $(mips_tdep_h) $(solib_svr4_h)
  18. mips-irix-tdep.o: mips-irix-tdep.c $(defs_h) $(osabi_h) $(elf_bfd_h)
  19. mips-linux-nat.o: mips-linux-nat.c $(defs_h) $(mips_tdep_h) $(target_h) \
  20. - $(linux_nat_h)
  21. + $(linux_nat_h) $(gdb_proc_service_h)
  22. mips-linux-tdep.o: mips-linux-tdep.c $(defs_h) $(gdbcore_h) $(target_h) \
  23. $(solib_svr4_h) $(osabi_h) $(mips_tdep_h) $(gdb_string_h) \
  24. $(gdb_assert_h) $(frame_h) $(regcache_h) $(trad_frame_h) \
  25. diff -urN gdb-6.3.50.20050915/gdb/gdbserver/Makefile.in gdb-6.3.50.20050915-patched/gdb/gdbserver/Makefile.in
  26. --- gdb-6.3.50.20050915/gdb/gdbserver/Makefile.in 2005-05-28 17:09:04.000000000 -0500
  27. +++ gdb-6.3.50.20050915-patched/gdb/gdbserver/Makefile.in 2005-09-15 19:20:01.000000000 -0500
  28. @@ -267,15 +267,18 @@
  29. linux-arm-low.o: linux-arm-low.c $(linux_low_h) $(server_h)
  30. linux-cris-low.o: linux-cris-low.c $(linux_low_h) $(server_h)
  31. linux-crisv32-low.o: linux-crisv32-low.c $(linux_low_h) $(server_h)
  32. -linux-i386-low.o: linux-i386-low.c $(linux_low_h) $(server_h)
  33. +linux-i386-low.o: linux-i386-low.c $(linux_low_h) $(server_h) \
  34. + $(gdb_proc_service_h)
  35. linux-ia64-low.o: linux-ia64-low.c $(linux_low_h) $(server_h)
  36. linux-m32r-low.o: linux-m32r-low.c $(linux_low_h) $(server_h)
  37. -linux-mips-low.o: linux-mips-low.c $(linux_low_h) $(server_h)
  38. +linux-mips-low.o: linux-mips-low.c $(linux_low_h) $(server_h) \
  39. + $(gdb_proc_service_h)
  40. linux-ppc-low.o: linux-ppc-low.c $(linux_low_h) $(server_h)
  41. linux-ppc64-low.o: linux-ppc64-low.c $(linux_low_h) $(server_h)
  42. linux-s390-low.o: linux-s390-low.c $(linux_low_h) $(server_h)
  43. linux-sh-low.o: linux-sh-low.c $(linux_low_h) $(server_h)
  44. -linux-x86-64-low.o: linux-x86-64-low.c $(linux_low_h) $(server_h)
  45. +linux-x86-64-low.o: linux-x86-64-low.c $(linux_low_h) $(server_h) \
  46. + $(gdb_proc_service_h)
  47. reg-arm.o : reg-arm.c $(regdef_h)
  48. reg-arm.c : $(srcdir)/../regformats/reg-arm.dat $(regdat_sh)
  49. diff -urN gdb-6.3.50.20050915/gdb/gdbserver/linux-mips-low.c gdb-6.3.50.20050915-patched/gdb/gdbserver/linux-mips-low.c
  50. --- gdb-6.3.50.20050915/gdb/gdbserver/linux-mips-low.c 2005-06-12 20:59:22.000000000 -0500
  51. +++ gdb-6.3.50.20050915-patched/gdb/gdbserver/linux-mips-low.c 2005-09-15 19:16:54.000000000 -0500
  52. @@ -22,6 +22,26 @@
  53. #include "server.h"
  54. #include "linux-low.h"
  55. +#include <sys/ptrace.h>
  56. +
  57. +/* Correct for all GNU/Linux targets (for quite some time). */
  58. +#define GDB_GREGSET_T elf_gregset_t
  59. +#define GDB_FPREGSET_T elf_fpregset_t
  60. +
  61. +#ifndef HAVE_ELF_FPREGSET_T
  62. +/* Make sure we have said types. Not all platforms bring in <linux/elf.h>
  63. + via <sys/procfs.h>. */
  64. +#ifdef HAVE_LINUX_ELF_H
  65. +#include <linux/elf.h>
  66. +#endif
  67. +#endif
  68. +
  69. +#include "../gdb_proc_service.h"
  70. +
  71. +#ifndef PTRACE_GET_THREAD_AREA
  72. +#define PTRACE_GET_THREAD_AREA 25
  73. +#endif
  74. +
  75. #ifdef HAVE_SYS_REG_H
  76. #include <sys/reg.h>
  77. #endif
  78. @@ -140,6 +160,23 @@
  79. return 0;
  80. }
  81. +/* Fetch the thread-local storage pointer for libthread_db. */
  82. +
  83. +ps_err_e
  84. +ps_get_thread_area (const struct ps_prochandle *ph,
  85. + lwpid_t lwpid, int idx, void **base)
  86. +{
  87. + if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
  88. + return PS_ERR;
  89. +
  90. + /* IDX is the bias from the thread pointer to the beginning of the
  91. + thread descriptor. It has to be subtracted due to implementation
  92. + quirks in libthread_db. */
  93. + *base = (void *) ((char *)*base - idx);
  94. +
  95. + return PS_OK;
  96. +}
  97. +
  98. struct linux_target_ops the_low_target = {
  99. mips_num_regs,
  100. mips_regmap,
  101. diff -urN gdb-6.3.50.20050915/gdb/mips-linux-nat.c gdb-6.3.50.20050915-patched/gdb/mips-linux-nat.c
  102. --- gdb-6.3.50.20050915/gdb/mips-linux-nat.c 2005-09-10 13:11:04.000000000 -0500
  103. +++ gdb-6.3.50.20050915-patched/gdb/mips-linux-nat.c 2005-09-15 19:16:54.000000000 -0500
  104. @@ -24,6 +24,12 @@
  105. #include "target.h"
  106. #include "linux-nat.h"
  107. +#include "gdb_proc_service.h"
  108. +
  109. +#ifndef PTRACE_GET_THREAD_AREA
  110. +#define PTRACE_GET_THREAD_AREA 25
  111. +#endif
  112. +
  113. /* Pseudo registers can not be read. ptrace does not provide a way to
  114. read (or set) MIPS_PS_REGNUM, and there's no point in reading or
  115. setting MIPS_ZERO_REGNUM. We also can not set BADVADDR, CAUSE, or
  116. @@ -72,3 +78,20 @@
  117. {
  118. add_target (linux_target ());
  119. }
  120. +
  121. +/* Fetch the thread-local storage pointer for libthread_db. */
  122. +
  123. +ps_err_e
  124. +ps_get_thread_area (const struct ps_prochandle *ph,
  125. + lwpid_t lwpid, int idx, void **base)
  126. +{
  127. + if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
  128. + return PS_ERR;
  129. +
  130. + /* IDX is the bias from the thread pointer to the beginning of the
  131. + thread descriptor. It has to be subtracted due to implementation
  132. + quirks in libthread_db. */
  133. + *base = (void *) ((char *)*base - idx);
  134. +
  135. + return PS_OK;
  136. +}