PageRenderTime 64ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/process.c

https://github.com/mindjiver/revisor
C | 2661 lines | 2491 code | 95 blank | 75 comment | 347 complexity | 28c546948b8d6d4ee06f9348c3c503b1 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
  3. * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
  4. * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
  5. * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  6. * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
  7. * Linux for s390 port by D.J. Barrow
  8. * <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
  9. * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH
  10. * port by Greg Banks <gbanks@pocketpenguins.com>
  11. *
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions
  16. * are met:
  17. * 1. Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. * 2. Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in the
  21. * documentation and/or other materials provided with the distribution.
  22. * 3. The name of the author may not be used to endorse or promote products
  23. * derived from this software without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  26. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  27. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  28. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  29. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  30. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  34. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. */
  36. #include "defs.h"
  37. #include <fcntl.h>
  38. #include <sys/stat.h>
  39. #include <sys/wait.h>
  40. #include <sys/resource.h>
  41. #include <sys/utsname.h>
  42. #include <sys/user.h>
  43. #ifdef HAVE_SYS_REG_H
  44. # include <sys/reg.h>
  45. # ifndef PTRACE_PEEKUSR
  46. # define PTRACE_PEEKUSR PTRACE_PEEKUSER
  47. # endif
  48. # ifndef PTRACE_POKEUSR
  49. # define PTRACE_POKEUSR PTRACE_POKEUSER
  50. # endif
  51. #endif
  52. #ifdef HAVE_LINUX_PTRACE_H
  53. # undef PTRACE_SYSCALL
  54. # ifdef HAVE_STRUCT_IA64_FPREG
  55. # define ia64_fpreg XXX_ia64_fpreg
  56. # endif
  57. # ifdef HAVE_STRUCT_PT_ALL_USER_REGS
  58. # define pt_all_user_regs XXX_pt_all_user_regs
  59. # endif
  60. # include <linux/ptrace.h>
  61. # undef ia64_fpreg
  62. # undef pt_all_user_regs
  63. #endif
  64. #if defined(SPARC64)
  65. # define r_pc r_tpc
  66. # undef PTRACE_GETREGS
  67. # define PTRACE_GETREGS PTRACE_GETREGS64
  68. # undef PTRACE_SETREGS
  69. # define PTRACE_SETREGS PTRACE_SETREGS64
  70. #endif
  71. #ifdef HAVE_LINUX_FUTEX_H
  72. # include <linux/futex.h>
  73. #endif
  74. #ifndef FUTEX_WAIT
  75. # define FUTEX_WAIT 0
  76. #endif
  77. #ifndef FUTEX_WAKE
  78. # define FUTEX_WAKE 1
  79. #endif
  80. #ifndef FUTEX_FD
  81. # define FUTEX_FD 2
  82. #endif
  83. #ifndef FUTEX_REQUEUE
  84. # define FUTEX_REQUEUE 3
  85. #endif
  86. #include <sched.h>
  87. #include <asm/posix_types.h>
  88. #undef GETGROUPS_T
  89. #define GETGROUPS_T __kernel_gid_t
  90. #undef GETGROUPS32_T
  91. #define GETGROUPS32_T __kernel_gid32_t
  92. #if defined(IA64)
  93. # include <asm/ptrace_offsets.h>
  94. # include <asm/rse.h>
  95. #endif
  96. #ifdef HAVE_PRCTL
  97. # include <sys/prctl.h>
  98. static const struct xlat prctl_options[] = {
  99. #ifdef PR_MAXPROCS
  100. { PR_MAXPROCS, "PR_MAXPROCS" },
  101. #endif
  102. #ifdef PR_ISBLOCKED
  103. { PR_ISBLOCKED, "PR_ISBLOCKED" },
  104. #endif
  105. #ifdef PR_SETSTACKSIZE
  106. { PR_SETSTACKSIZE, "PR_SETSTACKSIZE" },
  107. #endif
  108. #ifdef PR_GETSTACKSIZE
  109. { PR_GETSTACKSIZE, "PR_GETSTACKSIZE" },
  110. #endif
  111. #ifdef PR_MAXPPROCS
  112. { PR_MAXPPROCS, "PR_MAXPPROCS" },
  113. #endif
  114. #ifdef PR_UNBLKONEXEC
  115. { PR_UNBLKONEXEC, "PR_UNBLKONEXEC" },
  116. #endif
  117. #ifdef PR_ATOMICSIM
  118. { PR_ATOMICSIM, "PR_ATOMICSIM" },
  119. #endif
  120. #ifdef PR_SETEXITSIG
  121. { PR_SETEXITSIG, "PR_SETEXITSIG" },
  122. #endif
  123. #ifdef PR_RESIDENT
  124. { PR_RESIDENT, "PR_RESIDENT" },
  125. #endif
  126. #ifdef PR_ATTACHADDR
  127. { PR_ATTACHADDR, "PR_ATTACHADDR" },
  128. #endif
  129. #ifdef PR_DETACHADDR
  130. { PR_DETACHADDR, "PR_DETACHADDR" },
  131. #endif
  132. #ifdef PR_TERMCHILD
  133. { PR_TERMCHILD, "PR_TERMCHILD" },
  134. #endif
  135. #ifdef PR_GETSHMASK
  136. { PR_GETSHMASK, "PR_GETSHMASK" },
  137. #endif
  138. #ifdef PR_GETNSHARE
  139. { PR_GETNSHARE, "PR_GETNSHARE" },
  140. #endif
  141. #ifdef PR_COREPID
  142. { PR_COREPID, "PR_COREPID" },
  143. #endif
  144. #ifdef PR_ATTACHADDRPERM
  145. { PR_ATTACHADDRPERM, "PR_ATTACHADDRPERM" },
  146. #endif
  147. #ifdef PR_PTHREADEXIT
  148. { PR_PTHREADEXIT, "PR_PTHREADEXIT" },
  149. #endif
  150. #ifdef PR_SET_PDEATHSIG
  151. { PR_SET_PDEATHSIG, "PR_SET_PDEATHSIG" },
  152. #endif
  153. #ifdef PR_GET_PDEATHSIG
  154. { PR_GET_PDEATHSIG, "PR_GET_PDEATHSIG" },
  155. #endif
  156. #ifdef PR_GET_DUMPABLE
  157. { PR_GET_DUMPABLE, "PR_GET_DUMPABLE" },
  158. #endif
  159. #ifdef PR_SET_DUMPABLE
  160. { PR_SET_DUMPABLE, "PR_SET_DUMPABLE" },
  161. #endif
  162. #ifdef PR_GET_UNALIGN
  163. { PR_GET_UNALIGN, "PR_GET_UNALIGN" },
  164. #endif
  165. #ifdef PR_SET_UNALIGN
  166. { PR_SET_UNALIGN, "PR_SET_UNALIGN" },
  167. #endif
  168. #ifdef PR_GET_KEEPCAPS
  169. { PR_GET_KEEPCAPS, "PR_GET_KEEPCAPS" },
  170. #endif
  171. #ifdef PR_SET_KEEPCAPS
  172. { PR_SET_KEEPCAPS, "PR_SET_KEEPCAPS" },
  173. #endif
  174. #ifdef PR_GET_FPEMU
  175. { PR_GET_FPEMU, "PR_GET_FPEMU" },
  176. #endif
  177. #ifdef PR_SET_FPEMU
  178. { PR_SET_FPEMU, "PR_SET_FPEMU" },
  179. #endif
  180. #ifdef PR_GET_FPEXC
  181. { PR_GET_FPEXC, "PR_GET_FPEXC" },
  182. #endif
  183. #ifdef PR_SET_FPEXC
  184. { PR_SET_FPEXC, "PR_SET_FPEXC" },
  185. #endif
  186. #ifdef PR_GET_TIMING
  187. { PR_GET_TIMING, "PR_GET_TIMING" },
  188. #endif
  189. #ifdef PR_SET_TIMING
  190. { PR_SET_TIMING, "PR_SET_TIMING" },
  191. #endif
  192. #ifdef PR_SET_NAME
  193. { PR_SET_NAME, "PR_SET_NAME" },
  194. #endif
  195. #ifdef PR_GET_NAME
  196. { PR_GET_NAME, "PR_GET_NAME" },
  197. #endif
  198. #ifdef PR_GET_ENDIAN
  199. { PR_GET_ENDIAN, "PR_GET_ENDIAN" },
  200. #endif
  201. #ifdef PR_SET_ENDIAN
  202. { PR_SET_ENDIAN, "PR_SET_ENDIAN" },
  203. #endif
  204. #ifdef PR_GET_SECCOMP
  205. { PR_GET_SECCOMP, "PR_GET_SECCOMP" },
  206. #endif
  207. #ifdef PR_SET_SECCOMP
  208. { PR_SET_SECCOMP, "PR_SET_SECCOMP" },
  209. #endif
  210. #ifdef PR_GET_TSC
  211. { PR_GET_TSC, "PR_GET_TSC" },
  212. #endif
  213. #ifdef PR_SET_TSC
  214. { PR_SET_TSC, "PR_SET_TSC" },
  215. #endif
  216. #ifdef PR_GET_SECUREBITS
  217. { PR_GET_SECUREBITS, "PR_GET_SECUREBITS" },
  218. #endif
  219. #ifdef PR_SET_SECUREBITS
  220. { PR_SET_SECUREBITS, "PR_SET_SECUREBITS" },
  221. #endif
  222. { 0, NULL },
  223. };
  224. static const char *
  225. unalignctl_string(unsigned int ctl)
  226. {
  227. static char buf[sizeof(int)*2 + 2];
  228. switch (ctl) {
  229. #ifdef PR_UNALIGN_NOPRINT
  230. case PR_UNALIGN_NOPRINT:
  231. return "NOPRINT";
  232. #endif
  233. #ifdef PR_UNALIGN_SIGBUS
  234. case PR_UNALIGN_SIGBUS:
  235. return "SIGBUS";
  236. #endif
  237. default:
  238. break;
  239. }
  240. sprintf(buf, "%x", ctl);
  241. return buf;
  242. }
  243. int
  244. sys_prctl(struct tcb *tcp)
  245. {
  246. int i;
  247. if (entering(tcp)) {
  248. printxval(prctl_options, tcp->u_arg[0], "PR_???");
  249. switch (tcp->u_arg[0]) {
  250. #ifdef PR_GETNSHARE
  251. case PR_GETNSHARE:
  252. break;
  253. #endif
  254. #ifdef PR_SET_PDEATHSIG
  255. case PR_SET_PDEATHSIG:
  256. tprintf(", %lu", tcp->u_arg[1]);
  257. break;
  258. #endif
  259. #ifdef PR_GET_PDEATHSIG
  260. case PR_GET_PDEATHSIG:
  261. break;
  262. #endif
  263. #ifdef PR_SET_DUMPABLE
  264. case PR_SET_DUMPABLE:
  265. tprintf(", %lu", tcp->u_arg[1]);
  266. break;
  267. #endif
  268. #ifdef PR_GET_DUMPABLE
  269. case PR_GET_DUMPABLE:
  270. break;
  271. #endif
  272. #ifdef PR_SET_UNALIGN
  273. case PR_SET_UNALIGN:
  274. tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
  275. break;
  276. #endif
  277. #ifdef PR_GET_UNALIGN
  278. case PR_GET_UNALIGN:
  279. tprintf(", %#lx", tcp->u_arg[1]);
  280. break;
  281. #endif
  282. #ifdef PR_SET_KEEPCAPS
  283. case PR_SET_KEEPCAPS:
  284. tprintf(", %lu", tcp->u_arg[1]);
  285. break;
  286. #endif
  287. #ifdef PR_GET_KEEPCAPS
  288. case PR_GET_KEEPCAPS:
  289. break;
  290. #endif
  291. default:
  292. for (i = 1; i < tcp->u_nargs; i++)
  293. tprintf(", %#lx", tcp->u_arg[i]);
  294. break;
  295. }
  296. } else {
  297. switch (tcp->u_arg[0]) {
  298. #ifdef PR_GET_PDEATHSIG
  299. case PR_GET_PDEATHSIG:
  300. if (umove(tcp, tcp->u_arg[1], &i) < 0)
  301. tprintf(", %#lx", tcp->u_arg[1]);
  302. else
  303. tprintf(", {%u}", i);
  304. break;
  305. #endif
  306. #ifdef PR_GET_DUMPABLE
  307. case PR_GET_DUMPABLE:
  308. return RVAL_UDECIMAL;
  309. #endif
  310. #ifdef PR_GET_UNALIGN
  311. case PR_GET_UNALIGN:
  312. if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
  313. break;
  314. tcp->auxstr = unalignctl_string(i);
  315. return RVAL_STR;
  316. #endif
  317. #ifdef PR_GET_KEEPCAPS
  318. case PR_GET_KEEPCAPS:
  319. return RVAL_UDECIMAL;
  320. #endif
  321. default:
  322. break;
  323. }
  324. }
  325. return 0;
  326. }
  327. #endif /* HAVE_PRCTL */
  328. int
  329. sys_sethostname(struct tcb *tcp)
  330. {
  331. if (entering(tcp)) {
  332. printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
  333. tprintf(", %lu", tcp->u_arg[1]);
  334. }
  335. return 0;
  336. }
  337. #if defined(ALPHA)
  338. int
  339. sys_gethostname(struct tcb *tcp)
  340. {
  341. if (exiting(tcp)) {
  342. if (syserror(tcp))
  343. tprintf("%#lx", tcp->u_arg[0]);
  344. else
  345. printpath(tcp, tcp->u_arg[0]);
  346. tprintf(", %lu", tcp->u_arg[1]);
  347. }
  348. return 0;
  349. }
  350. #endif
  351. int
  352. sys_setdomainname(struct tcb *tcp)
  353. {
  354. if (entering(tcp)) {
  355. printpathn(tcp, tcp->u_arg[0], tcp->u_arg[1]);
  356. tprintf(", %lu", tcp->u_arg[1]);
  357. }
  358. return 0;
  359. }
  360. int
  361. sys_exit(struct tcb *tcp)
  362. {
  363. if (exiting(tcp)) {
  364. fprintf(stderr, "_exit returned!\n");
  365. return -1;
  366. }
  367. /* special case: we stop tracing this process, finish line now */
  368. tprintf("%ld) ", tcp->u_arg[0]);
  369. tabto();
  370. tprints("= ?\n");
  371. line_ended();
  372. return 0;
  373. }
  374. /* defines copied from linux/sched.h since we can't include that
  375. * ourselves (it conflicts with *lots* of libc includes)
  376. */
  377. #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
  378. #define CLONE_VM 0x00000100 /* set if VM shared between processes */
  379. #define CLONE_FS 0x00000200 /* set if fs info shared between processes */
  380. #define CLONE_FILES 0x00000400 /* set if open files shared between processes */
  381. #define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
  382. #define CLONE_IDLETASK 0x00001000 /* kernel-only flag */
  383. #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
  384. #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
  385. #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
  386. #define CLONE_THREAD 0x00010000 /* Same thread group? */
  387. #define CLONE_NEWNS 0x00020000 /* New namespace group? */
  388. #define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
  389. #define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
  390. #define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
  391. #define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
  392. #define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
  393. #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
  394. #define CLONE_STOPPED 0x02000000 /* Start in stopped state */
  395. #define CLONE_NEWUTS 0x04000000 /* New utsname group? */
  396. #define CLONE_NEWIPC 0x08000000 /* New ipcs */
  397. #define CLONE_NEWUSER 0x10000000 /* New user namespace */
  398. #define CLONE_NEWPID 0x20000000 /* New pid namespace */
  399. #define CLONE_NEWNET 0x40000000 /* New network namespace */
  400. #define CLONE_IO 0x80000000 /* Clone io context */
  401. static const struct xlat clone_flags[] = {
  402. { CLONE_VM, "CLONE_VM" },
  403. { CLONE_FS, "CLONE_FS" },
  404. { CLONE_FILES, "CLONE_FILES" },
  405. { CLONE_SIGHAND, "CLONE_SIGHAND" },
  406. { CLONE_IDLETASK, "CLONE_IDLETASK" },
  407. { CLONE_PTRACE, "CLONE_PTRACE" },
  408. { CLONE_VFORK, "CLONE_VFORK" },
  409. { CLONE_PARENT, "CLONE_PARENT" },
  410. { CLONE_THREAD, "CLONE_THREAD" },
  411. { CLONE_NEWNS, "CLONE_NEWNS" },
  412. { CLONE_SYSVSEM, "CLONE_SYSVSEM" },
  413. { CLONE_SETTLS, "CLONE_SETTLS" },
  414. { CLONE_PARENT_SETTID, "CLONE_PARENT_SETTID" },
  415. { CLONE_CHILD_CLEARTID, "CLONE_CHILD_CLEARTID" },
  416. { CLONE_UNTRACED, "CLONE_UNTRACED" },
  417. { CLONE_CHILD_SETTID, "CLONE_CHILD_SETTID" },
  418. { CLONE_STOPPED, "CLONE_STOPPED" },
  419. { CLONE_NEWUTS, "CLONE_NEWUTS" },
  420. { CLONE_NEWIPC, "CLONE_NEWIPC" },
  421. { CLONE_NEWUSER, "CLONE_NEWUSER" },
  422. { CLONE_NEWPID, "CLONE_NEWPID" },
  423. { CLONE_NEWNET, "CLONE_NEWNET" },
  424. { CLONE_IO, "CLONE_IO" },
  425. { 0, NULL },
  426. };
  427. #ifdef I386
  428. # include <asm/ldt.h>
  429. # ifdef HAVE_STRUCT_USER_DESC
  430. # define modify_ldt_ldt_s user_desc
  431. # endif
  432. extern void print_ldt_entry();
  433. #endif
  434. #if defined IA64
  435. # define ARG_FLAGS 0
  436. # define ARG_STACK 1
  437. # define ARG_STACKSIZE (tcp->scno == SYS_clone2 ? 2 : -1)
  438. # define ARG_PTID (tcp->scno == SYS_clone2 ? 3 : 2)
  439. # define ARG_CTID (tcp->scno == SYS_clone2 ? 4 : 3)
  440. # define ARG_TLS (tcp->scno == SYS_clone2 ? 5 : 4)
  441. #elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
  442. # define ARG_STACK 0
  443. # define ARG_FLAGS 1
  444. # define ARG_PTID 2
  445. # define ARG_CTID 3
  446. # define ARG_TLS 4
  447. #elif defined X86_64 || defined X32 || defined ALPHA
  448. # define ARG_FLAGS 0
  449. # define ARG_STACK 1
  450. # define ARG_PTID 2
  451. # define ARG_CTID 3
  452. # define ARG_TLS 4
  453. #else
  454. # define ARG_FLAGS 0
  455. # define ARG_STACK 1
  456. # define ARG_PTID 2
  457. # define ARG_TLS 3
  458. # define ARG_CTID 4
  459. #endif
  460. int
  461. sys_clone(struct tcb *tcp)
  462. {
  463. if (exiting(tcp)) {
  464. const char *sep = "|";
  465. unsigned long flags = tcp->u_arg[ARG_FLAGS];
  466. tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
  467. #ifdef ARG_STACKSIZE
  468. if (ARG_STACKSIZE != -1)
  469. tprintf("stack_size=%#lx, ",
  470. tcp->u_arg[ARG_STACKSIZE]);
  471. #endif
  472. tprints("flags=");
  473. if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
  474. sep = "";
  475. if ((flags & CSIGNAL) != 0)
  476. tprintf("%s%s", sep, signame(flags & CSIGNAL));
  477. if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
  478. |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
  479. return 0;
  480. if (flags & CLONE_PARENT_SETTID)
  481. tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
  482. if (flags & CLONE_SETTLS) {
  483. #ifdef I386
  484. struct modify_ldt_ldt_s copy;
  485. if (umove(tcp, tcp->u_arg[ARG_TLS], &copy) != -1) {
  486. tprintf(", {entry_number:%d, ",
  487. copy.entry_number);
  488. if (!verbose(tcp))
  489. tprints("...}");
  490. else
  491. print_ldt_entry(&copy);
  492. }
  493. else
  494. #endif
  495. tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
  496. }
  497. if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
  498. tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
  499. }
  500. return 0;
  501. }
  502. int
  503. sys_unshare(struct tcb *tcp)
  504. {
  505. if (entering(tcp))
  506. printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
  507. return 0;
  508. }
  509. int
  510. sys_fork(struct tcb *tcp)
  511. {
  512. if (exiting(tcp))
  513. return RVAL_UDECIMAL;
  514. return 0;
  515. }
  516. int
  517. sys_vfork(struct tcb *tcp)
  518. {
  519. if (exiting(tcp))
  520. return RVAL_UDECIMAL;
  521. return 0;
  522. }
  523. int sys_getuid(struct tcb *tcp)
  524. {
  525. if (exiting(tcp))
  526. tcp->u_rval = (uid_t) tcp->u_rval;
  527. return RVAL_UDECIMAL;
  528. }
  529. int sys_setfsuid(struct tcb *tcp)
  530. {
  531. if (entering(tcp))
  532. tprintf("%u", (uid_t) tcp->u_arg[0]);
  533. else
  534. tcp->u_rval = (uid_t) tcp->u_rval;
  535. return RVAL_UDECIMAL;
  536. }
  537. int
  538. sys_setuid(struct tcb *tcp)
  539. {
  540. if (entering(tcp)) {
  541. tprintf("%u", (uid_t) tcp->u_arg[0]);
  542. }
  543. return 0;
  544. }
  545. int
  546. sys_getresuid(struct tcb *tcp)
  547. {
  548. if (exiting(tcp)) {
  549. __kernel_uid_t uid;
  550. if (syserror(tcp))
  551. tprintf("%#lx, %#lx, %#lx", tcp->u_arg[0],
  552. tcp->u_arg[1], tcp->u_arg[2]);
  553. else {
  554. if (umove(tcp, tcp->u_arg[0], &uid) < 0)
  555. tprintf("%#lx, ", tcp->u_arg[0]);
  556. else
  557. tprintf("[%lu], ", (unsigned long) uid);
  558. if (umove(tcp, tcp->u_arg[1], &uid) < 0)
  559. tprintf("%#lx, ", tcp->u_arg[1]);
  560. else
  561. tprintf("[%lu], ", (unsigned long) uid);
  562. if (umove(tcp, tcp->u_arg[2], &uid) < 0)
  563. tprintf("%#lx", tcp->u_arg[2]);
  564. else
  565. tprintf("[%lu]", (unsigned long) uid);
  566. }
  567. }
  568. return 0;
  569. }
  570. int
  571. sys_setreuid(struct tcb *tcp)
  572. {
  573. if (entering(tcp)) {
  574. printuid("", tcp->u_arg[0]);
  575. printuid(", ", tcp->u_arg[1]);
  576. }
  577. return 0;
  578. }
  579. int
  580. sys_setresuid(struct tcb *tcp)
  581. {
  582. if (entering(tcp)) {
  583. printuid("", tcp->u_arg[0]);
  584. printuid(", ", tcp->u_arg[1]);
  585. printuid(", ", tcp->u_arg[2]);
  586. }
  587. return 0;
  588. }
  589. int
  590. sys_setgroups(struct tcb *tcp)
  591. {
  592. if (entering(tcp)) {
  593. unsigned long len, size, start, cur, end, abbrev_end;
  594. GETGROUPS_T gid;
  595. int failed = 0;
  596. len = tcp->u_arg[0];
  597. tprintf("%lu, ", len);
  598. if (len == 0) {
  599. tprints("[]");
  600. return 0;
  601. }
  602. start = tcp->u_arg[1];
  603. if (start == 0) {
  604. tprints("NULL");
  605. return 0;
  606. }
  607. size = len * sizeof(gid);
  608. end = start + size;
  609. if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
  610. tprintf("%#lx", start);
  611. return 0;
  612. }
  613. if (abbrev(tcp)) {
  614. abbrev_end = start + max_strlen * sizeof(gid);
  615. if (abbrev_end < start)
  616. abbrev_end = end;
  617. } else {
  618. abbrev_end = end;
  619. }
  620. tprints("[");
  621. for (cur = start; cur < end; cur += sizeof(gid)) {
  622. if (cur > start)
  623. tprints(", ");
  624. if (cur >= abbrev_end) {
  625. tprints("...");
  626. break;
  627. }
  628. if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
  629. tprints("?");
  630. failed = 1;
  631. break;
  632. }
  633. tprintf("%lu", (unsigned long) gid);
  634. }
  635. tprints("]");
  636. if (failed)
  637. tprintf(" %#lx", tcp->u_arg[1]);
  638. }
  639. return 0;
  640. }
  641. int
  642. sys_getgroups(struct tcb *tcp)
  643. {
  644. unsigned long len;
  645. if (entering(tcp)) {
  646. len = tcp->u_arg[0];
  647. tprintf("%lu, ", len);
  648. } else {
  649. unsigned long size, start, cur, end, abbrev_end;
  650. GETGROUPS_T gid;
  651. int failed = 0;
  652. len = tcp->u_rval;
  653. if (len == 0) {
  654. tprints("[]");
  655. return 0;
  656. }
  657. start = tcp->u_arg[1];
  658. if (start == 0) {
  659. tprints("NULL");
  660. return 0;
  661. }
  662. if (tcp->u_arg[0] == 0) {
  663. tprintf("%#lx", start);
  664. return 0;
  665. }
  666. size = len * sizeof(gid);
  667. end = start + size;
  668. if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
  669. size / sizeof(gid) != len || end < start) {
  670. tprintf("%#lx", start);
  671. return 0;
  672. }
  673. if (abbrev(tcp)) {
  674. abbrev_end = start + max_strlen * sizeof(gid);
  675. if (abbrev_end < start)
  676. abbrev_end = end;
  677. } else {
  678. abbrev_end = end;
  679. }
  680. tprints("[");
  681. for (cur = start; cur < end; cur += sizeof(gid)) {
  682. if (cur > start)
  683. tprints(", ");
  684. if (cur >= abbrev_end) {
  685. tprints("...");
  686. break;
  687. }
  688. if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
  689. tprints("?");
  690. failed = 1;
  691. break;
  692. }
  693. tprintf("%lu", (unsigned long) gid);
  694. }
  695. tprints("]");
  696. if (failed)
  697. tprintf(" %#lx", tcp->u_arg[1]);
  698. }
  699. return 0;
  700. }
  701. int
  702. sys_setgroups32(struct tcb *tcp)
  703. {
  704. if (entering(tcp)) {
  705. unsigned long len, size, start, cur, end, abbrev_end;
  706. GETGROUPS32_T gid;
  707. int failed = 0;
  708. len = tcp->u_arg[0];
  709. tprintf("%lu, ", len);
  710. if (len == 0) {
  711. tprints("[]");
  712. return 0;
  713. }
  714. start = tcp->u_arg[1];
  715. if (start == 0) {
  716. tprints("NULL");
  717. return 0;
  718. }
  719. size = len * sizeof(gid);
  720. end = start + size;
  721. if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
  722. tprintf("%#lx", start);
  723. return 0;
  724. }
  725. if (abbrev(tcp)) {
  726. abbrev_end = start + max_strlen * sizeof(gid);
  727. if (abbrev_end < start)
  728. abbrev_end = end;
  729. } else {
  730. abbrev_end = end;
  731. }
  732. tprints("[");
  733. for (cur = start; cur < end; cur += sizeof(gid)) {
  734. if (cur > start)
  735. tprints(", ");
  736. if (cur >= abbrev_end) {
  737. tprints("...");
  738. break;
  739. }
  740. if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
  741. tprints("?");
  742. failed = 1;
  743. break;
  744. }
  745. tprintf("%lu", (unsigned long) gid);
  746. }
  747. tprints("]");
  748. if (failed)
  749. tprintf(" %#lx", tcp->u_arg[1]);
  750. }
  751. return 0;
  752. }
  753. int
  754. sys_getgroups32(struct tcb *tcp)
  755. {
  756. unsigned long len;
  757. if (entering(tcp)) {
  758. len = tcp->u_arg[0];
  759. tprintf("%lu, ", len);
  760. } else {
  761. unsigned long size, start, cur, end, abbrev_end;
  762. GETGROUPS32_T gid;
  763. int failed = 0;
  764. len = tcp->u_rval;
  765. if (len == 0) {
  766. tprints("[]");
  767. return 0;
  768. }
  769. start = tcp->u_arg[1];
  770. if (start == 0) {
  771. tprints("NULL");
  772. return 0;
  773. }
  774. size = len * sizeof(gid);
  775. end = start + size;
  776. if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
  777. size / sizeof(gid) != len || end < start) {
  778. tprintf("%#lx", start);
  779. return 0;
  780. }
  781. if (abbrev(tcp)) {
  782. abbrev_end = start + max_strlen * sizeof(gid);
  783. if (abbrev_end < start)
  784. abbrev_end = end;
  785. } else {
  786. abbrev_end = end;
  787. }
  788. tprints("[");
  789. for (cur = start; cur < end; cur += sizeof(gid)) {
  790. if (cur > start)
  791. tprints(", ");
  792. if (cur >= abbrev_end) {
  793. tprints("...");
  794. break;
  795. }
  796. if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
  797. tprints("?");
  798. failed = 1;
  799. break;
  800. }
  801. tprintf("%lu", (unsigned long) gid);
  802. }
  803. tprints("]");
  804. if (failed)
  805. tprintf(" %#lx", tcp->u_arg[1]);
  806. }
  807. return 0;
  808. }
  809. static void
  810. printargv(struct tcb *tcp, long addr)
  811. {
  812. union {
  813. unsigned int p32;
  814. unsigned long p64;
  815. char data[sizeof(long)];
  816. } cp;
  817. const char *sep;
  818. int n = 0;
  819. unsigned wordsize = current_wordsize;
  820. cp.p64 = 1;
  821. for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
  822. if (umoven(tcp, addr, wordsize, cp.data) < 0) {
  823. tprintf("%#lx", addr);
  824. return;
  825. }
  826. if (wordsize == 4)
  827. cp.p64 = cp.p32;
  828. if (cp.p64 == 0)
  829. break;
  830. tprints(sep);
  831. printstr(tcp, cp.p64, -1);
  832. addr += wordsize;
  833. }
  834. if (cp.p64)
  835. tprintf("%s...", sep);
  836. }
  837. static void
  838. printargc(const char *fmt, struct tcb *tcp, long addr)
  839. {
  840. int count;
  841. char *cp;
  842. for (count = 0; umove(tcp, addr, &cp) >= 0 && cp != NULL; count++) {
  843. addr += sizeof(char *);
  844. }
  845. tprintf(fmt, count, count == 1 ? "" : "s");
  846. }
  847. #if defined(SPARC) || defined(SPARC64)
  848. int
  849. sys_execv(struct tcb *tcp)
  850. {
  851. if (entering(tcp)) {
  852. printpath(tcp, tcp->u_arg[0]);
  853. if (!verbose(tcp))
  854. tprintf(", %#lx", tcp->u_arg[1]);
  855. else {
  856. tprints(", [");
  857. printargv(tcp, tcp->u_arg[1]);
  858. tprints("]");
  859. }
  860. }
  861. return 0;
  862. }
  863. #endif
  864. int
  865. sys_execve(struct tcb *tcp)
  866. {
  867. if (entering(tcp)) {
  868. extract_and_save_path(tcp, tcp->u_arg[0], FTRACE_NOK);
  869. }
  870. return 0;
  871. }
  872. #ifndef __WNOTHREAD
  873. #define __WNOTHREAD 0x20000000
  874. #endif
  875. #ifndef __WALL
  876. #define __WALL 0x40000000
  877. #endif
  878. #ifndef __WCLONE
  879. #define __WCLONE 0x80000000
  880. #endif
  881. static const struct xlat wait4_options[] = {
  882. { WNOHANG, "WNOHANG" },
  883. #ifndef WSTOPPED
  884. { WUNTRACED, "WUNTRACED" },
  885. #endif
  886. #ifdef WEXITED
  887. { WEXITED, "WEXITED" },
  888. #endif
  889. #ifdef WTRAPPED
  890. { WTRAPPED, "WTRAPPED" },
  891. #endif
  892. #ifdef WSTOPPED
  893. { WSTOPPED, "WSTOPPED" },
  894. #endif
  895. #ifdef WCONTINUED
  896. { WCONTINUED, "WCONTINUED" },
  897. #endif
  898. #ifdef WNOWAIT
  899. { WNOWAIT, "WNOWAIT" },
  900. #endif
  901. #ifdef __WCLONE
  902. { __WCLONE, "__WCLONE" },
  903. #endif
  904. #ifdef __WALL
  905. { __WALL, "__WALL" },
  906. #endif
  907. #ifdef __WNOTHREAD
  908. { __WNOTHREAD, "__WNOTHREAD" },
  909. #endif
  910. { 0, NULL },
  911. };
  912. #if !defined WCOREFLAG && defined WCOREFLG
  913. # define WCOREFLAG WCOREFLG
  914. #endif
  915. #ifndef WCOREFLAG
  916. # define WCOREFLAG 0x80
  917. #endif
  918. #ifndef WCOREDUMP
  919. # define WCOREDUMP(status) ((status) & 0200)
  920. #endif
  921. #ifndef W_STOPCODE
  922. # define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
  923. #endif
  924. #ifndef W_EXITCODE
  925. # define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
  926. #endif
  927. static int
  928. printstatus(int status)
  929. {
  930. int exited = 0;
  931. /*
  932. * Here is a tricky presentation problem. This solution
  933. * is still not entirely satisfactory but since there
  934. * are no wait status constructors it will have to do.
  935. */
  936. if (WIFSTOPPED(status)) {
  937. tprintf("[{WIFSTOPPED(s) && WSTOPSIG(s) == %s}",
  938. signame(WSTOPSIG(status)));
  939. status &= ~W_STOPCODE(WSTOPSIG(status));
  940. }
  941. else if (WIFSIGNALED(status)) {
  942. tprintf("[{WIFSIGNALED(s) && WTERMSIG(s) == %s%s}",
  943. signame(WTERMSIG(status)),
  944. WCOREDUMP(status) ? " && WCOREDUMP(s)" : "");
  945. status &= ~(W_EXITCODE(0, WTERMSIG(status)) | WCOREFLAG);
  946. }
  947. else if (WIFEXITED(status)) {
  948. tprintf("[{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
  949. WEXITSTATUS(status));
  950. exited = 1;
  951. status &= ~W_EXITCODE(WEXITSTATUS(status), 0);
  952. }
  953. else {
  954. tprintf("[%#x]", status);
  955. return 0;
  956. }
  957. if (status == 0)
  958. tprints("]");
  959. else
  960. tprintf(" | %#x]", status);
  961. return exited;
  962. }
  963. static int
  964. printwaitn(struct tcb *tcp, int n, int bitness)
  965. {
  966. int status;
  967. if (entering(tcp)) {
  968. /* On Linux, kernel-side pid_t is typedef'ed to int
  969. * on all arches. Also, glibc-2.8 truncates wait3 and wait4
  970. * pid argument to int on 64bit arches, producing,
  971. * for example, wait4(4294967295, ...) instead of -1
  972. * in strace. We have to use int here, not long.
  973. */
  974. int pid = tcp->u_arg[0];
  975. tprintf("%d, ", pid);
  976. } else {
  977. /* status */
  978. if (!tcp->u_arg[1])
  979. tprints("NULL");
  980. else if (syserror(tcp) || tcp->u_rval == 0)
  981. tprintf("%#lx", tcp->u_arg[1]);
  982. else if (umove(tcp, tcp->u_arg[1], &status) < 0)
  983. tprints("[?]");
  984. else
  985. printstatus(status);
  986. /* options */
  987. tprints(", ");
  988. printflags(wait4_options, tcp->u_arg[2], "W???");
  989. if (n == 4) {
  990. tprints(", ");
  991. /* usage */
  992. if (!tcp->u_arg[3])
  993. tprints("NULL");
  994. else if (tcp->u_rval > 0) {
  995. #ifdef ALPHA
  996. if (bitness)
  997. printrusage32(tcp, tcp->u_arg[3]);
  998. else
  999. #endif
  1000. printrusage(tcp, tcp->u_arg[3]);
  1001. }
  1002. else
  1003. tprintf("%#lx", tcp->u_arg[3]);
  1004. }
  1005. }
  1006. return 0;
  1007. }
  1008. int
  1009. sys_waitpid(struct tcb *tcp)
  1010. {
  1011. return printwaitn(tcp, 3, 0);
  1012. }
  1013. int
  1014. sys_wait4(struct tcb *tcp)
  1015. {
  1016. return printwaitn(tcp, 4, 0);
  1017. }
  1018. #ifdef ALPHA
  1019. int
  1020. sys_osf_wait4(struct tcb *tcp)
  1021. {
  1022. return printwaitn(tcp, 4, 1);
  1023. }
  1024. #endif
  1025. static const struct xlat waitid_types[] = {
  1026. { P_PID, "P_PID" },
  1027. #ifdef P_PPID
  1028. { P_PPID, "P_PPID" },
  1029. #endif
  1030. { P_PGID, "P_PGID" },
  1031. #ifdef P_SID
  1032. { P_SID, "P_SID" },
  1033. #endif
  1034. #ifdef P_CID
  1035. { P_CID, "P_CID" },
  1036. #endif
  1037. #ifdef P_UID
  1038. { P_UID, "P_UID" },
  1039. #endif
  1040. #ifdef P_GID
  1041. { P_GID, "P_GID" },
  1042. #endif
  1043. { P_ALL, "P_ALL" },
  1044. #ifdef P_LWPID
  1045. { P_LWPID, "P_LWPID" },
  1046. #endif
  1047. { 0, NULL },
  1048. };
  1049. int
  1050. sys_waitid(struct tcb *tcp)
  1051. {
  1052. siginfo_t si;
  1053. if (entering(tcp)) {
  1054. printxval(waitid_types, tcp->u_arg[0], "P_???");
  1055. tprintf(", %ld, ", tcp->u_arg[1]);
  1056. }
  1057. else {
  1058. /* siginfo */
  1059. if (!tcp->u_arg[2])
  1060. tprints("NULL");
  1061. else if (syserror(tcp))
  1062. tprintf("%#lx", tcp->u_arg[2]);
  1063. else if (umove(tcp, tcp->u_arg[2], &si) < 0)
  1064. tprints("{???}");
  1065. else
  1066. printsiginfo(&si, verbose(tcp));
  1067. /* options */
  1068. tprints(", ");
  1069. printflags(wait4_options, tcp->u_arg[3], "W???");
  1070. if (tcp->u_nargs > 4) {
  1071. /* usage */
  1072. tprints(", ");
  1073. if (!tcp->u_arg[4])
  1074. tprints("NULL");
  1075. else if (tcp->u_error)
  1076. tprintf("%#lx", tcp->u_arg[4]);
  1077. else
  1078. printrusage(tcp, tcp->u_arg[4]);
  1079. }
  1080. }
  1081. return 0;
  1082. }
  1083. int
  1084. sys_uname(struct tcb *tcp)
  1085. {
  1086. struct utsname uname;
  1087. if (exiting(tcp)) {
  1088. if (syserror(tcp) || !verbose(tcp))
  1089. tprintf("%#lx", tcp->u_arg[0]);
  1090. else if (umove(tcp, tcp->u_arg[0], &uname) < 0)
  1091. tprints("{...}");
  1092. else if (!abbrev(tcp)) {
  1093. tprintf("{sysname=\"%s\", nodename=\"%s\", ",
  1094. uname.sysname, uname.nodename);
  1095. tprintf("release=\"%s\", version=\"%s\", ",
  1096. uname.release, uname.version);
  1097. tprintf("machine=\"%s\"", uname.machine);
  1098. #ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
  1099. tprintf(", domainname=\"%s\"", uname.domainname);
  1100. #endif
  1101. tprints("}");
  1102. }
  1103. else
  1104. tprintf("{sys=\"%s\", node=\"%s\", ...}",
  1105. uname.sysname, uname.nodename);
  1106. }
  1107. return 0;
  1108. }
  1109. static const struct xlat ptrace_cmds[] = {
  1110. { PTRACE_TRACEME, "PTRACE_TRACEME" },
  1111. { PTRACE_PEEKTEXT, "PTRACE_PEEKTEXT" },
  1112. { PTRACE_PEEKDATA, "PTRACE_PEEKDATA" },
  1113. { PTRACE_PEEKUSER, "PTRACE_PEEKUSER" },
  1114. { PTRACE_POKETEXT, "PTRACE_POKETEXT" },
  1115. { PTRACE_POKEDATA, "PTRACE_POKEDATA" },
  1116. { PTRACE_POKEUSER, "PTRACE_POKEUSER" },
  1117. { PTRACE_CONT, "PTRACE_CONT" },
  1118. { PTRACE_KILL, "PTRACE_KILL" },
  1119. { PTRACE_SINGLESTEP, "PTRACE_SINGLESTEP" },
  1120. { PTRACE_ATTACH, "PTRACE_ATTACH" },
  1121. { PTRACE_DETACH, "PTRACE_DETACH" },
  1122. #ifdef PTRACE_GETREGS
  1123. { PTRACE_GETREGS, "PTRACE_GETREGS" },
  1124. #endif
  1125. #ifdef PTRACE_SETREGS
  1126. { PTRACE_SETREGS, "PTRACE_SETREGS" },
  1127. #endif
  1128. #ifdef PTRACE_GETFPREGS
  1129. { PTRACE_GETFPREGS, "PTRACE_GETFPREGS" },
  1130. #endif
  1131. #ifdef PTRACE_SETFPREGS
  1132. { PTRACE_SETFPREGS, "PTRACE_SETFPREGS" },
  1133. #endif
  1134. #ifdef PTRACE_GETFPXREGS
  1135. { PTRACE_GETFPXREGS, "PTRACE_GETFPXREGS" },
  1136. #endif
  1137. #ifdef PTRACE_SETFPXREGS
  1138. { PTRACE_SETFPXREGS, "PTRACE_SETFPXREGS" },
  1139. #endif
  1140. #ifdef PTRACE_GETVRREGS
  1141. { PTRACE_GETVRREGS, "PTRACE_GETVRREGS" },
  1142. #endif
  1143. #ifdef PTRACE_SETVRREGS
  1144. { PTRACE_SETVRREGS, "PTRACE_SETVRREGS" },
  1145. #endif
  1146. #ifdef PTRACE_SETOPTIONS
  1147. { PTRACE_SETOPTIONS, "PTRACE_SETOPTIONS" },
  1148. #endif
  1149. #ifdef PTRACE_GETEVENTMSG
  1150. { PTRACE_GETEVENTMSG, "PTRACE_GETEVENTMSG" },
  1151. #endif
  1152. #ifdef PTRACE_GETSIGINFO
  1153. { PTRACE_GETSIGINFO, "PTRACE_GETSIGINFO" },
  1154. #endif
  1155. #ifdef PTRACE_SETSIGINFO
  1156. { PTRACE_SETSIGINFO, "PTRACE_SETSIGINFO" },
  1157. #endif
  1158. #ifdef PTRACE_GETREGSET
  1159. { PTRACE_GETREGSET, "PTRACE_GETREGSET" },
  1160. #endif
  1161. #ifdef PTRACE_SETREGSET
  1162. { PTRACE_SETREGSET, "PTRACE_SETREGSET" },
  1163. #endif
  1164. #ifdef PTRACE_SET_SYSCALL
  1165. { PTRACE_SET_SYSCALL, "PTRACE_SET_SYSCALL" },
  1166. #endif
  1167. #ifdef PTRACE_SEIZE
  1168. { PTRACE_SEIZE, "PTRACE_SEIZE" },
  1169. #endif
  1170. #ifdef PTRACE_INTERRUPT
  1171. { PTRACE_INTERRUPT, "PTRACE_INTERRUPT" },
  1172. #endif
  1173. #ifdef PTRACE_LISTEN
  1174. { PTRACE_LISTEN, "PTRACE_LISTEN" },
  1175. #endif
  1176. { PTRACE_SYSCALL, "PTRACE_SYSCALL" },
  1177. { 0, NULL },
  1178. };
  1179. #ifdef PTRACE_SETOPTIONS
  1180. static const struct xlat ptrace_setoptions_flags[] = {
  1181. # ifdef PTRACE_O_TRACESYSGOOD
  1182. { PTRACE_O_TRACESYSGOOD,"PTRACE_O_TRACESYSGOOD" },
  1183. # endif
  1184. # ifdef PTRACE_O_TRACEFORK
  1185. { PTRACE_O_TRACEFORK, "PTRACE_O_TRACEFORK" },
  1186. # endif
  1187. # ifdef PTRACE_O_TRACEVFORK
  1188. { PTRACE_O_TRACEVFORK, "PTRACE_O_TRACEVFORK" },
  1189. # endif
  1190. # ifdef PTRACE_O_TRACECLONE
  1191. { PTRACE_O_TRACECLONE, "PTRACE_O_TRACECLONE" },
  1192. # endif
  1193. # ifdef PTRACE_O_TRACEEXEC
  1194. { PTRACE_O_TRACEEXEC, "PTRACE_O_TRACEEXEC" },
  1195. # endif
  1196. # ifdef PTRACE_O_TRACEVFORKDONE
  1197. { PTRACE_O_TRACEVFORKDONE,"PTRACE_O_TRACEVFORKDONE"},
  1198. # endif
  1199. # ifdef PTRACE_O_TRACEEXIT
  1200. { PTRACE_O_TRACEEXIT, "PTRACE_O_TRACEEXIT" },
  1201. # endif
  1202. { 0, NULL },
  1203. };
  1204. #endif /* PTRACE_SETOPTIONS */
  1205. #define uoff(member) offsetof(struct user, member)
  1206. const struct xlat struct_user_offsets[] = {
  1207. #if defined(S390) || defined(S390X)
  1208. { PT_PSWMASK, "psw_mask" },
  1209. { PT_PSWADDR, "psw_addr" },
  1210. { PT_GPR0, "gpr0" },
  1211. { PT_GPR1, "gpr1" },
  1212. { PT_GPR2, "gpr2" },
  1213. { PT_GPR3, "gpr3" },
  1214. { PT_GPR4, "gpr4" },
  1215. { PT_GPR5, "gpr5" },
  1216. { PT_GPR6, "gpr6" },
  1217. { PT_GPR7, "gpr7" },
  1218. { PT_GPR8, "gpr8" },
  1219. { PT_GPR9, "gpr9" },
  1220. { PT_GPR10, "gpr10" },
  1221. { PT_GPR11, "gpr11" },
  1222. { PT_GPR12, "gpr12" },
  1223. { PT_GPR13, "gpr13" },
  1224. { PT_GPR14, "gpr14" },
  1225. { PT_GPR15, "gpr15" },
  1226. { PT_ACR0, "acr0" },
  1227. { PT_ACR1, "acr1" },
  1228. { PT_ACR2, "acr2" },
  1229. { PT_ACR3, "acr3" },
  1230. { PT_ACR4, "acr4" },
  1231. { PT_ACR5, "acr5" },
  1232. { PT_ACR6, "acr6" },
  1233. { PT_ACR7, "acr7" },
  1234. { PT_ACR8, "acr8" },
  1235. { PT_ACR9, "acr9" },
  1236. { PT_ACR10, "acr10" },
  1237. { PT_ACR11, "acr11" },
  1238. { PT_ACR12, "acr12" },
  1239. { PT_ACR13, "acr13" },
  1240. { PT_ACR14, "acr14" },
  1241. { PT_ACR15, "acr15" },
  1242. { PT_ORIGGPR2, "orig_gpr2" },
  1243. { PT_FPC, "fpc" },
  1244. #if defined(S390)
  1245. { PT_FPR0_HI, "fpr0.hi" },
  1246. { PT_FPR0_LO, "fpr0.lo" },
  1247. { PT_FPR1_HI, "fpr1.hi" },
  1248. { PT_FPR1_LO, "fpr1.lo" },
  1249. { PT_FPR2_HI, "fpr2.hi" },
  1250. { PT_FPR2_LO, "fpr2.lo" },
  1251. { PT_FPR3_HI, "fpr3.hi" },
  1252. { PT_FPR3_LO, "fpr3.lo" },
  1253. { PT_FPR4_HI, "fpr4.hi" },
  1254. { PT_FPR4_LO, "fpr4.lo" },
  1255. { PT_FPR5_HI, "fpr5.hi" },
  1256. { PT_FPR5_LO, "fpr5.lo" },
  1257. { PT_FPR6_HI, "fpr6.hi" },
  1258. { PT_FPR6_LO, "fpr6.lo" },
  1259. { PT_FPR7_HI, "fpr7.hi" },
  1260. { PT_FPR7_LO, "fpr7.lo" },
  1261. { PT_FPR8_HI, "fpr8.hi" },
  1262. { PT_FPR8_LO, "fpr8.lo" },
  1263. { PT_FPR9_HI, "fpr9.hi" },
  1264. { PT_FPR9_LO, "fpr9.lo" },
  1265. { PT_FPR10_HI, "fpr10.hi" },
  1266. { PT_FPR10_LO, "fpr10.lo" },
  1267. { PT_FPR11_HI, "fpr11.hi" },
  1268. { PT_FPR11_LO, "fpr11.lo" },
  1269. { PT_FPR12_HI, "fpr12.hi" },
  1270. { PT_FPR12_LO, "fpr12.lo" },
  1271. { PT_FPR13_HI, "fpr13.hi" },
  1272. { PT_FPR13_LO, "fpr13.lo" },
  1273. { PT_FPR14_HI, "fpr14.hi" },
  1274. { PT_FPR14_LO, "fpr14.lo" },
  1275. { PT_FPR15_HI, "fpr15.hi" },
  1276. { PT_FPR15_LO, "fpr15.lo" },
  1277. #endif
  1278. #if defined(S390X)
  1279. { PT_FPR0, "fpr0" },
  1280. { PT_FPR1, "fpr1" },
  1281. { PT_FPR2, "fpr2" },
  1282. { PT_FPR3, "fpr3" },
  1283. { PT_FPR4, "fpr4" },
  1284. { PT_FPR5, "fpr5" },
  1285. { PT_FPR6, "fpr6" },
  1286. { PT_FPR7, "fpr7" },
  1287. { PT_FPR8, "fpr8" },
  1288. { PT_FPR9, "fpr9" },
  1289. { PT_FPR10, "fpr10" },
  1290. { PT_FPR11, "fpr11" },
  1291. { PT_FPR12, "fpr12" },
  1292. { PT_FPR13, "fpr13" },
  1293. { PT_FPR14, "fpr14" },
  1294. { PT_FPR15, "fpr15" },
  1295. #endif
  1296. { PT_CR_9, "cr9" },
  1297. { PT_CR_10, "cr10" },
  1298. { PT_CR_11, "cr11" },
  1299. { PT_IEEE_IP, "ieee_exception_ip" },
  1300. #elif defined(SPARC)
  1301. /* XXX No support for these offsets yet. */
  1302. #elif defined(HPPA)
  1303. /* XXX No support for these offsets yet. */
  1304. #elif defined(POWERPC)
  1305. # ifndef PT_ORIG_R3
  1306. # define PT_ORIG_R3 34
  1307. # endif
  1308. # define REGSIZE (sizeof(unsigned long))
  1309. { REGSIZE*PT_R0, "r0" },
  1310. { REGSIZE*PT_R1, "r1" },
  1311. { REGSIZE*PT_R2, "r2" },
  1312. { REGSIZE*PT_R3, "r3" },
  1313. { REGSIZE*PT_R4, "r4" },
  1314. { REGSIZE*PT_R5, "r5" },
  1315. { REGSIZE*PT_R6, "r6" },
  1316. { REGSIZE*PT_R7, "r7" },
  1317. { REGSIZE*PT_R8, "r8" },
  1318. { REGSIZE*PT_R9, "r9" },
  1319. { REGSIZE*PT_R10, "r10" },
  1320. { REGSIZE*PT_R11, "r11" },
  1321. { REGSIZE*PT_R12, "r12" },
  1322. { REGSIZE*PT_R13, "r13" },
  1323. { REGSIZE*PT_R14, "r14" },
  1324. { REGSIZE*PT_R15, "r15" },
  1325. { REGSIZE*PT_R16, "r16" },
  1326. { REGSIZE*PT_R17, "r17" },
  1327. { REGSIZE*PT_R18, "r18" },
  1328. { REGSIZE*PT_R19, "r19" },
  1329. { REGSIZE*PT_R20, "r20" },
  1330. { REGSIZE*PT_R21, "r21" },
  1331. { REGSIZE*PT_R22, "r22" },
  1332. { REGSIZE*PT_R23, "r23" },
  1333. { REGSIZE*PT_R24, "r24" },
  1334. { REGSIZE*PT_R25, "r25" },
  1335. { REGSIZE*PT_R26, "r26" },
  1336. { REGSIZE*PT_R27, "r27" },
  1337. { REGSIZE*PT_R28, "r28" },
  1338. { REGSIZE*PT_R29, "r29" },
  1339. { REGSIZE*PT_R30, "r30" },
  1340. { REGSIZE*PT_R31, "r31" },
  1341. { REGSIZE*PT_NIP, "NIP" },
  1342. { REGSIZE*PT_MSR, "MSR" },
  1343. { REGSIZE*PT_ORIG_R3, "ORIG_R3" },
  1344. { REGSIZE*PT_CTR, "CTR" },
  1345. { REGSIZE*PT_LNK, "LNK" },
  1346. { REGSIZE*PT_XER, "XER" },
  1347. { REGSIZE*PT_CCR, "CCR" },
  1348. { REGSIZE*PT_FPR0, "FPR0" },
  1349. # undef REGSIZE
  1350. #elif defined(ALPHA)
  1351. { 0, "r0" },
  1352. { 1, "r1" },
  1353. { 2, "r2" },
  1354. { 3, "r3" },
  1355. { 4, "r4" },
  1356. { 5, "r5" },
  1357. { 6, "r6" },
  1358. { 7, "r7" },
  1359. { 8, "r8" },
  1360. { 9, "r9" },
  1361. { 10, "r10" },
  1362. { 11, "r11" },
  1363. { 12, "r12" },
  1364. { 13, "r13" },
  1365. { 14, "r14" },
  1366. { 15, "r15" },
  1367. { 16, "r16" },
  1368. { 17, "r17" },
  1369. { 18, "r18" },
  1370. { 19, "r19" },
  1371. { 20, "r20" },
  1372. { 21, "r21" },
  1373. { 22, "r22" },
  1374. { 23, "r23" },
  1375. { 24, "r24" },
  1376. { 25, "r25" },
  1377. { 26, "r26" },
  1378. { 27, "r27" },
  1379. { 28, "r28" },
  1380. { 29, "gp" },
  1381. { 30, "fp" },
  1382. { 31, "zero" },
  1383. { 32, "fp0" },
  1384. { 33, "fp" },
  1385. { 34, "fp2" },
  1386. { 35, "fp3" },
  1387. { 36, "fp4" },
  1388. { 37, "fp5" },
  1389. { 38, "fp6" },
  1390. { 39, "fp7" },
  1391. { 40, "fp8" },
  1392. { 41, "fp9" },
  1393. { 42, "fp10" },
  1394. { 43, "fp11" },
  1395. { 44, "fp12" },
  1396. { 45, "fp13" },
  1397. { 46, "fp14" },
  1398. { 47, "fp15" },
  1399. { 48, "fp16" },
  1400. { 49, "fp17" },
  1401. { 50, "fp18" },
  1402. { 51, "fp19" },
  1403. { 52, "fp20" },
  1404. { 53, "fp21" },
  1405. { 54, "fp22" },
  1406. { 55, "fp23" },
  1407. { 56, "fp24" },
  1408. { 57, "fp25" },
  1409. { 58, "fp26" },
  1410. { 59, "fp27" },
  1411. { 60, "fp28" },
  1412. { 61, "fp29" },
  1413. { 62, "fp30" },
  1414. { 63, "fp31" },
  1415. { 64, "pc" },
  1416. #elif defined(IA64)
  1417. { PT_F32, "f32" }, { PT_F33, "f33" }, { PT_F34, "f34" },
  1418. { PT_F35, "f35" }, { PT_F36, "f36" }, { PT_F37, "f37" },
  1419. { PT_F38, "f38" }, { PT_F39, "f39" }, { PT_F40, "f40" },
  1420. { PT_F41, "f41" }, { PT_F42, "f42" }, { PT_F43, "f43" },
  1421. { PT_F44, "f44" }, { PT_F45, "f45" }, { PT_F46, "f46" },
  1422. { PT_F47, "f47" }, { PT_F48, "f48" }, { PT_F49, "f49" },
  1423. { PT_F50, "f50" }, { PT_F51, "f51" }, { PT_F52, "f52" },
  1424. { PT_F53, "f53" }, { PT_F54, "f54" }, { PT_F55, "f55" },
  1425. { PT_F56, "f56" }, { PT_F57, "f57" }, { PT_F58, "f58" },
  1426. { PT_F59, "f59" }, { PT_F60, "f60" }, { PT_F61, "f61" },
  1427. { PT_F62, "f62" }, { PT_F63, "f63" }, { PT_F64, "f64" },
  1428. { PT_F65, "f65" }, { PT_F66, "f66" }, { PT_F67, "f67" },
  1429. { PT_F68, "f68" }, { PT_F69, "f69" }, { PT_F70, "f70" },
  1430. { PT_F71, "f71" }, { PT_F72, "f72" }, { PT_F73, "f73" },
  1431. { PT_F74, "f74" }, { PT_F75, "f75" }, { PT_F76, "f76" },
  1432. { PT_F77, "f77" }, { PT_F78, "f78" }, { PT_F79, "f79" },
  1433. { PT_F80, "f80" }, { PT_F81, "f81" }, { PT_F82, "f82" },
  1434. { PT_F83, "f83" }, { PT_F84, "f84" }, { PT_F85, "f85" },
  1435. { PT_F86, "f86" }, { PT_F87, "f87" }, { PT_F88, "f88" },
  1436. { PT_F89, "f89" }, { PT_F90, "f90" }, { PT_F91, "f91" },
  1437. { PT_F92, "f92" }, { PT_F93, "f93" }, { PT_F94, "f94" },
  1438. { PT_F95, "f95" }, { PT_F96, "f96" }, { PT_F97, "f97" },
  1439. { PT_F98, "f98" }, { PT_F99, "f99" }, { PT_F100, "f100" },
  1440. { PT_F101, "f101" }, { PT_F102, "f102" }, { PT_F103, "f103" },
  1441. { PT_F104, "f104" }, { PT_F105, "f105" }, { PT_F106, "f106" },
  1442. { PT_F107, "f107" }, { PT_F108, "f108" }, { PT_F109, "f109" },
  1443. { PT_F110, "f110" }, { PT_F111, "f111" }, { PT_F112, "f112" },
  1444. { PT_F113, "f113" }, { PT_F114, "f114" }, { PT_F115, "f115" },
  1445. { PT_F116, "f116" }, { PT_F117, "f117" }, { PT_F118, "f118" },
  1446. { PT_F119, "f119" }, { PT_F120, "f120" }, { PT_F121, "f121" },
  1447. { PT_F122, "f122" }, { PT_F123, "f123" }, { PT_F124, "f124" },
  1448. { PT_F125, "f125" }, { PT_F126, "f126" }, { PT_F127, "f127" },
  1449. /* switch stack: */
  1450. { PT_F2, "f2" }, { PT_F3, "f3" }, { PT_F4, "f4" },
  1451. { PT_F5, "f5" }, { PT_F10, "f10" }, { PT_F11, "f11" },
  1452. { PT_F12, "f12" }, { PT_F13, "f13" }, { PT_F14, "f14" },
  1453. { PT_F15, "f15" }, { PT_F16, "f16" }, { PT_F17, "f17" },
  1454. { PT_F18, "f18" }, { PT_F19, "f19" }, { PT_F20, "f20" },
  1455. { PT_F21, "f21" }, { PT_F22, "f22" }, { PT_F23, "f23" },
  1456. { PT_F24, "f24" }, { PT_F25, "f25" }, { PT_F26, "f26" },
  1457. { PT_F27, "f27" }, { PT_F28, "f28" }, { PT_F29, "f29" },
  1458. { PT_F30, "f30" }, { PT_F31, "f31" }, { PT_R4, "r4" },
  1459. { PT_R5, "r5" }, { PT_R6, "r6" }, { PT_R7, "r7" },
  1460. { PT_B1, "b1" }, { PT_B2, "b2" }, { PT_B3, "b3" },
  1461. { PT_B4, "b4" }, { PT_B5, "b5" },
  1462. { PT_AR_EC, "ar.ec" }, { PT_AR_LC, "ar.lc" },
  1463. /* pt_regs */
  1464. { PT_CR_IPSR, "psr" }, { PT_CR_IIP, "ip" },
  1465. { PT_CFM, "cfm" }, { PT_AR_UNAT, "ar.unat" },
  1466. { PT_AR_PFS, "ar.pfs" }, { PT_AR_RSC, "ar.rsc" },
  1467. { PT_AR_RNAT, "ar.rnat" }, { PT_AR_BSPSTORE, "ar.bspstore" },
  1468. { PT_PR, "pr" }, { PT_B6, "b6" }, { PT_AR_BSP, "ar.bsp" },
  1469. { PT_R1, "r1" }, { PT_R2, "r2" }, { PT_R3, "r3" },
  1470. { PT_R12, "r12" }, { PT_R13, "r13" }, { PT_R14, "r14" },
  1471. { PT_R15, "r15" }, { PT_R8, "r8" }, { PT_R9, "r9" },
  1472. { PT_R10, "r10" }, { PT_R11, "r11" }, { PT_R16, "r16" },
  1473. { PT_R17, "r17" }, { PT_R18, "r18" }, { PT_R19, "r19" },
  1474. { PT_R20, "r20" }, { PT_R21, "r21" }, { PT_R22, "r22" },
  1475. { PT_R23, "r23" }, { PT_R24, "r24" }, { PT_R25, "r25" },
  1476. { PT_R26, "r26" }, { PT_R27, "r27" }, { PT_R28, "r28" },
  1477. { PT_R29, "r29" }, { PT_R30, "r30" }, { PT_R31, "r31" },
  1478. { PT_AR_CCV, "ar.ccv" }, { PT_AR_FPSR, "ar.fpsr" },
  1479. { PT_B0, "b0" }, { PT_B7, "b7" }, { PT_F6, "f6" },
  1480. { PT_F7, "f7" }, { PT_F8, "f8" }, { PT_F9, "f9" },
  1481. # ifdef PT_AR_CSD
  1482. { PT_AR_CSD, "ar.csd" },
  1483. # endif
  1484. # ifdef PT_AR_SSD
  1485. { PT_AR_SSD, "ar.ssd" },
  1486. # endif
  1487. { PT_DBR, "dbr" }, { PT_IBR, "ibr" }, { PT_PMD, "pmd" },
  1488. #elif defined(I386)
  1489. { 4*EBX, "4*EBX" },
  1490. { 4*ECX, "4*ECX" },
  1491. { 4*EDX, "4*EDX" },
  1492. { 4*ESI, "4*ESI" },
  1493. { 4*EDI, "4*EDI" },
  1494. { 4*EBP, "4*EBP" },
  1495. { 4*EAX, "4*EAX" },
  1496. { 4*DS, "4*DS" },
  1497. { 4*ES, "4*ES" },
  1498. { 4*FS, "4*FS" },
  1499. { 4*GS, "4*GS" },
  1500. { 4*ORIG_EAX, "4*ORIG_EAX" },
  1501. { 4*EIP, "4*EIP" },
  1502. { 4*CS, "4*CS" },
  1503. { 4*EFL, "4*EFL" },
  1504. { 4*UESP, "4*UESP" },
  1505. { 4*SS, "4*SS" },
  1506. #elif defined(X86_64) || defined(X32)
  1507. { 8*R15, "8*R15" },
  1508. { 8*R14, "8*R14" },
  1509. { 8*R13, "8*R13" },
  1510. { 8*R12, "8*R12" },
  1511. { 8*RBP, "8*RBP" },
  1512. { 8*RBX, "8*RBX" },
  1513. { 8*R11, "8*R11" },
  1514. { 8*R10, "8*R10" },
  1515. { 8*R9, "8*R9" },
  1516. { 8*R8, "8*R8" },
  1517. { 8*RAX, "8*RAX" },
  1518. { 8*RCX, "8*RCX" },
  1519. { 8*RDX, "8*RDX" },
  1520. { 8*RSI, "8*RSI" },
  1521. { 8*RDI, "8*RDI" },
  1522. { 8*ORIG_RAX, "8*ORIG_RAX" },
  1523. { 8*RIP, "8*RIP" },
  1524. { 8*CS, "8*CS" },
  1525. { 8*EFLAGS, "8*EFL" },
  1526. { 8*RSP, "8*RSP" },
  1527. { 8*SS, "8*SS" },
  1528. #elif defined(M68K)
  1529. { 4*PT_D1, "4*PT_D1" },
  1530. { 4*PT_D2, "4*PT_D2" },
  1531. { 4*PT_D3, "4*PT_D3" },
  1532. { 4*PT_D4, "4*PT_D4" },
  1533. { 4*PT_D5, "4*PT_D5" },
  1534. { 4*PT_D6, "4*PT_D6" },
  1535. { 4*PT_D7, "4*PT_D7" },
  1536. { 4*PT_A0, "4*PT_A0" },
  1537. { 4*PT_A1, "4*PT_A1" },
  1538. { 4*PT_A2, "4*PT_A2" },
  1539. { 4*PT_A3, "4*PT_A3" },
  1540. { 4*PT_A4, "4*PT_A4" },
  1541. { 4*PT_A5, "4*PT_A5" },
  1542. { 4*PT_A6, "4*PT_A6" },
  1543. { 4*PT_D0, "4*PT_D0" },
  1544. { 4*PT_USP, "4*PT_USP" },
  1545. { 4*PT_ORIG_D0, "4*PT_ORIG_D0" },
  1546. { 4*PT_SR, "4*PT_SR" },
  1547. { 4*PT_PC, "4*PT_PC" },
  1548. #elif defined(SH)
  1549. { 4*REG_REG0, "4*REG_REG0" },
  1550. { 4*(REG_REG0+1), "4*REG_REG1" },
  1551. { 4*(REG_REG0+2), "4*REG_REG2" },
  1552. { 4*(REG_REG0+3), "4*REG_REG3" },
  1553. { 4*(REG_REG0+4), "4*REG_REG4" },
  1554. { 4*(REG_REG0+5), "4*REG_REG5" },
  1555. { 4*(REG_REG0+6), "4*REG_REG6" },
  1556. { 4*(REG_REG0+7), "4*REG_REG7" },
  1557. { 4*(REG_REG0+8), "4*REG_REG8" },
  1558. { 4*(REG_REG0+9), "4*REG_REG9" },
  1559. { 4*(REG_REG0+10), "4*REG_REG10" },
  1560. { 4*(REG_REG0+11), "4*REG_REG11" },
  1561. { 4*(REG_REG0+12), "4*REG_REG12" },
  1562. { 4*(REG_REG0+13), "4*REG_REG13" },
  1563. { 4*(REG_REG0+14), "4*REG_REG14" },
  1564. { 4*REG_REG15, "4*REG_REG15" },
  1565. { 4*REG_PC, "4*REG_PC" },
  1566. { 4*REG_PR, "4*REG_PR" },
  1567. { 4*REG_SR, "4*REG_SR" },
  1568. { 4*REG_GBR, "4*REG_GBR" },
  1569. { 4*REG_MACH, "4*REG_MACH" },
  1570. { 4*REG_MACL, "4*REG_MACL" },
  1571. { 4*REG_SYSCALL, "4*REG_SYSCALL" },
  1572. { 4*REG_FPUL, "4*REG_FPUL" },
  1573. { 4*REG_FPREG0, "4*REG_FPREG0" },
  1574. { 4*(REG_FPREG0+1), "4*REG_FPREG1" },
  1575. { 4*(REG_FPREG0+2), "4*REG_FPREG2" },
  1576. { 4*(REG_FPREG0+3), "4*REG_FPREG3" },
  1577. { 4*(REG_FPREG0+4), "4*REG_FPREG4" },
  1578. { 4*(REG_FPREG0+5), "4*REG_FPREG5" },
  1579. { 4*(REG_FPREG0+6), "4*REG_FPREG6" },
  1580. { 4*(REG_FPREG0+7), "4*REG_FPREG7" },
  1581. { 4*(REG_FPREG0+8), "4*REG_FPREG8" },
  1582. { 4*(REG_FPREG0+9), "4*REG_FPREG9" },
  1583. { 4*(REG_FPREG0+10), "4*REG_FPREG10" },
  1584. { 4*(REG_FPREG0+11), "4*REG_FPREG11" },
  1585. { 4*(REG_FPREG0+12), "4*REG_FPREG12" },
  1586. { 4*(REG_FPREG0+13), "4*REG_FPREG13" },
  1587. { 4*(REG_FPREG0+14), "4*REG_FPREG14" },
  1588. { 4*REG_FPREG15, "4*REG_FPREG15" },
  1589. # ifdef REG_XDREG0
  1590. { 4*REG_XDREG0, "4*REG_XDREG0" },
  1591. { 4*(REG_XDREG0+2), "4*REG_XDREG2" },
  1592. { 4*(REG_XDREG0+4), "4*REG_XDREG4" },
  1593. { 4*(REG_XDREG0+6), "4*REG_XDREG6" },
  1594. { 4*(REG_XDREG0+8), "4*REG_XDREG8" },
  1595. { 4*(REG_XDREG0+10), "4*REG_XDREG10" },
  1596. { 4*(REG_XDREG0+12), "4*REG_XDREG12" },
  1597. { 4*REG_XDREG14, "4*REG_XDREG14" },
  1598. # endif
  1599. { 4*REG_FPSCR, "4*REG_FPSCR" },
  1600. #elif defined(SH64)
  1601. { 0, "PC(L)" },
  1602. { 4, "PC(U)" },
  1603. { 8, "SR(L)" },
  1604. { 12, "SR(U)" },
  1605. { 16, "syscall no.(L)" },
  1606. { 20, "syscall_no.(U)" },
  1607. { 24, "R0(L)" },
  1608. { 28, "R0(U)" },
  1609. { 32, "R1(L)" },
  1610. { 36, "R1(U)" },
  1611. { 40, "R2(L)" },
  1612. { 44, "R2(U)" },
  1613. { 48, "R3(L)" },
  1614. { 52, "R3(U)" },
  1615. { 56, "R4(L)" },
  1616. { 60, "R4(U)" },
  1617. { 64, "R5(L)" },
  1618. { 68, "R5(U)" },
  1619. { 72, "R6(L)" },
  1620. { 76, "R6(U)" },
  1621. { 80, "R7(L)" },
  1622. { 84, "R7(U)" },
  1623. { 88, "R8(L)" },
  1624. { 92, "R8(U)" },
  1625. { 96, "R9(L)" },
  1626. { 100, "R9(U)" },
  1627. { 104, "R10(L)" },
  1628. { 108, "R10(U)" },
  1629. { 112, "R11(L)" },
  1630. { 116, "R11(U)" },
  1631. { 120, "R12(L)" },
  1632. { 124, "R12(U)" },
  1633. { 128, "R13(L)" },
  1634. { 132, "R13(U)" },
  1635. { 136, "R14(L)" },
  1636. { 140, "R14(U)" },
  1637. { 144, "R15(L)" },
  1638. { 148, "R15(U)" },
  1639. { 152, "R16(L)" },
  1640. { 156, "R16(U)" },
  1641. { 160, "R17(L)" },
  1642. { 164, "R17(U)" },
  1643. { 168, "R18(L)" },
  1644. { 172, "R18(U)" },
  1645. { 176, "R19(L)" },
  1646. { 180, "R19(U)" },
  1647. { 184, "R20(L)" },
  1648. { 188, "R20(U)" },
  1649. { 192, "R21(L)" },
  1650. { 196, "R21(U)" },
  1651. { 200, "R22(L)" },
  1652. { 204, "R22(U)" },
  1653. { 208, "R23(L)" },
  1654. { 212, "R23(U)" },
  1655. { 216, "R24(L)" },
  1656. { 220, "R24(U)" },
  1657. { 224, "R25(L)" },
  1658. { 228, "R25(U)" },
  1659. { 232, "R26(L)" },
  1660. { 236, "R26(U)" },
  1661. { 240, "R27(L)" },
  1662. { 244, "R27(U)" },
  1663. { 248, "R28(L)" },
  1664. { 252, "R28(U)" },
  1665. { 256, "R29(L)" },
  1666. { 260, "R29(U)" },
  1667. { 264, "R30(L)" },
  1668. { 268, "R30(U)" },
  1669. { 272, "R31(L)" },
  1670. { 276, "R31(U)" },
  1671. { 280, "R32(L)" },
  1672. { 284, "R32(U)" },
  1673. { 288, "R33(L)" },
  1674. { 292, "R33(U)" },
  1675. { 296, "R34(L)" },
  1676. { 300, "R34(U)" },
  1677. { 304, "R35(L)" },
  1678. { 308, "R35(U)" },
  1679. { 312, "R36(L)" },
  1680. { 316, "R36(U)" },
  1681. { 320, "R37(L)" },
  1682. { 324, "R37(U)" },
  1683. { 328, "R38(L)" },
  1684. { 332, "R38(U)" },
  1685. { 336, "R39(L)" },
  1686. { 340, "R39(U)" },
  1687. { 344, "R40(L)" },
  1688. { 348, "R40(U)" },
  1689. { 352, "R41(L)" },
  1690. { 356, "R41(U)" },
  1691. { 360, "R42(L)" },
  1692. { 364, "R42(U)" },
  1693. { 368, "R43(L)" },
  1694. { 372, "R43(U)" },
  1695. { 376, "R44(L)" },
  1696. { 380, "R44(U)" },
  1697. { 384, "R45(L)" },
  1698. { 388, "R45(U)" },
  1699. { 392, "R46(L)" },
  1700. { 396, "R46(U)" },
  1701. { 400, "R47(L)" },
  1702. { 404, "R47(U)" },
  1703. { 408, "R48(L)" },
  1704. { 412, "R48(U)" },
  1705. { 416, "R49(L)" },
  1706. { 420, "R49(U)" },
  1707. { 424, "R50(L)" },
  1708. { 428, "R50(U)" },
  1709. { 432, "R51(L)" },
  1710. { 436, "R51(U)" },
  1711. { 440, "R52(L)" },
  1712. { 444, "R52(U)" },
  1713. { 448, "R53(L)" },
  1714. { 452, "R53(U)" },
  1715. { 456, "R54(L)" },
  1716. { 460, "R54(U)" },
  1717. { 464, "R55(L)" },
  1718. { 468, "R55(U)" },
  1719. { 472, "R56(L)" },
  1720. { 476, "R56(U)" },
  1721. { 480, "R57(L)" },
  1722. { 484, "R57(U)" },
  1723. { 488, "R58(L)" },
  1724. { 492, "R58(U)" },
  1725. { 496, "R59(L)" },
  1726. { 500, "R59(U)" },
  1727. { 504, "R60(L)" },
  1728. { 508, "R60(U)" },
  1729. { 512, "R61(L)" },
  1730. { 516, "R61(U)" },
  1731. { 520, "R62(L)" },
  1732. { 524, "R62(U)" },
  1733. { 528, "TR0(L)" },
  1734. { 532, "TR0(U)" },
  1735. { 536, "TR1(L)" },
  1736. { 540, "TR1(U)" },
  1737. { 544, "TR2(L)" },
  1738. { 548, "TR2(U)" },
  1739. { 552, "TR3(L)" },
  1740. { 556, "TR3(U)" },
  1741. { 560, "TR4(L)" },
  1742. { 564, "TR4(U)" },
  1743. { 568, "TR5(L)" },
  1744. { 572, "TR5(U)" },
  1745. { 576, "TR6(L)" },
  1746. { 580, "TR6(U)" },
  1747. { 584, "TR7(L)" },
  1748. { 588, "TR7(U)" },
  1749. /* This entry is in case pt_regs contains dregs (depends on
  1750. the kernel build options). */
  1751. { uoff(regs), "offsetof(struct user, regs)" },
  1752. { uoff(fpu), "offsetof(struct user, fpu)" },
  1753. #elif defined(ARM)
  1754. { uoff(regs.ARM_r0), "r0" },
  1755. { uoff(regs.ARM_r1), "r1" },
  1756. { uoff(regs.ARM_r2), "r2" },
  1757. { uoff(regs.ARM_r3), "r3" },
  1758. { uoff(regs.ARM_r4), "r4" },
  1759. { uoff(regs.ARM_r5), "r5" },
  1760. { uoff(regs.ARM_r6), "r6" },
  1761. { uoff(regs.ARM_r7), "r7" },
  1762. { uoff(regs.ARM_r8), "r8" },
  1763. { uoff(regs.ARM_r9), "r9" },
  1764. { uoff(regs.ARM_r10), "r10" },
  1765. { uoff(regs.ARM_fp), "fp" },
  1766. { uoff(regs.ARM_ip), "ip" },
  1767. { uoff(regs.ARM_sp), "sp" },
  1768. { uoff(regs.ARM_lr), "lr" },
  1769. { uoff(regs.ARM_pc), "pc" },
  1770. { uoff(regs.ARM_cpsr), "cpsr" },
  1771. #elif defined(AVR32)
  1772. { uoff(regs.sr), "sr" },
  1773. { uoff(regs.pc), "pc" },
  1774. { uoff(regs.lr), "lr" },
  1775. { uoff(regs.sp), "sp" },
  1776. { uoff(regs.r12), "r12" },
  1777. { uoff(regs.r11), "r11" },
  1778. { uoff(regs.r10), "r10" },
  1779. { uoff(regs.r9), "r9" },
  1780. { uoff(regs.r8), "r8" },
  1781. { uoff(regs.r7), "r7" },
  1782. { uoff(regs.r6), "r6" },
  1783. { uoff(regs.r5), "r5" },
  1784. { uoff(regs.r4), "r4" },
  1785. { uoff(regs.r3), "r3" },
  1786. { uoff(regs.r2), "r2" },
  1787. { uoff(regs.r1), "r1" },
  1788. { uoff(regs.r0), "r0" },
  1789. { uoff(regs.r12_orig), "orig_r12" },
  1790. #elif defined(MIPS)
  1791. { 0, "r0" },
  1792. { 1, "r1" },
  1793. { 2, "r2" },
  1794. { 3, "r3" },
  1795. { 4, "r4" },
  1796. { 5, "r5" },
  1797. { 6, "r6" },
  1798. { 7, "r7" },
  1799. { 8, "r8" },
  1800. { 9, "r9" },
  1801. { 10, "r10" },
  1802. { 11, "r11" },
  1803. { 12, "r12" },
  1804. { 13, "r13" },
  1805. { 14, "r14" },
  1806. { 15, "r15" },
  1807. { 16, "r16" },
  1808. { 17, "r17" },
  1809. { 18, "r18" },
  1810. { 19, "r19" },
  1811. { 20, "r20" },
  1812. { 21, "r21" },
  1813. { 22, "r22" },
  1814. { 23, "r23" },
  1815. { 24, "r24" },
  1816. { 25, "r25" },
  1817. { 26, "r26" },
  1818. { 27, "r27" },
  1819. { 28, "r28" },
  1820. { 29, "r29" },
  1821. { 30, "r30" },
  1822. { 31, "r31" },
  1823. { 32, "f0" },
  1824. { 33, "f1" },
  1825. { 34, "f2" },
  1826. { 35, "f3" },
  1827. { 36, "f4" },
  1828. { 37, "f5" },
  1829. { 38, "f6" },
  1830. { 39, "f7" },
  1831. { 40, "f8" },
  1832. { 41, "f9" },
  1833. { 42, "f10" },
  1834. { 43, "f11" },
  1835. { 44, "f12" },
  1836. { 45, "f13" },
  1837. { 46, "f14" },
  1838. { 47, "f15" },
  1839. { 48, "f16" },
  1840. { 49, "f17" },
  1841. { 50, "f18" },
  1842. { 51, "f19" },
  1843. { 52, "f20" },
  1844. { 53, "f21" },
  1845. { 54, "f22" },
  1846. { 55, "f23" },
  1847. { 56, "f24" },
  1848. { 57, "f25" },
  1849. { 58, "f26" },
  1850. { 59, "f27" },
  1851. { 60, "f28" },
  1852. { 61, "f29" },
  1853. { 62, "f30" },
  1854. { 63, "f31" },
  1855. { 64, "pc" },
  1856. { 65, "cause" },
  1857. { 66, "badvaddr" },
  1858. { 67, "mmhi" },
  1859. { 68, "mmlo" },
  1860. { 69, "fpcsr" },
  1861. { 70, "fpeir" },
  1862. #elif defined(TILE)
  1863. { PTREGS_OFFSET_REG(0), "r0" },
  1864. { PTREGS_OFFSET_REG(1), "r1" },
  1865. { PTREGS_OFFSET_REG(2), "r2" },
  1866. { PTREGS_OFFSET_REG(3), "r3" },
  1867. { PTREGS_OFFSET_REG(4), "r4" },
  1868. { PTREGS_OFFSET_REG(5), "r5" },
  1869. { PTREGS_OFFSET_REG(6), "r6" },
  1870. { PTREGS_OFFSET_REG(7), "r7" },
  1871. { PTREGS_OFFSET_REG(8), "r8" },
  1872. { PTREGS_OFFSET_REG(9), "r9" },
  1873. { PTREGS_OFFSET_REG(10), "r10" },
  1874. { PTREGS_OFFSET_REG(11), "r11" },
  1875. { PTREGS_OFFSET_REG(12), "r12" },
  1876. { PTREGS_OFFSET_REG(13), "r13" },
  1877. { PTREGS_OFFSET_REG(14), "r14" },
  1878. { PTREGS_OFFSET_REG(15), "r15" },
  1879. { PTREGS_OFFSET_REG(16), "r16" },
  1880. { PTREGS_OFFSET_REG(17), "r17" },
  1881. { PTREGS_OFFSET_REG(18), "r18" },
  1882. { PTREGS_OFFSET_REG(19), "r19" },
  1883. { PTREGS_OFFSET_REG(20), "r20" },
  1884. { PTREGS_OFFSET_REG(21), "r21" },
  1885. { PTREGS_OFFSET_REG(22), "r22" },
  1886. { PTREGS_OFFSET_REG(23), "r23" },
  1887. { PTREGS_OFFSET_REG(24), "r24" },
  1888. { PTREGS_OFFSET_REG(25), "r25" },
  1889. { PTREGS_OFFSET_REG(26), "r26" },
  1890. { PTREGS_OFFSET_REG(27), "r27" },
  1891. { PTREGS_OFFSET_REG(28), "r28" },
  1892. { PTREGS_OFFSET_REG(29), "r29" },
  1893. { PTREGS_OFFSET_REG(30), "r30" },
  1894. { PTREGS_OFFSET_REG(31), "r31" },
  1895. { PTREGS_OFFSET_REG(32), "r32" },
  1896. { PTREGS_OFFSET_REG(33), "r33" },
  1897. { PTREGS_OFFSET_REG(34), "r34" },
  1898. { PTREGS_OFFSET_REG(35), "r35" },
  1899. { PTREGS_OFFSET_REG(36

Large files files are truncated, but you can click here to view the full file