netbsd-tdep.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. /* Common target-dependent code for NetBSD systems.
  2. Copyright (C) 2002-2022 Free Software Foundation, Inc.
  3. Contributed by Wasabi Systems, Inc.
  4. This file is part of GDB.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. #include "defs.h"
  16. #include "auxv.h"
  17. #include "solib-svr4.h"
  18. #include "netbsd-tdep.h"
  19. #include "gdbarch.h"
  20. #include "objfiles.h"
  21. #include "xml-syscall.h"
  22. /* Flags in the 'kve_protection' field in struct kinfo_vmentry. These
  23. match the KVME_PROT_* constants in <sys/sysctl.h>. */
  24. #define KINFO_VME_PROT_READ 0x00000001
  25. #define KINFO_VME_PROT_WRITE 0x00000002
  26. #define KINFO_VME_PROT_EXEC 0x00000004
  27. /* Flags in the 'kve_flags' field in struct kinfo_vmentry. These
  28. match the KVME_FLAG_* constants in <sys/sysctl.h>. */
  29. #define KINFO_VME_FLAG_COW 0x00000001
  30. #define KINFO_VME_FLAG_NEEDS_COPY 0x00000002
  31. #define KINFO_VME_FLAG_NOCOREDUMP 0x00000004
  32. #define KINFO_VME_FLAG_PAGEABLE 0x00000008
  33. #define KINFO_VME_FLAG_GROWS_UP 0x00000010
  34. #define KINFO_VME_FLAG_GROWS_DOWN 0x00000020
  35. /* FIXME: kettenis/20060115: We should really eliminate the next two
  36. functions completely. */
  37. struct link_map_offsets *
  38. nbsd_ilp32_solib_svr4_fetch_link_map_offsets (void)
  39. {
  40. return svr4_ilp32_fetch_link_map_offsets ();
  41. }
  42. struct link_map_offsets *
  43. nbsd_lp64_solib_svr4_fetch_link_map_offsets (void)
  44. {
  45. return svr4_lp64_fetch_link_map_offsets ();
  46. }
  47. int
  48. nbsd_pc_in_sigtramp (CORE_ADDR pc, const char *func_name)
  49. {
  50. /* Check for libc-provided signal trampoline. All such trampolines
  51. have function names which begin with "__sigtramp". */
  52. return (func_name != NULL
  53. && startswith (func_name, "__sigtramp"));
  54. }
  55. /* This enum is derived from NETBSD's <sys/signal.h>. */
  56. enum
  57. {
  58. NBSD_SIGHUP = 1,
  59. NBSD_SIGINT = 2,
  60. NBSD_SIGQUIT = 3,
  61. NBSD_SIGILL = 4,
  62. NBSD_SIGTRAP = 5,
  63. NBSD_SIGABRT = 6,
  64. NBSD_SIGEMT = 7,
  65. NBSD_SIGFPE = 8,
  66. NBSD_SIGKILL = 9,
  67. NBSD_SIGBUS = 10,
  68. NBSD_SIGSEGV = 11,
  69. NBSD_SIGSYS = 12,
  70. NBSD_SIGPIPE = 13,
  71. NBSD_SIGALRM = 14,
  72. NBSD_SIGTERM = 15,
  73. NBSD_SIGURG = 16,
  74. NBSD_SIGSTOP = 17,
  75. NBSD_SIGTSTP = 18,
  76. NBSD_SIGCONT = 19,
  77. NBSD_SIGCHLD = 20,
  78. NBSD_SIGTTIN = 21,
  79. NBSD_SIGTTOU = 22,
  80. NBSD_SIGIO = 23,
  81. NBSD_SIGXCPU = 24,
  82. NBSD_SIGXFSZ = 25,
  83. NBSD_SIGVTALRM = 26,
  84. NBSD_SIGPROF = 27,
  85. NBSD_SIGWINCH = 28,
  86. NBSD_SIGINFO = 29,
  87. NBSD_SIGUSR1 = 30,
  88. NBSD_SIGUSR2 = 31,
  89. NBSD_SIGPWR = 32,
  90. NBSD_SIGRTMIN = 33,
  91. NBSD_SIGRTMAX = 63,
  92. };
  93. /* Implement the "gdb_signal_from_target" gdbarch method. */
  94. static enum gdb_signal
  95. nbsd_gdb_signal_from_target (struct gdbarch *gdbarch, int signal)
  96. {
  97. switch (signal)
  98. {
  99. case 0:
  100. return GDB_SIGNAL_0;
  101. case NBSD_SIGHUP:
  102. return GDB_SIGNAL_HUP;
  103. case NBSD_SIGINT:
  104. return GDB_SIGNAL_INT;
  105. case NBSD_SIGQUIT:
  106. return GDB_SIGNAL_QUIT;
  107. case NBSD_SIGILL:
  108. return GDB_SIGNAL_ILL;
  109. case NBSD_SIGTRAP:
  110. return GDB_SIGNAL_TRAP;
  111. case NBSD_SIGABRT:
  112. return GDB_SIGNAL_ABRT;
  113. case NBSD_SIGEMT:
  114. return GDB_SIGNAL_EMT;
  115. case NBSD_SIGFPE:
  116. return GDB_SIGNAL_FPE;
  117. case NBSD_SIGKILL:
  118. return GDB_SIGNAL_KILL;
  119. case NBSD_SIGBUS:
  120. return GDB_SIGNAL_BUS;
  121. case NBSD_SIGSEGV:
  122. return GDB_SIGNAL_SEGV;
  123. case NBSD_SIGSYS:
  124. return GDB_SIGNAL_SYS;
  125. case NBSD_SIGPIPE:
  126. return GDB_SIGNAL_PIPE;
  127. case NBSD_SIGALRM:
  128. return GDB_SIGNAL_ALRM;
  129. case NBSD_SIGTERM:
  130. return GDB_SIGNAL_TERM;
  131. case NBSD_SIGURG:
  132. return GDB_SIGNAL_URG;
  133. case NBSD_SIGSTOP:
  134. return GDB_SIGNAL_STOP;
  135. case NBSD_SIGTSTP:
  136. return GDB_SIGNAL_TSTP;
  137. case NBSD_SIGCONT:
  138. return GDB_SIGNAL_CONT;
  139. case NBSD_SIGCHLD:
  140. return GDB_SIGNAL_CHLD;
  141. case NBSD_SIGTTIN:
  142. return GDB_SIGNAL_TTIN;
  143. case NBSD_SIGTTOU:
  144. return GDB_SIGNAL_TTOU;
  145. case NBSD_SIGIO:
  146. return GDB_SIGNAL_IO;
  147. case NBSD_SIGXCPU:
  148. return GDB_SIGNAL_XCPU;
  149. case NBSD_SIGXFSZ:
  150. return GDB_SIGNAL_XFSZ;
  151. case NBSD_SIGVTALRM:
  152. return GDB_SIGNAL_VTALRM;
  153. case NBSD_SIGPROF:
  154. return GDB_SIGNAL_PROF;
  155. case NBSD_SIGWINCH:
  156. return GDB_SIGNAL_WINCH;
  157. case NBSD_SIGINFO:
  158. return GDB_SIGNAL_INFO;
  159. case NBSD_SIGUSR1:
  160. return GDB_SIGNAL_USR1;
  161. case NBSD_SIGUSR2:
  162. return GDB_SIGNAL_USR2;
  163. case NBSD_SIGPWR:
  164. return GDB_SIGNAL_PWR;
  165. /* SIGRTMIN and SIGRTMAX are not continuous in <gdb/signals.def>,
  166. therefore we have to handle them here. */
  167. case NBSD_SIGRTMIN:
  168. return GDB_SIGNAL_REALTIME_33;
  169. case NBSD_SIGRTMAX:
  170. return GDB_SIGNAL_REALTIME_63;
  171. }
  172. if (signal >= NBSD_SIGRTMIN + 1 && signal <= NBSD_SIGRTMAX - 1)
  173. {
  174. int offset = signal - NBSD_SIGRTMIN + 1;
  175. return (enum gdb_signal) ((int) GDB_SIGNAL_REALTIME_34 + offset);
  176. }
  177. return GDB_SIGNAL_UNKNOWN;
  178. }
  179. /* Implement the "gdb_signal_to_target" gdbarch method. */
  180. static int
  181. nbsd_gdb_signal_to_target (struct gdbarch *gdbarch,
  182. enum gdb_signal signal)
  183. {
  184. switch (signal)
  185. {
  186. case GDB_SIGNAL_0:
  187. return 0;
  188. case GDB_SIGNAL_HUP:
  189. return NBSD_SIGHUP;
  190. case GDB_SIGNAL_INT:
  191. return NBSD_SIGINT;
  192. case GDB_SIGNAL_QUIT:
  193. return NBSD_SIGQUIT;
  194. case GDB_SIGNAL_ILL:
  195. return NBSD_SIGILL;
  196. case GDB_SIGNAL_TRAP:
  197. return NBSD_SIGTRAP;
  198. case GDB_SIGNAL_ABRT:
  199. return NBSD_SIGABRT;
  200. case GDB_SIGNAL_EMT:
  201. return NBSD_SIGEMT;
  202. case GDB_SIGNAL_FPE:
  203. return NBSD_SIGFPE;
  204. case GDB_SIGNAL_KILL:
  205. return NBSD_SIGKILL;
  206. case GDB_SIGNAL_BUS:
  207. return NBSD_SIGBUS;
  208. case GDB_SIGNAL_SEGV:
  209. return NBSD_SIGSEGV;
  210. case GDB_SIGNAL_SYS:
  211. return NBSD_SIGSYS;
  212. case GDB_SIGNAL_PIPE:
  213. return NBSD_SIGPIPE;
  214. case GDB_SIGNAL_ALRM:
  215. return NBSD_SIGALRM;
  216. case GDB_SIGNAL_TERM:
  217. return NBSD_SIGTERM;
  218. case GDB_SIGNAL_URG:
  219. return NBSD_SIGSTOP;
  220. case GDB_SIGNAL_TSTP:
  221. return NBSD_SIGTSTP;
  222. case GDB_SIGNAL_CONT:
  223. return NBSD_SIGCONT;
  224. case GDB_SIGNAL_CHLD:
  225. return NBSD_SIGCHLD;
  226. case GDB_SIGNAL_TTIN:
  227. return NBSD_SIGTTIN;
  228. case GDB_SIGNAL_TTOU:
  229. return NBSD_SIGTTOU;
  230. case GDB_SIGNAL_IO:
  231. return NBSD_SIGIO;
  232. case GDB_SIGNAL_XCPU:
  233. return NBSD_SIGXCPU;
  234. case GDB_SIGNAL_XFSZ:
  235. return NBSD_SIGXFSZ;
  236. case GDB_SIGNAL_VTALRM:
  237. return NBSD_SIGVTALRM;
  238. case GDB_SIGNAL_PROF:
  239. return NBSD_SIGPROF;
  240. case GDB_SIGNAL_WINCH:
  241. return NBSD_SIGWINCH;
  242. case GDB_SIGNAL_INFO:
  243. return NBSD_SIGINFO;
  244. case GDB_SIGNAL_USR1:
  245. return NBSD_SIGUSR1;
  246. case GDB_SIGNAL_USR2:
  247. return NBSD_SIGUSR2;
  248. case GDB_SIGNAL_PWR:
  249. return NBSD_SIGPWR;
  250. /* GDB_SIGNAL_REALTIME_33 is not continuous in <gdb/signals.def>,
  251. therefore we have to handle it here. */
  252. case GDB_SIGNAL_REALTIME_33:
  253. return NBSD_SIGRTMIN;
  254. /* Same comment applies to _64. */
  255. case GDB_SIGNAL_REALTIME_63:
  256. return NBSD_SIGRTMAX;
  257. }
  258. if (signal >= GDB_SIGNAL_REALTIME_34
  259. && signal <= GDB_SIGNAL_REALTIME_62)
  260. {
  261. int offset = signal - GDB_SIGNAL_REALTIME_32;
  262. return NBSD_SIGRTMIN + 1 + offset;
  263. }
  264. return -1;
  265. }
  266. /* Shared library resolver handling. */
  267. static CORE_ADDR
  268. nbsd_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
  269. {
  270. struct bound_minimal_symbol msym;
  271. msym = lookup_minimal_symbol ("_rtld_bind_start", NULL, NULL);
  272. if (msym.minsym && BMSYMBOL_VALUE_ADDRESS (msym) == pc)
  273. return frame_unwind_caller_pc (get_current_frame ());
  274. else
  275. return find_solib_trampoline_target (get_current_frame (), pc);
  276. }
  277. static struct gdbarch_data *nbsd_gdbarch_data_handle;
  278. struct nbsd_gdbarch_data
  279. {
  280. struct type *siginfo_type;
  281. };
  282. static void *
  283. init_nbsd_gdbarch_data (struct gdbarch *gdbarch)
  284. {
  285. return GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nbsd_gdbarch_data);
  286. }
  287. static struct nbsd_gdbarch_data *
  288. get_nbsd_gdbarch_data (struct gdbarch *gdbarch)
  289. {
  290. return ((struct nbsd_gdbarch_data *)
  291. gdbarch_data (gdbarch, nbsd_gdbarch_data_handle));
  292. }
  293. /* Implement the "get_siginfo_type" gdbarch method. */
  294. static struct type *
  295. nbsd_get_siginfo_type (struct gdbarch *gdbarch)
  296. {
  297. nbsd_gdbarch_data *nbsd_gdbarch_data = get_nbsd_gdbarch_data (gdbarch);
  298. if (nbsd_gdbarch_data->siginfo_type != NULL)
  299. return nbsd_gdbarch_data->siginfo_type;
  300. type *char_type = builtin_type (gdbarch)->builtin_char;
  301. type *int_type = builtin_type (gdbarch)->builtin_int;
  302. type *long_type = builtin_type (gdbarch)->builtin_long;
  303. type *void_ptr_type
  304. = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
  305. type *int32_type = builtin_type (gdbarch)->builtin_int32;
  306. type *uint32_type = builtin_type (gdbarch)->builtin_uint32;
  307. type *uint64_type = builtin_type (gdbarch)->builtin_uint64;
  308. bool lp64 = TYPE_LENGTH (void_ptr_type) == 8;
  309. size_t char_bits = gdbarch_addressable_memory_unit_size (gdbarch) * 8;
  310. /* pid_t */
  311. type *pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
  312. TYPE_LENGTH (int32_type) * char_bits, "pid_t");
  313. TYPE_TARGET_TYPE (pid_type) = int32_type;
  314. /* uid_t */
  315. type *uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
  316. TYPE_LENGTH (uint32_type) * char_bits, "uid_t");
  317. TYPE_TARGET_TYPE (uid_type) = uint32_type;
  318. /* clock_t */
  319. type *clock_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
  320. TYPE_LENGTH (int_type) * char_bits, "clock_t");
  321. TYPE_TARGET_TYPE (clock_type) = int_type;
  322. /* lwpid_t */
  323. type *lwpid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
  324. TYPE_LENGTH (int32_type) * char_bits,
  325. "lwpid_t");
  326. TYPE_TARGET_TYPE (lwpid_type) = int32_type;
  327. /* union sigval */
  328. type *sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
  329. sigval_type->set_name (gdbarch_obstack_strdup (gdbarch, "sigval"));
  330. append_composite_type_field (sigval_type, "sival_int", int_type);
  331. append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type);
  332. /* union _option */
  333. type *option_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
  334. option_type->set_name (gdbarch_obstack_strdup (gdbarch, "_option"));
  335. append_composite_type_field (option_type, "_pe_other_pid", pid_type);
  336. append_composite_type_field (option_type, "_pe_lwp", lwpid_type);
  337. /* union _reason */
  338. type *reason_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
  339. /* _rt */
  340. type *t = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
  341. append_composite_type_field (t, "_pid", pid_type);
  342. append_composite_type_field (t, "_uid", uid_type);
  343. append_composite_type_field (t, "_value", sigval_type);
  344. append_composite_type_field (reason_type, "_rt", t);
  345. /* _child */
  346. t = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
  347. append_composite_type_field (t, "_pid", pid_type);
  348. append_composite_type_field (t, "_uid", uid_type);
  349. append_composite_type_field (t, "_status", int_type);
  350. append_composite_type_field (t, "_utime", clock_type);
  351. append_composite_type_field (t, "_stime", clock_type);
  352. append_composite_type_field (reason_type, "_child", t);
  353. /* _fault */
  354. t = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
  355. append_composite_type_field (t, "_addr", void_ptr_type);
  356. append_composite_type_field (t, "_trap", int_type);
  357. append_composite_type_field (t, "_trap2", int_type);
  358. append_composite_type_field (t, "_trap3", int_type);
  359. append_composite_type_field (reason_type, "_fault", t);
  360. /* _poll */
  361. t = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
  362. append_composite_type_field (t, "_band", long_type);
  363. append_composite_type_field (t, "_fd", int_type);
  364. append_composite_type_field (reason_type, "_poll", t);
  365. /* _syscall */
  366. t = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
  367. append_composite_type_field (t, "_sysnum", int_type);
  368. append_composite_type_field (t, "_retval",
  369. init_vector_type (int_type, 2));
  370. append_composite_type_field (t, "_error", int_type);
  371. append_composite_type_field (t, "_args",
  372. init_vector_type (uint64_type, 8));
  373. append_composite_type_field (reason_type, "_syscall", t);
  374. /* _ptrace_state */
  375. t = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
  376. append_composite_type_field (t, "_pe_report_event", int_type);
  377. append_composite_type_field (t, "_option", option_type);
  378. append_composite_type_field (reason_type, "_ptrace_state", t);
  379. /* struct _ksiginfo */
  380. type *ksiginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
  381. ksiginfo_type->set_name (gdbarch_obstack_strdup (gdbarch, "_ksiginfo"));
  382. append_composite_type_field (ksiginfo_type, "_signo", int_type);
  383. append_composite_type_field (ksiginfo_type, "_code", int_type);
  384. append_composite_type_field (ksiginfo_type, "_errno", int_type);
  385. if (lp64)
  386. append_composite_type_field (ksiginfo_type, "_pad", int_type);
  387. append_composite_type_field (ksiginfo_type, "_reason", reason_type);
  388. /* union siginfo */
  389. type *siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
  390. siginfo_type->set_name (gdbarch_obstack_strdup (gdbarch, "siginfo"));
  391. append_composite_type_field (siginfo_type, "si_pad",
  392. init_vector_type (char_type, 128));
  393. append_composite_type_field (siginfo_type, "_info", ksiginfo_type);
  394. nbsd_gdbarch_data->siginfo_type = siginfo_type;
  395. return siginfo_type;
  396. }
  397. /* See netbsd-tdep.h. */
  398. void
  399. nbsd_info_proc_mappings_header (int addr_bit)
  400. {
  401. gdb_printf (_("Mapped address spaces:\n\n"));
  402. if (addr_bit == 64)
  403. {
  404. gdb_printf (" %18s %18s %10s %10s %9s %s\n",
  405. "Start Addr",
  406. " End Addr",
  407. " Size", " Offset", "Flags ", "File");
  408. }
  409. else
  410. {
  411. gdb_printf ("\t%10s %10s %10s %10s %9s %s\n",
  412. "Start Addr",
  413. " End Addr",
  414. " Size", " Offset", "Flags ", "File");
  415. }
  416. }
  417. /* Helper function to generate mappings flags for a single VM map
  418. entry in 'info proc mappings'. */
  419. static const char *
  420. nbsd_vm_map_entry_flags (int kve_flags, int kve_protection)
  421. {
  422. static char vm_flags[9];
  423. vm_flags[0] = (kve_protection & KINFO_VME_PROT_READ) ? 'r' : '-';
  424. vm_flags[1] = (kve_protection & KINFO_VME_PROT_WRITE) ? 'w' : '-';
  425. vm_flags[2] = (kve_protection & KINFO_VME_PROT_EXEC) ? 'x' : '-';
  426. vm_flags[3] = ' ';
  427. vm_flags[4] = (kve_flags & KINFO_VME_FLAG_COW) ? 'C' : '-';
  428. vm_flags[5] = (kve_flags & KINFO_VME_FLAG_NEEDS_COPY) ? 'N' : '-';
  429. vm_flags[6] = (kve_flags & KINFO_VME_FLAG_PAGEABLE) ? 'P' : '-';
  430. vm_flags[7] = (kve_flags & KINFO_VME_FLAG_GROWS_UP) ? 'U'
  431. : (kve_flags & KINFO_VME_FLAG_GROWS_DOWN) ? 'D' : '-';
  432. vm_flags[8] = '\0';
  433. return vm_flags;
  434. }
  435. void
  436. nbsd_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start,
  437. ULONGEST kve_end, ULONGEST kve_offset,
  438. int kve_flags, int kve_protection,
  439. const char *kve_path)
  440. {
  441. if (addr_bit == 64)
  442. {
  443. gdb_printf (" %18s %18s %10s %10s %9s %s\n",
  444. hex_string (kve_start),
  445. hex_string (kve_end),
  446. hex_string (kve_end - kve_start),
  447. hex_string (kve_offset),
  448. nbsd_vm_map_entry_flags (kve_flags, kve_protection),
  449. kve_path);
  450. }
  451. else
  452. {
  453. gdb_printf ("\t%10s %10s %10s %10s %9s %s\n",
  454. hex_string (kve_start),
  455. hex_string (kve_end),
  456. hex_string (kve_end - kve_start),
  457. hex_string (kve_offset),
  458. nbsd_vm_map_entry_flags (kve_flags, kve_protection),
  459. kve_path);
  460. }
  461. }
  462. /* Implement the "get_syscall_number" gdbarch method. */
  463. static LONGEST
  464. nbsd_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread)
  465. {
  466. /* NetBSD doesn't use gdbarch_get_syscall_number since NetBSD
  467. native targets fetch the system call number from the
  468. 'si_sysnum' member of siginfo_t in nbsd_nat_target::wait.
  469. However, system call catching requires this function to be
  470. set. */
  471. internal_error (__FILE__, __LINE__, _("nbsd_get_sycall_number called"));
  472. }
  473. /* See netbsd-tdep.h. */
  474. void
  475. nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
  476. {
  477. set_gdbarch_gdb_signal_from_target (gdbarch, nbsd_gdb_signal_from_target);
  478. set_gdbarch_gdb_signal_to_target (gdbarch, nbsd_gdb_signal_to_target);
  479. set_gdbarch_skip_solib_resolver (gdbarch, nbsd_skip_solib_resolver);
  480. set_gdbarch_auxv_parse (gdbarch, svr4_auxv_parse);
  481. set_gdbarch_get_siginfo_type (gdbarch, nbsd_get_siginfo_type);
  482. /* `catch syscall' */
  483. set_xml_syscall_file_name (gdbarch, "syscalls/netbsd.xml");
  484. set_gdbarch_get_syscall_number (gdbarch, nbsd_get_syscall_number);
  485. }
  486. void _initialize_nbsd_tdep ();
  487. void
  488. _initialize_nbsd_tdep ()
  489. {
  490. nbsd_gdbarch_data_handle
  491. = gdbarch_data_register_post_init (init_nbsd_gdbarch_data);
  492. }