35 #if defined (NEW_PROC_API)
36 #define _STRUCTURED_PROC 1
39 #include <sys/procfs.h>
40 #ifdef HAVE_SYS_FAULT_H
41 #include <sys/fault.h>
43 #ifdef HAVE_SYS_SYSCALL_H
44 #include <sys/syscall.h>
90 #include <sys/types.h>
114 ptid_t,
int,
enum gdb_signal);
118 struct regcache *,
int);
120 struct regcache *,
int);
122 int,
unsigned char *);
126 char *,
char **,
int);
152 #if defined (PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64)
166 if (endptr - ptr < 8 * 2)
209 #if defined(PR_MODEL_NATIVE) && (PR_MODEL_NATIVE == PR_MODEL_LP64)
242 #ifdef HAVE_PR_SIGSET_T
249 #ifdef HAVE_PR_SIGACTION64_T
252 typedef struct sigaction gdb_sigaction_t;
256 #ifdef HAVE_PR_SIGINFO64_T
268 #define gdb_praddset(sp, flag) ((void) praddset (sp, flag))
269 #define gdb_prdelset(sp, flag) ((void) prdelset (sp, flag))
273 #define gdb_premptysysset premptysysset
275 #define gdb_premptysysset premptyset
280 #define gdb_praddsysset praddsysset
282 #define gdb_praddsysset gdb_praddset
287 #define gdb_prdelsysset prdelsysset
289 #define gdb_prdelsysset gdb_prdelset
293 #ifdef prissyssetmember
294 #define gdb_pr_issyssetmember prissyssetmember
296 #define gdb_pr_issyssetmember prismember
309 #ifdef HAVE_PRSYSENT_T
310 #define DYNAMIC_SYSCALLS
338 # ifndef CTL_PROC_NAME_FMT
339 # define MAIN_PROC_NAME_FMT "/proc/%d"
340 # define CTL_PROC_NAME_FMT "/proc/%d/ctl"
341 # define AS_PROC_NAME_FMT "/proc/%d/as"
342 # define MAP_PROC_NAME_FMT "/proc/%d/map"
343 # define STATUS_PROC_NAME_FMT "/proc/%d/status"
344 # define MAX_PROC_NAME_SIZE sizeof("/proc/99999/lwp/8096/lstatus")
351 # ifndef CTL_PROC_NAME_FMT
352 # define MAIN_PROC_NAME_FMT "/proc/%05d"
353 # define CTL_PROC_NAME_FMT "/proc/%05d"
354 # define AS_PROC_NAME_FMT "/proc/%05d"
355 # define MAP_PROC_NAME_FMT "/proc/%05d"
356 # define STATUS_PROC_NAME_FMT "/proc/%05d"
357 # define MAX_PROC_NAME_SIZE sizeof("/proc/ttttppppp")
402 #ifdef DYNAMIC_SYSCALLS
404 char **syscall_names;
415 static char errmsg[128];
429 #ifdef DYNAMIC_SYSCALLS
430 static void load_syscalls (
procinfo *pi);
431 static void free_syscalls (
procinfo *pi);
432 static int find_syscall (
procinfo *pi,
char *name);
451 for (pi = procinfo_list; pi; pi = pi->
next)
483 error (
_(
"procfs: couldn't find pid %d "
484 "(kernel thread %d) in procinfo list."),
487 error (
_(
"procfs: couldn't find pid %d in procinfo list."), pid);
505 int retries_remaining,
status;
507 retries_remaining = 2;
511 status = open (pathname, flags);
513 if (status >= 0 || retries_remaining == 0)
515 else if (errno != EINTR && errno != EAGAIN)
597 strcat (tmp,
"/lwpctl");
599 strcat (tmp,
"/ctl");
616 strcat (tmp,
"/lwpstatus");
618 strcat (tmp,
"/status");
662 if ((fd = ioctl (process->
ctl_fd, PIOCOPENLWP, &lwpid)) < 0)
698 #ifdef DYNAMIC_SYSCALLS
715 sprintf (pi->
pathname,
"/proc/%05d/lwp/%d", pid, tid);
752 for (ptr = *list; ptr; ptr = ptr->
next)
763 #ifdef DYNAMIC_SYSCALLS
814 sprintf (procfile,
"process %d", pi->
pid);
818 kill (pi->
pid, SIGKILL);
831 #ifndef DYNAMIC_SYSCALLS
832 return sizeof (sysset_t);
834 return sizeof (sysset_t) -
sizeof (uint64_t)
835 +
sizeof (uint64_t) * ((pi->num_syscalls + (8 * sizeof (uint64_t) - 1))
836 / (8 *
sizeof (uint64_t)));
849 #ifdef DYNAMIC_SYSCALLS
850 ret->pr_size = ((pi->num_syscalls + (8 *
sizeof (uint64_t) - 1))
851 / (8 *
sizeof (uint64_t)));
856 #ifdef DYNAMIC_SYSCALLS
863 #define MAX_SYSCALL_NAME_LENGTH 256
864 #define MAX_SYSCALLS 65536
872 prsyscall_t *syscalls;
873 int i,
size, maxcall;
876 pi->num_syscalls = 0;
877 pi->syscall_names = 0;
880 sprintf (pathname,
"/proc/%d/sysent", pi->
pid);
884 error (
_(
"load_syscalls: Can't open /proc/%d/sysent"), pi->
pid);
888 size =
sizeof header -
sizeof (prsyscall_t);
889 if (
read (sysent_fd, &header, size) !=
size)
891 error (
_(
"load_syscalls: Error reading /proc/%d/sysent"), pi->
pid);
894 if (header.pr_nsyscalls == 0)
896 error (
_(
"load_syscalls: /proc/%d/sysent contains no syscalls!"),
900 size = header.pr_nsyscalls *
sizeof (prsyscall_t);
904 if (
read (sysent_fd, syscalls, size) != size)
905 error (
_(
"load_syscalls: Error reading /proc/%d/sysent"), pi->
pid);
912 maxcall = syscalls[0].pr_number;
914 for (i = 1; i < header.pr_nsyscalls; i++)
915 if (syscalls[i].pr_number > maxcall
916 && syscalls[i].pr_nameoff > 0
918 maxcall = syscalls[i].pr_number;
920 pi->num_syscalls = maxcall+1;
921 pi->syscall_names =
xmalloc (pi->num_syscalls * sizeof (
char *));
923 for (i = 0; i < pi->num_syscalls; i++)
924 pi->syscall_names[i] = NULL;
927 for (i = 0; i < header.pr_nsyscalls; i++)
929 char namebuf[MAX_SYSCALL_NAME_LENGTH];
934 || syscalls[i].pr_number < 0
935 || syscalls[i].pr_nameoff <= 0
936 || (lseek (sysent_fd, (off_t) syscalls[i].pr_nameoff,
SEEK_SET)
937 != (off_t) syscalls[i].pr_nameoff))
940 nread =
read (sysent_fd, namebuf,
sizeof namebuf);
944 callnum = syscalls[i].pr_number;
946 if (pi->syscall_names[callnum] != NULL)
952 namebuf[nread-1] =
'\0';
953 size = strlen (namebuf) + 1;
954 pi->syscall_names[callnum] =
xmalloc (size);
955 strncpy (pi->syscall_names[callnum], namebuf, size-1);
956 pi->syscall_names[callnum][size-1] =
'\0';
968 if (pi->syscall_names)
972 for (i = 0; i < pi->num_syscalls; i++)
973 if (pi->syscall_names[i] != NULL)
974 xfree (pi->syscall_names[i]);
976 xfree (pi->syscall_names);
977 pi->syscall_names = 0;
985 find_syscall (
procinfo *pi,
char *name)
989 for (i = 0; i < pi->num_syscalls; i++)
991 if (pi->syscall_names[i] && strcmp (name, pi->syscall_names[i]) == 0)
1025 sprintf (errmsg,
"procfs: %s line %d, %s", func, line, pi->
pathname);
1032 sprintf (errmsg,
"procfs: %s line %d, %s", func, line, pi->
pathname);
1063 sizeof (lwpstatus_t))
1064 ==
sizeof (lwpstatus_t));
1069 sizeof (gdb_prstatus_t))
1086 tid_t pr_error_thread;
1087 struct prstatus status;
1090 thread_status.pr_count = 1;
1091 thread_status.status.pr_tid = pi->
tid;
1092 win = (ioctl (pi->
status_fd, PIOCTSTATUS, &thread_status) >= 0);
1095 memcpy (&pi->
prstatus, &thread_status.status,
1134 return pi->
prstatus.pr_lwp.pr_flags;
1166 return pi->
prstatus.pr_lwp.pr_what;
1209 return pi->
prstatus.pr_lwp.pr_nsysarg;
1226 return (
long *) &pi->
prstatus.pr_lwp.pr_sysarg;
1228 return (
long *) &pi->
prstatus.pr_sysarg;
1233 #ifdef PROCFS_DONT_PIOCSSIG_CURSIG
1244 return pi->
prstatus.pr_lwp.pr_cursig;
1301 #define GDBRESET PCUNSET
1304 #define GDBRESET PCRESET
1316 win = (write (pi->
ctl_fd, (
void *) &arg, sizeof (arg)) ==
sizeof (arg));
1322 win = (ioctl (pi->
ctl_fd, PIOCSET, &flag) >= 0);
1326 win = (ioctl (pi->
ctl_fd, PIOCRESET, &flag) >= 0);
1335 win = (ioctl (pi->
ctl_fd, PIOCSRLC, NULL) >= 0);
1339 win = (ioctl (pi->
ctl_fd, PIOCRRLC, NULL) >= 0);
1345 win = (ioctl (pi->
ctl_fd, PIOCSFORK, NULL) >= 0);
1349 win = (ioctl (pi->
ctl_fd, PIOCRFORK, NULL) >= 0);
1365 warning (
_(
"procfs: modify_flag failed to turn %s %s"),
1366 flag == PR_FORK ?
"PR_FORK" :
1367 flag == PR_RLC ?
"PR_RLC" :
1369 flag == PR_ASYNC ?
"PR_ASYNC" :
1372 flag == PR_KLC ?
"PR_KLC" :
1452 win = (write (pi->
ctl_fd, (
char *) &cmd, sizeof (cmd)) ==
sizeof (cmd));
1490 win = (write (pi->
ctl_fd, (
char *) &cmd, sizeof (cmd)) ==
sizeof (cmd));
1544 runflags = PRCFAULT;
1549 else if (signo != -1)
1558 win = (write (pi->
ctl_fd, (
char *) &cmd, sizeof (cmd)) ==
sizeof (cmd));
1564 memset (&prrun, 0,
sizeof (prrun));
1565 prrun.pr_flags = runflags;
1566 win = (ioctl (pi->
ctl_fd, PIOCRUN, &prrun) >= 0);
1598 memcpy (&arg.sigset, sigset, sizeof (gdb_sigset_t));
1600 win = (write (pi->
ctl_fd, (
char *) &arg, sizeof (arg)) ==
sizeof (arg));
1603 win = (ioctl (pi->
ctl_fd, PIOCSTRACE, sigset) >= 0);
1609 warning (
_(
"procfs: set_traced_signals failed"));
1634 char fltset[
sizeof (fltset_t)];
1638 memcpy (&arg.fltset, fltset, sizeof (fltset_t));
1640 win = (write (pi->
ctl_fd, (
char *) &arg, sizeof (arg)) ==
sizeof (arg));
1643 win = (ioctl (pi->
ctl_fd, PIOCSFAULT, fltset) >= 0);
1669 struct gdb_proc_ctl_pcsentry {
1672 char sysset[
sizeof (sysset_t)];
1674 int argp_size =
sizeof (
struct gdb_proc_ctl_pcsentry)
1676 + sysset_t_size (pi);
1680 argp->cmd = PCSENTRY;
1681 memcpy (&argp->sysset, sysset, sysset_t_size (pi));
1683 win = (write (pi->ctl_fd, (
char *) argp, argp_size) == argp_size);
1687 win = (ioctl (pi->
ctl_fd, PIOCSENTRY, sysset) >= 0);
1714 struct gdb_proc_ctl_pcsexit {
1717 char sysset[
sizeof (sysset_t)];
1719 int argp_size =
sizeof (
struct gdb_proc_ctl_pcsexit)
1721 + sysset_t_size (pi);
1725 argp->cmd = PCSEXIT;
1726 memcpy (&argp->sysset, sysset, sysset_t_size (pi));
1728 win = (write (pi->ctl_fd, (
char *) argp, argp_size) == argp_size);
1732 win = (ioctl (pi->
ctl_fd, PIOCSEXIT, sysset) >= 0);
1766 memcpy (&arg.hold, sighold, sizeof (gdb_sigset_t));
1767 win = (write (pi->
ctl_fd, (
void *) &arg, sizeof (arg)) ==
sizeof (arg));
1770 win = (ioctl (pi->
ctl_fd, PIOCSHOLD, sighold) >= 0);
1782 static gdb_sigset_t *
1785 gdb_sigset_t *ret = NULL;
1800 ret = &pi->
prstatus.pr_lwp.pr_lwphold;
1803 static gdb_sigset_t sigheld;
1805 if (ioctl (pi->
ctl_fd, PIOCGHOLD, &sigheld) >= 0)
1810 memcpy (save, ret,
sizeof (gdb_sigset_t));
1818 static gdb_sigset_t *
1821 gdb_sigset_t *ret = NULL;
1839 static gdb_sigset_t sigtrace;
1841 if (ioctl (pi->
ctl_fd, PIOCGTRACE, &sigtrace) >= 0)
1846 memcpy (save, ret,
sizeof (gdb_sigset_t));
1857 fltset_t *ret = NULL;
1875 static fltset_t flttrace;
1877 if (ioctl (pi->
ctl_fd, PIOCGFAULT, &flttrace) >= 0)
1882 memcpy (save, ret,
sizeof (fltset_t));
1893 sysset_t *ret = NULL;
1908 #ifndef DYNAMIC_SYSCALLS
1912 static sysset_t *sysentry;
1920 if (pi->
prstatus.pr_sysentry_offset == 0)
1930 != (off_t) pi->
prstatus.pr_sysentry_offset)
1942 static sysset_t sysentry;
1944 if (ioctl (pi->
ctl_fd, PIOCGENTRY, &sysentry) >= 0)
1960 sysset_t * ret = NULL;
1975 #ifndef DYNAMIC_SYSCALLS
1979 static sysset_t *sysexit;
1987 if (pi->
prstatus.pr_sysexit_offset == 0)
1997 != (off_t) pi->
prstatus.pr_sysexit_offset)
2009 static sysset_t sysexit;
2011 if (ioctl (pi->
ctl_fd, PIOCGEXIT, &sysexit) >= 0)
2042 win = (write (pi->
ctl_fd, (
void *) &cmd, sizeof (cmd)) ==
sizeof (cmd));
2045 win = (ioctl (pi->
ctl_fd, PIOCCFAULT, 0) >= 0);
2068 gdb_siginfo_t mysinfo;
2080 #ifdef PROCFS_DONT_PIOCSSIG_CURSIG
2086 signo == proc_cursig (pi))
2097 && pi->
prstatus.pr_lwp.pr_info.si_signo == signo
2099 && pi->
prstatus.pr_info.si_signo == signo
2105 memcpy (arg.sinfo, &pi->
prstatus.pr_lwp.pr_info, sizeof (gdb_siginfo_t));
2107 memcpy (arg.sinfo, &pi->
prstatus.pr_info, sizeof (gdb_siginfo_t));
2111 mysinfo.si_signo = signo;
2112 mysinfo.si_code = 0;
2113 mysinfo.si_pid = getpid ();
2114 mysinfo.si_uid = getuid ();
2115 memcpy (arg.sinfo, &mysinfo, sizeof (gdb_siginfo_t));
2120 win = (write (pi->
ctl_fd, (
void *) &arg, sizeof (arg)) ==
sizeof (arg));
2122 win = (ioctl (pi->
ctl_fd, PIOCSSIG, (
void *) &arg.sinfo) >= 0);
2152 gdb_siginfo_t mysinfo;
2156 mysinfo.si_signo = 0;
2157 mysinfo.si_code = 0;
2158 mysinfo.si_errno = 0;
2159 mysinfo.si_pid = getpid ();
2160 mysinfo.si_uid = getuid ();
2161 memcpy (arg.sinfo, &mysinfo, sizeof (gdb_siginfo_t));
2163 win = (write (pi->
ctl_fd, (
void *) &arg, sizeof (arg)) ==
sizeof (arg));
2166 win = (ioctl (pi->
ctl_fd, PIOCSSIG, 0) >= 0);
2183 return &pi->
prstatus.pr_lwp.pr_reg;
2200 return &pi->
prstatus.pr_lwp.pr_fpreg;
2216 tid_t pr_error_thread;
2217 tfpregset_t thread_1;
2220 thread_fpregs.pr_count = 1;
2221 thread_fpregs.thread_1.tid = pi->
tid;
2229 else if (pi->
tid != 0
2230 && ioctl (pi->
ctl_fd, PIOCTGFPREG, &thread_fpregs) >= 0)
2232 memcpy (&pi->
fpregset, &thread_fpregs.thread_1.pr_fpregs,
2285 memcpy (&arg.gregs, gregs, sizeof (arg.gregs));
2286 win = (write (pi->
ctl_fd, (
void *) &arg, sizeof (arg)) ==
sizeof (arg));
2288 win = (ioctl (pi->
ctl_fd, PIOCSREG, gregs) >= 0);
2325 memcpy (&arg.fpregs, fpregs, sizeof (arg.fpregs));
2326 win = (write (pi->
ctl_fd, (
void *) &arg, sizeof (arg)) ==
sizeof (arg));
2330 win = (ioctl (pi->
ctl_fd, PIOCSFPREG, fpregs) >= 0);
2335 tid_t pr_error_thread;
2336 tfpregset_t thread_1;
2339 thread_fpregs.pr_count = 1;
2340 thread_fpregs.thread_1.tid = pi->
tid;
2341 memcpy (&thread_fpregs.thread_1.pr_fpregs, fpregs,
2343 win = (ioctl (pi->
ctl_fd, PIOCTSFPREG, &thread_fpregs) >= 0);
2346 win = (ioctl (pi->
ctl_fd, PIOCSFPREG, fpregs) >= 0);
2379 win = (write (pi->
ctl_fd, (
char *) &cmd, sizeof (cmd)) ==
sizeof (cmd));
2383 win = (ioctl (pi->
ctl_fd, PIOCKILL, &signo) >= 0);
2414 #if (defined (PCWATCH) || defined (PIOCSWATCH)) \
2415 && !(defined (PIOCOPENLWP))
2417 procfs_address_to_host_pointer (
CORE_ADDR addr)
2432 #if !defined (PCWATCH) && !defined (PIOCSWATCH)
2439 #if defined (PIOCOPENLWP)
2444 char watch[
sizeof (prwatch_t)];
2452 pwatch.pr_vaddr = (uintptr_t) procfs_address_to_host_pointer (addr);
2454 pwatch.pr_vaddr = (caddr_t) procfs_address_to_host_pointer (addr);
2456 pwatch.pr_size =
len;
2457 pwatch.pr_wflags = wflags;
2458 #if defined(NEW_PROC_API) && defined (PCWATCH)
2460 memcpy (arg.watch, &pwatch, sizeof (prwatch_t));
2461 return (write (pi->
ctl_fd, &arg, sizeof (arg)) ==
sizeof (arg));
2463 #if defined (PIOCSWATCH)
2464 return (ioctl (pi->
ctl_fd, PIOCSWATCH, &pwatch) >= 0);
2473 #if (defined(__i386__) || defined(__x86_64__)) && defined (sun)
2475 #include <sys/sysi86.h>
2482 proc_get_LDT_entry (
procinfo *pi,
int key)
2484 static struct ssd *ldt_entry = NULL;
2487 struct cleanup *old_chain = NULL;
2492 if (ldt_entry == NULL)
2493 ldt_entry = (
struct ssd *)
xmalloc (
sizeof (
struct ssd));
2496 sprintf (pathname,
"/proc/%d/ldt", pi->
pid);
2499 proc_warn (pi,
"proc_get_LDT_entry (open)", __LINE__);
2506 while (
read (fd, ldt_entry,
sizeof (
struct ssd)) ==
sizeof (
struct ssd))
2508 if (ldt_entry->sel == 0 &&
2509 ldt_entry->bo == 0 &&
2510 ldt_entry->acc1 == 0 &&
2511 ldt_entry->acc2 == 0)
2514 if (ldt_entry->sel == key)
2521 static int nalloc = 0;
2524 if (ioctl (pi->
ctl_fd, PIOCNLDT, &nldt) < 0)
2526 proc_warn (pi,
"proc_get_LDT_entry (PIOCNLDT)", __LINE__);
2534 ldt_entry = (
struct ssd *)
2535 xrealloc (ldt_entry, (nldt + 1) *
sizeof (
struct ssd));
2540 if (ioctl (pi->
ctl_fd, PIOCLDT, ldt_entry) < 0)
2542 proc_warn (pi,
"proc_get_LDT_entry (PIOCLDT)", __LINE__);
2547 for (i = 0; i < nldt; i++)
2548 if (ldt_entry[i].sel == key)
2549 return &ldt_entry[i];
2559 procfs_find_LDT_entry (
ptid_t ptid)
2568 warning (
_(
"procfs_find_LDT_entry: could not find procinfo for %d:%ld."),
2575 warning (
_(
"procfs_find_LDT_entry: could not read gregs for %d:%ld."),
2580 key = (*gregs)[GS] & 0xffff;
2583 return proc_get_LDT_entry (pi, key);
2597 #if defined (PIOCNTHR) && defined (PIOCTLIST)
2604 if (ioctl (pi->
ctl_fd, PIOCNTHR, &nthreads) < 0)
2605 proc_warn (pi,
"procfs: PIOCNTHR failed", __LINE__);
2611 #if defined (SYS_lwpcreate) || defined (SYS_lwp_create)
2646 #if defined (SYS_lwpcreate) || defined (SYS_lwp_create)
2664 return pi->
prstatus.pr_lwp.pr_lwpid;
2671 #if defined (PIOCNTHR) && defined (PIOCTLIST)
2702 if (thread && parent)
2711 #if defined (PIOCLSTATUS)
2716 gdb_prstatus_t *prstatus;
2717 struct cleanup *old_chain = NULL;
2734 prstatus =
xmalloc (
sizeof (gdb_prstatus_t) * (nlwp + 1));
2737 if (ioctl (pi->
ctl_fd, PIOCLSTATUS, prstatus) < 0)
2738 proc_error (pi,
"update_threads (PIOCLSTATUS)", __LINE__);
2741 for (i = 1; i < nlwp + 1; i++)
2744 proc_error (pi,
"update_threads, create_procinfo", __LINE__);
2746 memcpy (&thread->
prstatus, &prstatus[i], sizeof (*prstatus));
2766 struct dirent *direntry;
2767 struct cleanup *old_chain = NULL;
2789 strcat (pathname,
"/lwp");
2790 if ((dirp = opendir (pathname)) == NULL)
2791 proc_error (pi,
"update_threads, opendir", __LINE__);
2794 while ((direntry = readdir (dirp)) != NULL)
2795 if (direntry->d_name[0] !=
'.')
2797 lwpid = atoi (&direntry->d_name[0]);
2799 proc_error (pi,
"update_threads, create_procinfo", __LINE__);
2828 threads =
xmalloc (nthreads *
sizeof (tid_t));
2830 if (ioctl (pi->
ctl_fd, PIOCTLIST, threads) < 0)
2831 proc_error (pi,
"procfs: update_threads (PIOCTLIST)", __LINE__);
2833 for (i = 0; i < nthreads; i++)
2837 proc_error (pi,
"update_threads, create_procinfo", __LINE__);
2882 for (thread = pi->
thread_list; thread != NULL; thread = next)
2884 next = thread->
next;
2885 if ((retval = (*
func) (pi, thread, ptr)) != 0)
2904 int entry_or_exit,
int mode,
int from_tty);
2915 fltset_t traced_faults;
2916 gdb_sigset_t traced_signals;
2917 sysset_t *traced_syscall_entries;
2918 sysset_t *traced_syscall_exits;
2922 prfillset (&traced_faults);
2928 prfillset (&traced_signals);
2945 #ifdef DYNAMIC_SYSCALLS
2947 int callnum = find_syscall (pi,
"_exit");
2955 xfree (traced_syscall_entries);
2959 #ifdef PRFS_STOPEXEC
2967 if (ioctl (pi->
ctl_fd, PIOCGSPCACT, &prfs_flags) < 0)
2970 prfs_flags |= PRFS_STOPEXEC;
2972 if (ioctl (pi->
ctl_fd, PIOCSSPCACT, &prfs_flags) < 0)
2994 #ifdef SYS_lwpcreate
2999 #ifdef SYS_lwp_create
3004 #ifdef DYNAMIC_SYSCALLS
3006 int callnum = find_syscall (pi,
"execve");
3010 callnum = find_syscall (pi,
"ra_execve");
3017 xfree (traced_syscall_exits);
3033 if (pid == getpid ())
3034 error (
_(
"Attaching GDB to itself is not a good idea..."));
3068 if (exec_file == NULL)
3092 perror (
_(
"procfs: out of memory in 'attach'"));
3097 sprintf (errmsg,
"do_attach: couldn't open /proc file for process %d",
3103 if (
proc_flags (pi) & (PR_STOPPED | PR_ISTOP))
3126 dead_procinfo (pi,
"do_attach: couldn't save traced syscall entries.",
3129 dead_procinfo (pi,
"do_attach: couldn't save traced syscall exits.",
3163 proc_warn (pi,
"do_detach, set_current_signal", __LINE__);
3166 proc_warn (pi,
"do_detach, set_traced_signal", __LINE__);
3169 proc_warn (pi,
"do_detach, set_traced_faults", __LINE__);
3172 proc_warn (pi,
"do_detach, set_traced_sysentry", __LINE__);
3175 proc_warn (pi,
"do_detach, set_traced_sysexit", __LINE__);
3178 proc_warn (pi,
"do_detach, set_held_signals", __LINE__);
3180 if (signo || (
proc_flags (pi) & (PR_STOPPED | PR_ISTOP)))
3182 query (
_(
"Was stopped when attached, make it runnable again? ")))
3186 proc_warn (pi,
"do_detach, clear_current_fault", __LINE__);
3189 proc_warn (pi,
"do_detach, clear_current_signal", __LINE__);
3192 proc_warn (pi,
"do_detach, set_rlc", __LINE__);
3214 struct regcache *regcache,
int regnum)
3225 error (
_(
"procfs: fetch_registers failed to find procinfo for %s"),
3230 proc_error (pi,
"fetch_registers, get_gregs", __LINE__);
3245 proc_error (pi,
"fetch_registers, get_fpregs", __LINE__);
3263 struct regcache *regcache,
int regnum)
3274 error (
_(
"procfs: store_registers: failed to find procinfo for %s"),
3279 proc_error (pi,
"store_registers, get_gregs", __LINE__);
3283 proc_error (pi,
"store_registers, set_gregs", __LINE__);
3296 proc_error (pi,
"store_registers, get_fpregs", __LINE__);
3300 proc_error (pi,
"store_registers, set_fpregs", __LINE__);
3308 if (scall == SYS_lwp_exit)
3312 if (scall == SYS_lwpexit)
3322 if (scall == SYS_exit)
3325 #ifdef DYNAMIC_SYSCALLS
3326 if (find_syscall (pi,
"_exit") == scall)
3336 if (scall == SYS_exec)
3340 if (scall == SYS_execv)
3344 if (scall == SYS_execve)
3347 #ifdef DYNAMIC_SYSCALLS
3348 if (find_syscall (pi,
"_execve"))
3350 if (find_syscall (pi,
"ra_execve"))
3359 #ifdef SYS_lwp_create
3360 if (scall == SYS_lwp_create)
3363 #ifdef SYS_lwpcreate
3364 if (scall == SYS_lwpcreate)
3376 dbx_link_addr (bfd *abfd)
3378 long storage_needed;
3379 asymbol **symbol_table;
3380 long number_of_symbols;
3383 storage_needed = bfd_get_symtab_upper_bound (abfd);
3384 if (storage_needed <= 0)
3387 symbol_table = (asymbol **)
xmalloc (storage_needed);
3390 number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
3392 for (i = 0; i < number_of_symbols; i++)
3394 asymbol *sym = symbol_table[i];
3396 if ((sym->flags & BSF_GLOBAL)
3397 && sym->name != NULL && strcmp (sym->name,
"__dbx_link") == 0)
3398 return (sym->value + sym->section->vma);
3410 insert_dbx_link_bpt_in_file (
int fd,
CORE_ADDR ignored)
3413 long storage_needed;
3419 warning (
_(
"Failed to create a bfd: %s."), bfd_errmsg (bfd_get_error ()));
3423 if (!bfd_check_format (abfd, bfd_object))
3431 sym_addr = dbx_link_addr (abfd);
3440 if (dbx_link_bpt == NULL)
3442 warning (
_(
"Failed to insert dbx_link breakpoint."));
3463 solib_mappings_callback (
struct prmap *map,
int (*
func) (
int,
CORE_ADDR),
3472 if (map->pr_vaddr == 0 && map->pr_size == 0)
3475 if (map->pr_mapname[0] == 0)
3481 sprintf (name,
"/proc/%d/object/%s", pi->
pid, map->pr_mapname);
3490 fd = ioctl (pi->
ctl_fd, PIOCOPENM, &map->pr_vaddr);
3504 insert_dbx_link_bpt_in_region (
struct prmap *map,
3512 if (map->pr_mflags & MA_EXEC)
3513 return solib_mappings_callback (map, insert_dbx_link_bpt_in_file, pi);
3523 insert_dbx_link_breakpoint (
procinfo *pi)
3543 ptid_t retval, temp_ptid;
3544 int why, what,
flags;
3565 if ((flags & PR_STOPPED) && (why == PR_REQUESTED))
3569 if (!(
proc_flags (pi) & (PR_STOPPED | PR_ISTOP)) &&
3573 if (errno == ENOENT)
3578 wait_retval = wait (&wstat);
3582 error (
_(
"procfs: couldn't stop "
3583 "process %d: wait returned %d."),
3589 else if (errno == EINTR)
3594 proc_error (pi,
"target_wait (wait_for_stop)", __LINE__);
3613 if (flags & (PR_STOPPED | PR_ISTOP))
3618 if (flags & PR_ASYNC)
3619 if (!proc_unset_async (pi))
3620 proc_error (pi,
"target_wait, unset_async", __LINE__);
3632 wstat = (what << 8) | 0177;
3660 proc_error (pi,
"target_wait, run_process", __LINE__);
3673 int temp = wait (&wstat);
3695 long i, nsysargs, *sysargs;
3702 for (i = 0; i < nsysargs; i++)
3731 wstat = (SIGTRAP << 8) | 0177;
3734 else if (what == SYS_syssgi)
3738 if (insert_dbx_link_breakpoint (pi))
3798 long i, nsysargs, *sysargs;
3805 for (i = 0; i < nsysargs; i++)
3817 wstat = (SIGSTOP << 8) | 0177;
3844 wstat = (what << 8) | 0177;
3850 wstat = (SIGTRAP << 8) | 0177;
3855 wstat = (SIGTRAP << 8) | 0177;
3860 #if (FLTILL != FLTPRIV)
3863 wstat = (SIGILL << 8) | 0177;
3866 #if (FLTTRACE != FLTBPT)
3869 wstat = (SIGTRAP << 8) | 0177;
3873 #if (FLTBOUNDS != FLTSTACK)
3876 wstat = (SIGSEGV << 8) | 0177;
3880 #if (FLTFPE != FLTIOVF)
3883 wstat = (SIGFPE << 8) | 0177;
3892 error (
_(
"... giving up..."));
3900 error (
_(
"... giving up..."));
3925 error (
_(
"procfs: ...giving up..."));
3941 const char *annex,
gdb_byte *readbuf,
3953 offset, len, xfered_len);
3958 readbuf, writebuf, offset, len,
3975 if (pi->
as_fd == 0 &&
3978 proc_warn (pi,
"xfer_memory, open_proc_files", __LINE__);
3982 if (lseek (pi->
as_fd, (off_t) memaddr,
SEEK_SET) != (off_t) memaddr)
3985 if (writebuf != NULL)
3988 nbytes = write (pi->
as_fd, writebuf, len);
3993 nbytes =
read (pi->
as_fd, readbuf, len);
3997 *xfered_len = nbytes;
4023 if (pi->gregs_dirty)
4024 if (parent == NULL ||
4027 proc_warn (pi,
"target_resume, set_gregs",
4030 if (pi->fpregs_dirty)
4031 if (parent == NULL ||
4034 proc_warn (pi,
"target_resume, set_fpregs",
4049 pi->gregs_dirty = 0;
4050 pi->fpregs_dirty = 0;
4070 proc_error (pi,
"make_signal_thread_runnable", __LINE__);
4090 ptid_t ptid,
int step,
enum gdb_signal signo)
4139 if (thread->
tid != 0)
4144 if (!proc_set_async (pi))
4145 proc_error (pi,
"target_resume, set_async", __LINE__);
4149 make_signal_thread_runnable,
4161 warning (
_(
"resume: target already running. "
4162 "Pretend to resume, and hope for the best!"));
4172 int numsigs,
unsigned char *pass_signals)
4178 prfillset (&signals);
4180 for (signo = 0; signo < NSIG; signo++)
4183 if (target_signo < numsigs && pass_signals[target_signo])
4224 #ifdef PROCFS_NEED_PIOCSSIG_FOR_KILL
4231 gdb_siginfo_t newsiginfo;
4233 memset ((
char *) &newsiginfo, 0,
sizeof (newsiginfo));
4234 newsiginfo.si_signo = SIGKILL;
4235 newsiginfo.si_code = 0;
4236 newsiginfo.si_errno = 0;
4237 newsiginfo.si_pid = getpid ();
4238 newsiginfo.si_uid = getuid ();
4240 ioctl (pi->
ctl_fd, PIOCSSIG, &newsiginfo);
4244 proc_error (pi,
"unconditionally_kill, proc_kill", __LINE__);
4249 if (parent_pid == getpid ())
4256 ret = waitpid (pi->
pid, &status, 0);
4319 perror (
_(
"procfs: out of memory in 'init_inferior'"));
4322 proc_error (pi,
"init_inferior, open_proc_files", __LINE__);
4345 proc_error (pi,
"init_inferior, get_traced_signals", __LINE__);
4347 proc_error (pi,
"init_inferior, get_held_signals", __LINE__);
4349 proc_error (pi,
"init_inferior, get_traced_faults", __LINE__);
4351 proc_error (pi,
"init_inferior, get_traced_sysentry", __LINE__);
4353 proc_error (pi,
"init_inferior, get_traced_sysexit", __LINE__);
4356 proc_error (pi,
"init_inferior (procfs_debug_inferior)", fail);
4365 proc_error (pi,
"init_inferior, set_RLC", __LINE__);
4430 proc_warn (pi,
"set_exec_trap, open_proc_files", __LINE__);
4437 #ifdef PRFS_STOPEXEC
4445 if (ioctl (pi->
ctl_fd, PIOCGSPCACT, &prfs_flags) < 0)
4447 proc_warn (pi,
"set_exec_trap (PIOCGSPCACT)", __LINE__);
4451 prfs_flags |= PRFS_STOPEXEC;
4453 if (ioctl (pi->
ctl_fd, PIOCSSPCACT, &prfs_flags) < 0)
4455 proc_warn (pi,
"set_exec_trap (PIOCSSPCACT)", __LINE__);
4478 #ifdef DYNAMIC_SYSCALLS
4480 int callnum = find_syscall (pi,
"execve");
4485 callnum = find_syscall (pi,
"ra_execve");
4493 proc_warn (pi,
"set_exec_trap, set_traced_sysexit", __LINE__);
4503 proc_warn (pi,
"set_exec_trap, unset_inherit", __LINE__);
4509 proc_warn (pi,
"set_exec_trap, unset_RLC", __LINE__);
4529 char *allargs,
char **env,
int from_tty)
4531 char *shell_file = getenv (
"SHELL");
4535 if (shell_file != NULL && strchr (shell_file,
'/') == NULL)
4563 char *path = getenv (
"PATH");
4565 struct stat statbuf;
4568 path =
"/bin:/usr/bin";
4570 tryname = alloca (strlen (path) + strlen (shell_file) + 2);
4571 for (p = path; p != NULL; p = p1 ? p1 + 1: NULL)
4573 p1 = strchr (p,
':');
4578 strncpy (tryname, p, len);
4579 tryname[
len] =
'\0';
4580 strcat (tryname,
"/");
4581 strcat (tryname, shell_file);
4582 if (access (tryname, X_OK) < 0)
4584 if (stat (tryname, &statbuf) < 0)
4586 if (!S_ISREG (statbuf.st_mode))
4597 error (
_(
"procfs:%d -- Can't find shell %s in PATH"),
4598 __LINE__, shell_file);
4600 shell_file = tryname;
4604 NULL, NULL, shell_file, NULL);
4696 static char buf[80];
4749 if (errno == ESRCH && len == 0)
4768 int type,
int cnt,
int othertype)
4798 if (
proc_flags (pi) & (PR_STOPPED | PR_ISTOP))
4901 int (*
func) (
struct prmap *map,
4906 struct prmap *prmaps;
4907 struct prmap *prmap;
4920 sprintf (pathname,
"/proc/%d/map", pi->
pid);
4921 if ((map_fd = open (pathname, O_RDONLY)) < 0)
4922 proc_error (pi,
"iterate_over_mappings (open)", __LINE__);
4929 if (fstat (map_fd, &sbuf) != 0)
4930 proc_error (pi,
"iterate_over_mappings (fstat)", __LINE__);
4932 nmap = sbuf.st_size /
sizeof (prmap_t);
4933 prmaps = (
struct prmap *) alloca ((nmap + 1) *
sizeof (*prmaps));
4934 if (
read (map_fd, (
char *) prmaps, nmap *
sizeof (*prmaps))
4935 != (nmap *
sizeof (*prmaps)))
4936 proc_error (pi,
"iterate_over_mappings (read)", __LINE__);
4939 if (ioctl (pi->
ctl_fd, PIOCNMAP, &nmap) != 0)
4940 proc_error (pi,
"iterate_over_mappings (PIOCNMAP)", __LINE__);
4942 prmaps = (
struct prmap *) alloca ((nmap + 1) *
sizeof (*prmaps));
4943 if (ioctl (pi->
ctl_fd, PIOCMAP, prmaps) != 0)
4944 proc_error (pi,
"iterate_over_mappings (PIOCMAP)", __LINE__);
4947 for (prmap = prmaps; nmap > 0; prmap++, nmap--)
4948 if ((funcstat = (*
func) (prmap, child_func, data)) != 0)
4966 return (*func) ((
CORE_ADDR) map->pr_vaddr,
4968 (map->pr_mflags & MA_READ) != 0,
4969 (map->pr_mflags & MA_WRITE) != 0,
4970 (map->pr_mflags & MA_EXEC) != 0,
5002 static char asciiflags[8];
5004 strcpy (asciiflags,
"-------");
5005 #if defined (MA_PHYS)
5006 if (flags & MA_PHYS)
5007 asciiflags[0] =
'd';
5009 if (flags & MA_STACK)
5010 asciiflags[1] =
's';
5011 if (flags & MA_BREAK)
5012 asciiflags[2] =
'b';
5013 if (flags & MA_SHARED)
5014 asciiflags[3] =
's';
5015 if (flags & MA_READ)
5016 asciiflags[4] =
'r';
5017 if (flags & MA_WRITE)
5018 asciiflags[5] =
'w';
5019 if (flags & MA_EXEC)
5020 asciiflags[6] =
'x';
5021 return (asciiflags);
5031 unsigned int pr_off;
5034 pr_off = (
unsigned int) map->pr_offset;
5036 pr_off = map->pr_off;
5041 (
unsigned long) map->pr_vaddr,
5042 (
unsigned long) map->pr_vaddr + map->pr_size - 1,
5043 (
unsigned long) map->pr_size,
5048 (
unsigned long) map->pr_vaddr,
5049 (
unsigned long) map->pr_vaddr + map->pr_size - 1,
5050 (
unsigned long) map->pr_size,
5111 error (
_(
"Not supported on this target."));
5120 while (argv != NULL && *argv != NULL)
5122 if (isdigit (argv[0][0]))
5124 pid = strtoul (argv[0], &tmp, 10);
5126 tid = strtoul (++tmp, NULL, 10);
5128 else if (argv[0][0] ==
'/')
5130 tid = strtoul (argv[0] + 1, NULL, 10);
5137 error (
_(
"No current process: you must name one."));
5143 if (process == NULL)
5150 proc_error (process,
"info proc, open_procinfo_files", __LINE__);
5160 if (
proc_flags (process) & (PR_STOPPED | PR_ISTOP))
5170 if (
proc_flags (thread) & (PR_STOPPED | PR_ISTOP))
5193 int mode,
int from_tty)
5197 if (entry_or_exit == PR_SYSENTRY)
5203 proc_error (pi,
"proc-trace, get_traced_sysset", __LINE__);
5210 if (entry_or_exit == PR_SYSENTRY)
5213 proc_error (pi,
"proc-trace, set_traced_sysentry", __LINE__);
5218 proc_error (pi,
"proc-trace, set_traced_sysexit", __LINE__);
5228 error (
_(
"you must be debugging a process to use this command."));
5230 if (args == NULL || args[0] == 0)
5234 if (isdigit (args[0]))
5236 const int syscallnum = atoi (args);
5276 _(
"Give a trace of entries into the syscall."));
5278 _(
"Give a trace of exits from the syscall."));
5280 _(
"Cancel a trace of entries into the syscall."));
5282 _(
"Cancel a trace of exits from the syscall."));
5304 #if defined (PIOCOPENLWP) || defined (PCAGENT)
5308 procfs_do_thread_registers (bfd *obfd,
ptid_t ptid,
5309 char *note_data,
int *note_size,
5310 enum gdb_signal stop_signal)
5315 unsigned long merged_pid;
5330 #if defined (NEW_PROC_API)
5331 note_data = (
char *) elfcore_write_lwpstatus (obfd,
5338 note_data = (
char *) elfcore_write_prstatus (obfd,
5346 note_data = (
char *) elfcore_write_prfpreg (obfd,
5357 struct procfs_corefile_thread_data {
5361 enum gdb_signal stop_signal;
5365 procfs_corefile_thread_callback (
procinfo *pi,
procinfo *thread,
void *data)
5367 struct procfs_corefile_thread_data *args = data;
5373 args->note_data = procfs_do_thread_registers (args->obfd, ptid,
5391 static enum gdb_signal
5400 return GDB_SIGNAL_0;
5409 char fname[16] = {
'\0'};
5410 char psargs[80] = {
'\0'};
5412 char *note_data = NULL;
5414 struct procfs_corefile_thread_data thread_args;
5417 enum gdb_signal stop_signal;
5421 strncpy (fname, lbasename (
get_exec_file (0)),
sizeof (fname));
5422 fname[
sizeof (fname) - 1] = 0;
5424 psargs[
sizeof (psargs) - 1] = 0;
5427 if (inf_args && *inf_args &&
5428 strlen (inf_args) < ((
int)
sizeof (psargs) - (
int) strlen (psargs)))
5430 strncat (psargs,
" ",
5431 sizeof (psargs) - strlen (psargs));
5432 strncat (psargs, inf_args,
5433 sizeof (psargs) - strlen (psargs));
5437 note_data = (
char *) elfcore_write_prpsinfo (obfd,
5447 note_data = elfcore_write_pstatus (obfd, note_data, note_size,
5449 stop_signal, &gregs);
5452 thread_args.obfd = obfd;
5453 thread_args.note_data = note_data;
5454 thread_args.note_size = note_size;
5455 thread_args.stop_signal = stop_signal;
5458 note_data = thread_args.note_data;
5464 note_data = elfcore_write_note (obfd, note_data, note_size,
5465 "CORE", NT_AUXV, auxv, auxv_len);
5475 error (
_(
"gcore not implemented for this host."));
void error_no_arg(const char *why)
void get_last_target_status(ptid_t *ptidp, struct target_waitstatus *status)
struct gdbarch * target_gdbarch(void)
struct cleanup * make_cleanup_freeargv(char **arg)
static ptid_t procfs_wait(struct target_ops *, ptid_t, struct target_waitstatus *, int)
static void destroy_procinfo(procinfo *p)
ssize_t read(int fd, void *buf, size_t count)
ptid_t procfs_first_available(void)
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
static int open_procinfo_files(procinfo *p, int which)
static int procfs_region_ok_for_hw_watchpoint(struct target_ops *self, CORE_ADDR addr, int len)
struct thread_info * add_thread(ptid_t ptid)
static target_xfer_partial_ftype procfs_xfer_partial
static void destroy_one_procinfo(procinfo **list, procinfo *pi)
static int proc_what(procinfo *pi)
static int procfs_insert_watchpoint(struct target_ops *self, CORE_ADDR addr, int len, int type, struct expression *cond)
static int sysset_t_size(procinfo *p)
static void proc_warn(procinfo *pi, char *func, int line)
#define MAIN_PROC_NAME_FMT
static void do_destroy_procinfo_cleanup(void *)
#define gdb_premptysysset
static int syscall_is_lwp_create(procinfo *pi, int scall)
int ptid_equal(ptid_t ptid1, ptid_t ptid2)
int(* to_find_memory_regions)(struct target_ops *, find_memory_region_ftype func, void *data) TARGET_DEFAULT_FUNC(dummy_find_memory_regions)
struct regcache * get_thread_regcache(ptid_t ptid)
void fill_gregset(const struct regcache *regcache, gdb_gregset_t *gregsetp, int regno)
void delete_thread(ptid_t)
char * get_inferior_args(void)
static int proc_set_traced_faults(procinfo *pi, fltset_t *fltset)
static int procfs_notice_thread(procinfo *pi, procinfo *thread, void *ptr)
struct gdbarch * get_regcache_arch(const struct regcache *regcache)
static void procfs_mourn_inferior(struct target_ops *ops)
void warning(const char *fmt,...)
static int proc_get_current_thread(procinfo *pi)
static long * proc_sysargs(procinfo *pi)
char *(* to_pid_to_str)(struct target_ops *, ptid_t) TARGET_DEFAULT_FUNC(default_pid_to_str)
static int procfs_remove_watchpoint(struct target_ops *self, CORE_ADDR addr, int len, int type, struct expression *cond)
int query(const char *ctlstr,...)
static procinfo * find_procinfo(int pid, int tid)
static const struct @41 signals[]
static int proc_watchpoint_address(procinfo *pi, CORE_ADDR *addr)
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
void push_target(struct target_ops *t)
LONGEST target_read_alloc(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte **buf_p)
static int iterate_over_mappings(procinfo *pi, find_memory_region_ftype child_func, void *data, int(*func)(struct prmap *map, find_memory_region_ftype child_func, void *data))
struct ui_file * gdb_stdout
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
static void procfs_info_proc(struct target_ops *, const char *, enum info_proc_what)
void print_sys_errmsg(const char *string, int errcode)
#define target_can_run(t)
void generic_mourn_inferior(void)
void proc_prettyprint_syscall(int num, int verbose)
static int procfs_thread_alive(struct target_ops *ops, ptid_t)
static void procfs_attach(struct target_ops *, const char *, int)
void _initialize_procfs(void)
static int procfs_debug_inferior(procinfo *pi)
static int proc_get_status(procinfo *pi)
int(* to_region_ok_for_hw_watchpoint)(struct target_ops *, CORE_ADDR, int) TARGET_DEFAULT_FUNC(default_region_ok_for_hw_watchpoint)
ptid_t(* to_wait)(struct target_ops *, ptid_t, struct target_waitstatus *, int TARGET_DEBUG_PRINTER(target_debug_print_options)) TARGET_DEFAULT_NORETURN(noprocess())
void target_fetch_registers(struct regcache *regcache, int regno)
char * target_pid_to_str(ptid_t ptid)
enum gdb_signal stop_signal
static int syscall_is_exit(procinfo *pi, int scall)
static int proc_iterate_over_threads(procinfo *pi, int(*func)(procinfo *, procinfo *, void *), void *ptr)
int gdbarch_have_nonsteppable_watchpoint(struct gdbarch *gdbarch)
static void do_closedir_cleanup(void *dir)
static int info_mappings_callback(struct prmap *map, find_memory_region_ftype ignore, void *unused)
void inf_child_maybe_unpush_target(struct target_ops *ops)
static procinfo * find_procinfo_or_die(int pid, int tid)
void fill_fpregset(const struct regcache *regcache, gdb_fpregset_t *fpregsetp, int regno)
struct regcache * get_current_regcache(void)
gdb_sigset_t saved_sighold
static int proc_why(procinfo *pi)
static gdb_sigset_t * proc_get_traced_signals(procinfo *pi, gdb_sigset_t *save)
void printf_filtered(const char *format,...)
static void procfs_pass_signals(struct target_ops *self, int, unsigned char *)
static int proc_set_traced_signals(procinfo *pi, gdb_sigset_t *sigset)
ptid_t ptid_build(int pid, long lwp, long tid)
gdb_sigset_t saved_sigset
void(* to_files_info)(struct target_ops *) TARGET_DEFAULT_IGNORE()
static void close_procinfo_files(procinfo *p)
static gdb_fpregset_t * proc_get_fpregs(procinfo *pi)
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
void null_cleanup(void *arg)
struct observer * observer_attach_inferior_created(observer_inferior_created_ftype *f)
int in_thread_list(ptid_t ptid)
static sysset_t * proc_get_traced_sysexit(procinfo *pi, sysset_t *save)
struct thread_info * iterate_over_threads(thread_callback_func, void *)
#define gdb_prdelset(sp, flag)
static void proc_untrace_sysexit_cmd(char *args, int from_tty)
int(* to_insert_watchpoint)(struct target_ops *, CORE_ADDR, int, int, struct expression *) TARGET_DEFAULT_RETURN(-1)
static int proc_set_gregs(procinfo *pi)
struct cleanup * save_inferior_ptid(void)
static int proc_clear_current_signal(procinfo *pi)
static enum gdb_signal find_stop_signal(void)
static void procfs_set_exec_trap(void)
static gdb_sigset_t * proc_get_held_signals(procinfo *pi, gdb_sigset_t *save)
struct target_ops current_target
void gdb_bfd_unref(struct bfd *abfd)
static void procfs_resume(struct target_ops *, ptid_t, int, enum gdb_signal)
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
void startup_inferior(int ntraps)
static char * procfs_pid_to_str(struct target_ops *, ptid_t)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
static void procfs_files_info(struct target_ops *)
struct procinfo * thread_list
bfd * gdb_bfd_fdopenr(const char *filename, const char *target, int fd)
GDB_GREGSET_T gdb_gregset_t
static void procfs_detach(struct target_ops *, const char *, int)
int(* to_remove_watchpoint)(struct target_ops *, CORE_ADDR, int, int, struct expression *) TARGET_DEFAULT_RETURN(-1)
void target_resume(ptid_t ptid, int step, enum gdb_signal signal)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int status
void(* to_resume)(struct target_ops *, ptid_t, int TARGET_DEBUG_PRINTER(target_debug_print_step), enum gdb_signal) TARGET_DEFAULT_NORETURN(noprocess())
static enum target_xfer_status procfs_xfer_memory(gdb_byte *, const gdb_byte *, ULONGEST, ULONGEST, ULONGEST *)
static int proc_set_traced_sysexit(procinfo *pi, sysset_t *sysset)
GDB_FPREGSET_T gdb_fpregset_t
void free_current_contents(void *ptr)
ptid_t pid_to_ptid(int pid)
void supply_gregset(struct regcache *regcache, const gdb_gregset_t *gregsetp)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
void proc_prettyprint_why(unsigned long why, unsigned long what, int verbose)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
void store_waitstatus(struct target_waitstatus *ourstatus, int hoststatus)
union target_waitstatus::@161 value
static int proc_modify_flag(procinfo *pi, long flag, long mode)
sysset_t * saved_entryset
static void do_detach(int signo)
static int proc_nsysarg(procinfo *pi)
struct inferior * find_inferior_pid(int pid)
int gdb_signal_to_host(enum gdb_signal)
static void procfs_update_thread_list(struct target_ops *ops)
struct cleanup * make_cleanup_close(int fd)
enum gdb_signal gdb_signal_from_host(int)
enum target_xfer_status target_xfer_partial_ftype(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
void target_mourn_inferior(void)
void thread_change_ptid(ptid_t old_ptid, ptid_t new_ptid)
static void procfs_fetch_registers(struct target_ops *, struct regcache *, int)
static void proc_trace_syscalls(char *args, int from_tty, int entry_or_exit, int mode)
static sysset_t * sysset_t_alloc(procinfo *pi)
static int proc_stop_process(procinfo *pi)
static void procfs_store_registers(struct target_ops *, struct regcache *, int)
int fork_inferior(char *exec_file_arg, char *allargs, char **env, void(*traceme_fun)(void), void(*init_trace_fun)(int), void(*pre_trace_fun)(void), char *shell_file_arg, void(*exec_fun)(const char *file, char *const *argv, char *const *env))
int gdbarch_addr_bit(struct gdbarch *gdbarch)
enum target_xfer_status(* to_xfer_partial)(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) TARGET_DEFAULT_RETURN(TARGET_XFER_E_IO)
static void unconditionally_kill_inferior(procinfo *pi)
void printf_unfiltered(const char *format,...)
void(* to_detach)(struct target_ops *ops, const char *, int) TARGET_DEFAULT_IGNORE()
static sysset_t * proc_get_traced_sysentry(procinfo *pi, sysset_t *save)
static char * procfs_make_note_section(struct target_ops *self, bfd *, int *)
char *(* to_make_corefile_notes)(struct target_ops *, bfd *, int *) TARGET_DEFAULT_FUNC(dummy_make_corefile_notes)
CORE_ADDR gdbarch_pointer_to_address(struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf)
static int proc_set_traced_sysentry(procinfo *pi, sysset_t *sysset)
int target_is_pushed(struct target_ops *t)
static int proc_wait_for_stop(procinfo *pi)
static int proc_parent_pid(procinfo *pi)
int ptid_get_pid(ptid_t ptid)
static int proc_delete_dead_threads(procinfo *parent, procinfo *thread, void *ignore)
#define PROC_PRETTYFPRINT_STATUS(X, Y, Z, T)
int(* to_auxv_parse)(struct target_ops *ops, gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) TARGET_DEFAULT_FUNC(default_auxv_parse)
PTR xrealloc(PTR ptr, size_t size)
static gdb_gregset_t * proc_get_gregs(procinfo *pi)
static int proc_run_process(procinfo *pi, int step, int signo)
static char * mappingflags(long flags)
const char const char int
static int proc_clear_current_fault(procinfo *pi)
struct target_ops * inf_child_target(void)
static void proc_trace_sysentry_cmd(char *args, int from_tty)
static int proc_unset_run_on_last_close(procinfo *pi)
void(* to_fetch_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_IGNORE()
static int syscall_is_lwp_exit(procinfo *pi, int scall)
static int procfs_can_use_hw_breakpoint(struct target_ops *self, int, int, int)
void(* to_mourn_inferior)(struct target_ops *) TARGET_DEFAULT_FUNC(default_mourn_inferior)
static int proc_set_held_signals(procinfo *pi, gdb_sigset_t *sighold)
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
static int proc_set_fpregs(procinfo *pi)
int(* to_can_use_hw_breakpoint)(struct target_ops *, int, int, int) TARGET_DEFAULT_RETURN(0)
static int find_memory_regions_callback(struct prmap *map, find_memory_region_ftype func, void *data)
int gdbarch_fp0_regnum(struct gdbarch *gdbarch)
void(* to_pass_signals)(struct target_ops *, int, unsigned char *TARGET_DEBUG_PRINTER(target_debug_print_signals)) TARGET_DEFAULT_IGNORE()
void(* to_stop)(struct target_ops *, ptid_t) TARGET_DEFAULT_IGNORE()
static int procfs_stopped_data_address(struct target_ops *targ, CORE_ADDR *addr)
#define START_INFERIOR_TRAPS_EXPECTED
enum target_waitkind kind
void(* to_kill)(struct target_ops *) TARGET_DEFAULT_NORETURN(noprocess())
static void procfs_init_inferior(struct target_ops *ops, int pid)
struct ui_file * gdb_stderr
struct type * builtin_data_ptr
void detach_inferior(int pid)
static procinfo * procinfo_list
void procfs_use_watchpoints(struct target_ops *t)
static int proc_kill(procinfo *pi, int signo)
static long proc_flags(procinfo *pi)
static int proc_get_nthreads(procinfo *pi)
static int syscall_is_exec(procinfo *pi, int scall)
static int invalidate_cache(procinfo *parent, procinfo *pi, void *ptr)
void(* to_create_inferior)(struct target_ops *, char *, char *, char **, int)
static int proc_set_current_signal(procinfo *pi, int signo)
char ** gdb_buildargv(const char *s)
struct thread_suspend_state suspend
int parse_pid_to_attach(const char *args)
struct target_ops * procfs_target(void)
int(* to_stopped_by_watchpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
static void dead_procinfo(procinfo *p, char *msg, int killp)
static int open_with_retry(const char *pathname, int flags)
static void procfs_inferior_created(struct target_ops *ops, int from_tty)
static void procfs_create_inferior(struct target_ops *, char *, char *, char **, int)
static void proc_error(procinfo *pi, char *func, int line)
static const int mappings[]
struct inferior * current_inferior(void)
int is_exited(ptid_t ptid)
static int proc_set_watchpoint(procinfo *pi, CORE_ADDR addr, int len, int wflags)
char * get_exec_file(int err)
static procinfo * create_procinfo(int pid, int tid)
unsigned long long ULONGEST
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
static void procfs_kill_inferior(struct target_ops *ops)
long ptid_get_lwp(ptid_t ptid)
void proc_prettyprint_flags(unsigned long flags, int verbose)
static int procfs_stopped_by_watchpoint(struct target_ops *ops)
int gdbarch_pc_regnum(struct gdbarch *gdbarch)
struct sigaction gdb_sigaction_t
static int proc_set_run_on_last_close(procinfo *pi)
#define TYPE_LENGTH(thistype)
int to_has_thread_control
#define MAX_PROC_NAME_SIZE
int(* to_thread_alive)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(0)
void(* to_info_proc)(struct target_ops *, const char *, enum info_proc_what)
void(* to_attach)(struct target_ops *ops, const char *, int)
#define target_have_steppable_watchpoint
void gdb_flush(struct ui_file *file)
PROCESS_GROUP_TYPE inferior_process_group(void)
int(* to_stopped_data_address)(struct target_ops *, CORE_ADDR *) TARGET_DEFAULT_RETURN(0)
void(* to_update_thread_list)(struct target_ops *) TARGET_DEFAULT_IGNORE()
static void info_proc_mappings(procinfo *pi, int summary)
static ptid_t do_attach(ptid_t ptid)
static void proc_untrace_sysentry_cmd(char *args, int from_tty)
void(* to_store_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_NORETURN(noprocess())
int(* find_memory_region_ftype)(CORE_ADDR addr, unsigned long size, int read, int write, int exec, int modified, void *data)
static void procfs_stop(struct target_ops *self, ptid_t)
static int proc_unset_inherit_on_fork(procinfo *pi)
static int find_signalled_thread(struct thread_info *info, void *data)
void error(const char *fmt,...)
void gdbarch_address_to_pointer(struct gdbarch *gdbarch, struct type *type, gdb_byte *buf, CORE_ADDR addr)
struct breakpoint * create_and_insert_solib_event_breakpoint(struct gdbarch *gdbarch, CORE_ADDR address)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int int rusage_t pid_t pid
static int procfs_set_watchpoint(ptid_t ptid, CORE_ADDR addr, int len, int rwflag, int after)
prstatus_t gdb_lwpstatus_t
static void proc_trace_syscalls_1(procinfo *pi, int syscallnum, int entry_or_exit, int mode, int from_tty)
static void proc_trace_sysexit_cmd(char *args, int from_tty)
struct target_ops * beneath
static int proc_update_threads(procinfo *pi)
void inferior_appeared(struct inferior *inf, int pid)
void do_cleanups(struct cleanup *old_chain)
static fltset_t * proc_get_traced_faults(procinfo *pi, fltset_t *save)
target_xfer_partial_ftype memory_xfer_auxv
void supply_fpregset(struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
prstatus_t gdb_prstatus_t
const ULONGEST const LONGEST len
static int proc_find_memory_regions(struct target_ops *self, find_memory_region_ftype, void *)
char pathname[MAX_PROC_NAME_SIZE]