Rizin
unix-like reverse engineering framework and cli tools
bsd_debug.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2019 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <signal.h>
5 #include <errno.h>
6 #include <sys/param.h>
7 #include <sys/types.h>
8 #include <sys/socket.h>
9 #include <netinet/in.h>
10 #include <sys/sysctl.h>
11 #include <sys/types.h>
12 #include <sys/wait.h>
13 #include <sys/un.h>
14 #include <arpa/inet.h>
15 #include <kvm.h>
16 #include <limits.h>
17 #include <sys/ptrace.h>
18 #include <sys/types.h>
19 #include <sys/wait.h>
20 #include <kvm.h>
21 #include <limits.h>
22 #include "bsd_debug.h"
23 #if __KFBSD__ || __DragonFly__
24 #include <sys/user.h>
25 #include <libutil.h>
26 #elif __OpenBSD__ || __NetBSD__
27 #include <sys/proc.h>
28 #endif
29 
30 #if __KFBSD__
31 static void addr_to_string(struct sockaddr_storage *ss, char *buffer, int buflen) {
32  char buffer2[INET6_ADDRSTRLEN];
33  struct sockaddr_in6 *sin6;
34  struct sockaddr_in *sin;
35  struct sockaddr_un *sun;
36 
37  if (buflen > 0)
38  switch (ss->ss_family) {
39  case AF_LOCAL:
40  sun = (struct sockaddr_un *)ss;
41  strncpy(buffer, (sun && *sun->sun_path) ? sun->sun_path : "-", buflen - 1);
42  break;
43  case AF_INET:
44  sin = (struct sockaddr_in *)ss;
45  snprintf(buffer, buflen, "%s:%d", inet_ntoa(sin->sin_addr),
46  ntohs(sin->sin_port));
47  break;
48  case AF_INET6:
49  sin6 = (struct sockaddr_in6 *)ss;
50  if (inet_ntop(AF_INET6, &sin6->sin6_addr, buffer2,
51  sizeof(buffer2)) != NULL) {
52  snprintf(buffer, buflen, "%s.%d", buffer2,
53  ntohs(sin6->sin6_port));
54  } else {
55  strcpy(buffer, "-");
56  }
57  break;
58  default:
59  *buffer = 0;
60  break;
61  }
62 }
63 #endif
64 
66 #if __KFBSD__ || __NetBSD__
67  // Trying to figure out a bit by the signal
68  struct ptrace_lwpinfo linfo = { 0 };
69  siginfo_t siginfo;
70  int ret = ptrace(PT_LWPINFO, dbg->pid, (char *)&linfo, sizeof(linfo));
71  if (ret == -1) {
72  if (errno == ESRCH) {
74  return 0;
75  }
76  rz_sys_perror("ptrace PTRACE_LWPINFO");
77  return -1;
78  }
79 
80  // Not stopped by the signal
81  if (linfo.pl_event == PL_EVENT_NONE) {
83  return 0;
84  }
85 
86 #if __KFBSD__
87  siginfo = linfo.pl_siginfo;
88 #else
89  struct ptrace_siginfo sinfo = { 0 };
90  if (ptrace(PT_GET_SIGINFO, dbg->pid, (char *)&sinfo, sizeof(sinfo)) == -1) {
91  if (errno == ESRCH) {
93  return 0;
94  }
95  rz_sys_perror("ptrace PTRACE_GET_SIGINFO");
96  return -1;
97  }
98 
99  siginfo = sinfo.psi_siginfo;
100 #endif
102  dbg->reason.signum = siginfo.si_signo;
103 
104  switch (dbg->reason.signum) {
105  case SIGABRT:
107  break;
108  case SIGSEGV:
110  break;
111  }
112 
113  return 0;
114 #else
115  return -1;
116 #endif
117 }
118 
119 int bsd_reg_write(RzDebug *dbg, int type, const ut8 *buf, int size) {
120  int r = -1;
121  switch (type) {
122  case RZ_REG_TYPE_GPR:
123  r = ptrace(PT_SETREGS, dbg->pid,
124  (caddr_t)buf, sizeof(struct reg));
125  break;
126  case RZ_REG_TYPE_DRX:
127 #if __KFBSD__ || __NetBSD__
128  r = ptrace(PT_SETDBREGS, dbg->pid, (caddr_t)buf, sizeof(struct dbreg));
129 #endif
130  break;
131  case RZ_REG_TYPE_FPU:
132  r = ptrace(PT_SETFPREGS, dbg->pid, (caddr_t)buf, sizeof(struct fpreg));
133  break;
134  }
135 
136  return (r == 0 ? true : false);
137 }
138 
140 #if defined(__NetBSD__)
141  return ptrace(PT_DUMPCORE, dbg->pid, path, strlen(path)) != -1;
142 #elif defined(__FreeBSD__) && __FreeBSD_version >= 1400030
143  struct ptrace_coredump pc = { .pc_fd = dest->fd, .pc_flags = PC_ALL, .pc_limit = 0 };
144  return ptrace(PT_COREDUMP, dbg->pid, (void *)&pc, sizeof(pc)) != -1;
145 #else
146  return false;
147 #endif
148 }
149 RzDebugInfo *bsd_info(RzDebug *dbg, const char *arg) {
150 #if __KFBSD__
151  struct kinfo_proc *kp;
153  if (!rdi) {
154  return NULL;
155  }
156 
157  if (!(kp = kinfo_getproc(dbg->pid))) {
158  free(rdi);
159  return NULL;
160  }
161 
162  rdi->pid = dbg->pid;
163  rdi->tid = dbg->tid;
164  rdi->uid = kp->ki_uid;
165  rdi->gid = kp->ki_pgid;
166  rdi->exe = strdup(kp->ki_comm);
167 
168  switch (kp->ki_stat) {
169  case SSLEEP:
170  rdi->status = RZ_DBG_PROC_SLEEP;
171  break;
172  case SSTOP:
173  rdi->status = RZ_DBG_PROC_STOP;
174  break;
175  case SZOMB:
176  rdi->status = RZ_DBG_PROC_ZOMBIE;
177  break;
178  case SRUN:
179  case SIDL:
180  case SLOCK:
181  case SWAIT:
182  rdi->status = RZ_DBG_PROC_RUN;
183  break;
184  default:
185  rdi->status = RZ_DBG_PROC_DEAD;
186  }
187 
188  free(kp);
189 
190  return rdi;
191 #elif __OpenBSD__
192  struct kinfo_proc *kp;
193  char err[_POSIX2_LINE_MAX];
194  int rc;
196  if (!rdi) {
197  return NULL;
198  }
199 
200  kvm_t *kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, err);
201  if (!kd) {
202  free(rdi);
203  return NULL;
204  }
205 
206  kp = kvm_getprocs(kd, KERN_PROC_PID, dbg->pid, sizeof(*kp), &rc);
207  if (kp) {
208  rdi->pid = dbg->pid;
209  rdi->tid = dbg->tid;
210  rdi->uid = kp->p_uid;
211  rdi->gid = kp->p__pgid;
212  rdi->exe = strdup(kp->p_comm);
213 
214  rdi->status = RZ_DBG_PROC_STOP;
215 
216  if (kp->p_psflags & PS_ZOMBIE) {
217  rdi->status = RZ_DBG_PROC_ZOMBIE;
218  } else if (kp->p_psflags & PS_STOPPED) {
219  rdi->status = RZ_DBG_PROC_STOP;
220  } else if (kp->p_psflags & PS_PPWAIT) {
221  rdi->status = RZ_DBG_PROC_SLEEP;
222  } else if ((kp->p_psflags & PS_EXEC) || (kp->p_psflags & PS_INEXEC)) {
223  rdi->status = RZ_DBG_PROC_RUN;
224  }
225  }
226 
227  kvm_close(kd);
228 
229  return rdi;
230 #elif __NetBSD__
231  struct kinfo_proc2 *kp;
232  char err[_POSIX2_LINE_MAX];
233  int np;
235  if (!rdi) {
236  return NULL;
237  }
238 
239  kvm_t *kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, err);
240  if (!kd) {
241  free(rdi);
242  return NULL;
243  }
244 
245  kp = kvm_getproc2(kd, KERN_PROC_PID, dbg->pid, sizeof(*kp), &np);
246  if (kp) {
247  rdi->pid = dbg->pid;
248  rdi->tid = dbg->tid;
249  rdi->uid = kp->p_uid;
250  rdi->gid = kp->p__pgid;
251  rdi->exe = strdup(kp->p_comm);
252 
253  rdi->status = RZ_DBG_PROC_STOP;
254 
255  switch (kp->p_stat) {
256  case SDEAD:
257  rdi->status = RZ_DBG_PROC_DEAD;
258  break;
259  case SSTOP:
260  rdi->status = RZ_DBG_PROC_STOP;
261  break;
262  case SZOMB:
263  rdi->status = RZ_DBG_PROC_ZOMBIE;
264  break;
265  case SACTIVE:
266  case SIDL:
267  case SDYING:
268  rdi->status = RZ_DBG_PROC_RUN;
269  break;
270  default:
271  rdi->status = RZ_DBG_PROC_SLEEP;
272  }
273  }
274 
275  kvm_close(kd);
276 
277  return rdi;
278 #endif
279 }
280 
282 #if __KFBSD__
283 #ifdef __NetBSD__
284 #define KVM_OPEN_FLAG KVM_NO_FILES
285 #define KVM_GETPROCS(kd, opt, arg, cntptr) \
286  kvm_getproc2(kd, opt, arg, sizeof(struct kinfo_proc2), cntptr)
287 #define KP_COMM(x) (x)->p_comm
288 #define KP_PID(x) (x)->p_pid
289 #define KP_PPID(x) (x)->p_ppid
290 #define KP_UID(x) (x)->p_uid
291 #define KINFO_PROC kinfo_proc2
292 #elif defined(__OpenBSD__)
293 #define KVM_OPEN_FLAG KVM_NO_FILES
294 #define KVM_GETPROCS(kd, opt, arg, cntptr) \
295  kvm_getprocs(kd, opt, arg, sizeof(struct kinfo_proc), cntptr)
296 #define KP_COMM(x) (x)->p_comm
297 #define KP_PID(x) (x)->p_pid
298 #define KP_PPID(x) (x)->p_ppid
299 #define KP_UID(x) (x)->p_uid
300 #define KINFO_PROC kinfo_proc
301 #elif __DragonFly__
302 #define KVM_OPEN_FLAG O_RDONLY
303 #define KVM_GETPROCS(kd, opt, arg, cntptr) \
304  kvm_getprocs(kd, opt, arg, cntptr)
305 #define KP_COMM(x) (x)->kp_comm
306 #define KP_PID(x) (x)->kp_pid
307 #define KP_PPID(x) (x)->kp_ppid
308 #define KP_UID(x) (x)->kp_uid
309 #define KINFO_PROC kinfo_proc
310 #else
311 #define KVM_OPEN_FLAG O_RDONLY
312 #define KVM_GETPROCS(kd, opt, arg, cntptr) \
313  kvm_getprocs(kd, opt, arg, cntptr)
314 #define KP_COMM(x) (x)->ki_comm
315 #define KP_PID(x) (x)->ki_pid
316 #define KP_PPID(x) (x)->ki_ppid
317 #define KP_UID(x) (x)->ki_uid
318 #define KINFO_PROC kinfo_proc
319 #endif
320  char errbuf[_POSIX2_LINE_MAX];
321  struct KINFO_PROC *kp, *entry;
322  int cnt = 0;
323  int i;
324 
325 #if __FreeBSD__
326  kvm_t *kd = kvm_openfiles(NULL, "/dev/null", NULL, KVM_OPEN_FLAG, errbuf);
327 #else
328  kvm_t *kd = kvm_openfiles(NULL, NULL, NULL, KVM_OPEN_FLAG, errbuf);
329 #endif
330  if (!kd) {
331  eprintf("kvm_openfiles failed: %s\n", errbuf);
332  return NULL;
333  }
334 
335  kp = KVM_GETPROCS(kd, KERN_PROC_PROC, 0, &cnt);
336  for (i = 0; i < cnt; i++) {
337  entry = kp + i;
338  // Unless pid 0 is requested, only add the requested pid and it's child processes
339  if (0 == pid || KP_PID(entry) == pid || KP_PPID(entry) == pid) {
340  RzDebugPid *p = rz_debug_pid_new(KP_COMM(entry), KP_PID(entry), KP_UID(entry), 's', 0);
341  if (p) {
342  p->ppid = KP_PPID(entry);
344  }
345  }
346  }
347 
348  kvm_close(kd);
349 #endif
350  return list;
351 }
352 
354 #if __KFBSD__
355  int mib[4];
356  size_t len;
357  char *buf, *bp, *eb;
358  struct kinfo_vmentry *kve;
359  RzList *list = NULL;
360  RzDebugMap *map;
361 
362  len = 0;
363  mib[0] = CTL_KERN;
364  mib[1] = KERN_PROC;
365  mib[2] = KERN_PROC_VMMAP;
366  mib[3] = dbg->pid;
367 
368  if (sysctl(mib, 4, NULL, &len, NULL, 0) != 0)
369  return NULL;
370  len = len * 4 / 3;
371  buf = malloc(len);
372  if (!buf) {
373  return NULL;
374  }
375  if (sysctl(mib, 4, buf, &len, NULL, 0) != 0) {
376  free(buf);
377  return NULL;
378  }
379  bp = buf;
380  eb = buf + len;
382  if (!list) {
383  free(buf);
384  return NULL;
385  }
386  while (bp < eb) {
387  kve = (struct kinfo_vmentry *)(uintptr_t)bp;
388  map = rz_debug_map_new(kve->kve_path, kve->kve_start,
389  kve->kve_end, kve->kve_protection, 0);
390  if (!map)
391  break;
393  bp += kve->kve_structsize;
394  }
395  free(buf);
396  return list;
397 #elif __OpenBSD__
398  int mib[3];
399  size_t len;
400  struct kinfo_vmentry entry;
401  u_long old_end = 0;
402  RzList *list = NULL;
403  RzDebugMap *map;
404 
405  len = sizeof(entry);
406  mib[0] = CTL_KERN;
407  mib[1] = KERN_PROC_VMMAP;
408  mib[2] = dbg->pid;
409  entry.kve_start = 0;
410 
411  if (sysctl(mib, 3, &entry, &len, NULL, 0) == -1) {
412  eprintf("Could not get memory map: %s\n", strerror(errno));
413  return NULL;
414  }
415 
417  if (!list)
418  return NULL;
419 
420  while (sysctl(mib, 3, &entry, &len, NULL, 0) != -1) {
421  if (old_end == entry.kve_end) {
422  /* No more entries */
423  break;
424  }
425  /* path to vm obj is not included in kinfo_vmentry.
426  * see usr.sbin/procmap for namei-cache lookup.
427  */
428  map = rz_debug_map_new("", entry.kve_start, entry.kve_end,
429  entry.kve_protection, 0);
430  if (!map)
431  break;
433 
434  entry.kve_start = entry.kve_start + 1;
435  old_end = entry.kve_end;
436  }
437 
438  return list;
439 #else
440  return NULL;
441 #endif
442 }
443 
445 #if __KFBSD__
446  RzList *ret = NULL;
447  int perm, type, mib[4];
448  size_t len;
449  char *buf, *bp, *eb, *str, path[1024];
450  RzDebugDesc *desc;
451  struct kinfo_file *kve;
452 
453  len = 0;
454  mib[0] = CTL_KERN;
455  mib[1] = KERN_PROC;
456  mib[2] = KERN_PROC_FILEDESC;
457  mib[3] = pid;
458 
459  if (sysctl(mib, 4, NULL, &len, NULL, 0) != 0)
460  return NULL;
461  len = len * 4 / 3;
462  buf = malloc(len);
463  if (!buf) {
464  return NULL;
465  }
466  if (sysctl(mib, 4, buf, &len, NULL, 0) != 0) {
467  free(buf);
468  return NULL;
469  }
470  bp = buf;
471  eb = buf + len;
472  ret = rz_list_new();
473  if (!ret) {
474  free(buf);
475  return NULL;
476  }
478  while (bp < eb) {
479  kve = (struct kinfo_file *)(uintptr_t)bp;
480  bp += kve->kf_structsize;
481  if (kve->kf_fd < 0)
482  continue; // Skip root and cwd. We need it ??
483  str = kve->kf_path;
484  switch (kve->kf_type) {
485  case KF_TYPE_VNODE: type = 'v'; break;
486  case KF_TYPE_SOCKET:
487  type = 's';
488 #if __FreeBSD_version < 1200031
489  if (kve->kf_sock_domain == AF_LOCAL) {
490  struct sockaddr_un *sun =
491  (struct sockaddr_un *)&kve->kf_sa_local;
492  if (sun->sun_path[0] != 0)
493  addr_to_string(&kve->kf_sa_local, path, sizeof(path));
494  else
495  addr_to_string(&kve->kf_sa_peer, path, sizeof(path));
496  } else {
497  addr_to_string(&kve->kf_sa_local, path, sizeof(path));
498  strcat(path, " ");
499  addr_to_string(&kve->kf_sa_peer, path + strlen(path),
500  sizeof(path));
501  }
502 #else
503  if (kve->kf_sock_domain == AF_LOCAL) {
504  struct sockaddr_un *sun =
505  (struct sockaddr_un *)&kve->kf_un.kf_sock.kf_sa_local;
506  ;
507  if (sun->sun_path[0] != 0)
508  addr_to_string(&kve->kf_un.kf_sock.kf_sa_local, path, sizeof(path));
509  else
510  addr_to_string(&kve->kf_un.kf_sock.kf_sa_peer, path, sizeof(path));
511  } else {
512  addr_to_string(&kve->kf_un.kf_sock.kf_sa_local, path, sizeof(path));
513  strcat(path, " ");
514  addr_to_string(&kve->kf_un.kf_sock.kf_sa_peer, path + strlen(path),
515  sizeof(path));
516  }
517 #endif
518  str = path;
519  break;
520  case KF_TYPE_PIPE: type = 'p'; break;
521  case KF_TYPE_FIFO: type = 'f'; break;
522  case KF_TYPE_KQUEUE: type = 'k'; break;
523 #if __FreeBSD_version < 1300130
524  // removed in https://reviews.freebsd.org/D27302
525  case KF_TYPE_CRYPTO: type = 'c'; break;
526 #endif
527  case KF_TYPE_MQUEUE: type = 'm'; break;
528  case KF_TYPE_SHM: type = 'h'; break;
529  case KF_TYPE_PTS: type = 't'; break;
530  case KF_TYPE_SEM: type = 'e'; break;
531  case KF_TYPE_NONE:
532  case KF_TYPE_UNKNOWN:
533  default: type = '-'; break;
534  }
535  perm = (kve->kf_flags & KF_FLAG_READ) ? RZ_PERM_R : 0;
536  perm |= (kve->kf_flags & KF_FLAG_WRITE) ? RZ_PERM_W : 0;
537  desc = rz_debug_desc_new(kve->kf_fd, str, perm, type, kve->kf_offset);
538  if (!desc) {
539  break;
540  }
541  rz_list_append(ret, desc);
542  }
543 
544  free(buf);
545  return ret;
546 #elif __NetBSD__
547  RzList *ret = NULL;
548  char path[512], file[512], buf[512];
549  struct dirent *de;
550  RzDebugDesc *desc;
551  int type, perm;
552  int len, len2;
553  struct stat st;
554  DIR *dd = NULL;
555 
556  rz_strf(path, "/proc/%i/fd/", pid);
557  if (!(dd = opendir(path))) {
558  rz_sys_perror("opendir /proc/x/fd");
559  return NULL;
560  }
562  if (!ret) {
563  closedir(dd);
564  return NULL;
565  }
566  while ((de = (struct dirent *)readdir(dd))) {
567  if (de->d_name[0] == '.') {
568  continue;
569  }
570  len = strlen(path);
571  len2 = strlen(de->d_name);
572  if (len + len2 + 1 >= sizeof(file)) {
573  RZ_LOG_ERROR("Filename is too long.\n");
574  goto fail;
575  }
576  memcpy(file, path, len);
577  memcpy(file + len, de->d_name, len2 + 1);
578  buf[0] = 0;
579  if (readlink(file, buf, sizeof(buf) - 1) == -1) {
580  RZ_LOG_ERROR("readlink %s failed.\n", file);
581  goto fail;
582  }
583  buf[sizeof(buf) - 1] = 0;
584  type = perm = 0;
585  if (stat(file, &st) != -1) {
586  type = st.st_mode & S_IFIFO ? 'P' : st.st_mode & S_IFSOCK ? 'S'
587  : st.st_mode & S_IFCHR ? 'C'
588  : '-';
589  }
590  if (lstat(path, &st) != -1) {
591  if (st.st_mode & S_IRUSR) {
592  perm |= RZ_PERM_R;
593  }
594  if (st.st_mode & S_IWUSR) {
595  perm |= RZ_PERM_W;
596  }
597  }
598  // TODO: Offset
599  desc = rz_debug_desc_new(atoi(de->d_name), buf, perm, type, 0);
600  if (!desc) {
601  break;
602  }
603  rz_list_append(ret, desc);
604  }
605  closedir(dd);
606  return ret;
607 
608 fail:
609  rz_list_free(ret);
610  closedir(dd);
611  return NULL;
612 #else
613  return NULL;
614 #endif
615 }
616 
617 #if __KFBSD__
618 static int get_rz_status(int stat) {
619  switch (stat) {
620  case SRUN:
621  case SIDL:
622  case SLOCK:
623  case SWAIT:
624  return RZ_DBG_PROC_RUN;
625  case SSTOP:
626  return RZ_DBG_PROC_STOP;
627  case SZOMB:
628  return RZ_DBG_PROC_ZOMBIE;
629  case SSLEEP:
630  return RZ_DBG_PROC_SLEEP;
631  default:
632  return RZ_DBG_PROC_DEAD;
633  }
634 }
635 #endif
636 
638 #if __KFBSD__
639  int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD, pid };
640  struct kinfo_proc *kp;
641  size_t len = 0;
642  size_t max;
643  int i = 0;
644 
645  if (sysctl(mib, 4, NULL, &len, NULL, 0) == -1) {
647  return NULL;
648  }
649 
650  len += sizeof(*kp) + len / 10;
651  kp = malloc(len);
652  if (sysctl(mib, 4, kp, &len, NULL, 0) == -1) {
653  free(kp);
655  return NULL;
656  }
657 
658  max = len / sizeof(*kp);
659  for (i = 0; i < max; i++) {
660  RzDebugPid *pid_info;
661  int pid_stat;
662 
663  pid_stat = get_rz_status(kp[i].ki_stat);
664  pid_info = rz_debug_pid_new(kp[i].ki_comm, kp[i].ki_tid,
665  kp[i].ki_uid, pid_stat, (ut64)kp[i].ki_wchan);
666  rz_list_append(list, pid_info);
667  }
668 
669  free(kp);
670  return list;
671 #else
672  eprintf("bsd_thread_list unsupported on this platform\n");
674  return NULL;
675 #endif
676 }
size_t len
Definition: 6502dis.c:15
lzma_index ** i
Definition: index.h:629
static bool err
Definition: armass.c:435
const char * desc
Definition: bin_vsf.c:19
RzList * bsd_desc_list(int pid)
Definition: bsd_debug.c:444
int bsd_handle_signals(RzDebug *dbg)
Definition: bsd_debug.c:65
RzList * bsd_pid_list(RzDebug *dbg, int pid, RzList *list)
Definition: bsd_debug.c:281
RzList * bsd_native_sysctl_map(RzDebug *dbg)
Definition: bsd_debug.c:353
int bsd_reg_write(RzDebug *dbg, int type, const ut8 *buf, int size)
Definition: bsd_debug.c:119
RzList * bsd_thread_list(RzDebug *dbg, int pid, RzList *list)
Definition: bsd_debug.c:637
bool bsd_generate_corefile(RzDebug *dbg, char *path, RzBuffer *dest)
Definition: bsd_debug.c:139
RzDebugInfo * bsd_info(RzDebug *dbg, const char *arg)
Definition: bsd_debug.c:149
#define NULL
Definition: cris-opc.c:27
#define r
Definition: crypto_rc6.c:12
static static fork const void static count static fd const char const char static newpath const char static path const char path
Definition: sflib.h:35
static static sync static getppid static getegid const char static filename char static len readlink
Definition: sflib.h:65
RZ_API RzDebugDesc * rz_debug_desc_new(int fd, char *path, int perm, int type, int off)
Definition: ddesc.c:8
RZ_API void rz_debug_desc_free(RzDebugDesc *p)
Definition: ddesc.c:20
RzDebug * dbg
Definition: desil.c:30
RZ_API RzList * rz_debug_map_list_new(void)
Definition: dmap.c:83
RZ_API RzDebugMap * rz_debug_map_new(char *name, ut64 addr, ut64 addr_end, int perm, int user)
Definition: dmap.c:7
int max
Definition: enough.c:225
size_t map(int syms, int left, int len)
Definition: enough.c:237
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
voidpf void * buf
Definition: ioapi.h:138
snprintf
Definition: kernel.h:364
#define reg(n)
uint8_t ut8
Definition: lh5801.h:11
void * p
Definition: libc.cpp:67
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static void list(RzEgg *egg)
Definition: rz-gg.c:52
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
Definition: list.c:235
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
void * malloc(size_t size)
Definition: malloc.c:123
static stat
Definition: sflib.h:131
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc pid
Definition: sflib.h:64
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname unsigned long static filedes void static end_data_segment static handler static getegid char static len static pgid const char static path static newfd static getpgrp static euid const sigset_t static mask const char static len const gid_t static list const char const char static newpath const char static library readdir
Definition: sflib.h:120
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid ptrace
Definition: sflib.h:57
char * dest
Definition: lz4.h:697
int type
Definition: mipsasm.c:17
RZ_API RzDebugPid * rz_debug_pid_new(const char *path, int pid, int uid, char status, ut64 pc)
Definition: pid.c:6
#define eprintf(x, y...)
Definition: rlcc.c:7
@ RZ_DEBUG_REASON_DEAD
Definition: rz_debug.h:90
@ RZ_DEBUG_REASON_BREAKPOINT
Definition: rz_debug.h:94
@ RZ_DEBUG_REASON_ABORT
Definition: rz_debug.h:99
@ RZ_DEBUG_REASON_SEGFAULT
Definition: rz_debug.h:93
@ RZ_DEBUG_REASON_SIGNAL
Definition: rz_debug.h:92
@ RZ_DBG_PROC_RUN
Definition: rz_debug.h:61
@ RZ_DBG_PROC_STOP
Definition: rz_debug.h:60
@ RZ_DBG_PROC_ZOMBIE
Definition: rz_debug.h:63
@ RZ_DBG_PROC_DEAD
Definition: rz_debug.h:64
@ RZ_DBG_PROC_SLEEP
Definition: rz_debug.h:62
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
@ RZ_REG_TYPE_GPR
Definition: rz_reg.h:21
@ RZ_REG_TYPE_FPU
Definition: rz_reg.h:23
@ RZ_REG_TYPE_DRX
Definition: rz_reg.h:22
#define rz_strf(buf,...)
Convenience macro for local temporary strings.
Definition: rz_str.h:59
#define rz_sys_perror(x)
Definition: rz_types.h:336
#define RZ_PERM_R
Definition: rz_types.h:93
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define RZ_PERM_W
Definition: rz_types.h:94
#define PT_SETREGS
Definition: sftypes.h:604
#define ESRCH
Definition: sftypes.h:113
int caddr_t
Definition: sftypes.h:62
#define AF_INET
Definition: sftypes.h:287
#define AF_INET6
Definition: sftypes.h:295
#define PT_SETFPREGS
Definition: sftypes.h:614
#define ntohs(x)
Definition: sftypes.h:478
#define AF_LOCAL
Definition: sftypes.h:284
_W64 unsigned int uintptr_t
Definition: buffer.h:15
Definition: sftypes.h:48
char d_name[256]
Definition: sftypes.h:52
Definition: zipcmp.c:77
Definition: gzappend.c:170
RzDebugReason reason
Definition: rz_debug.h:276
RzListFree free
Definition: rz_list.h:21
in_port_t sin6_port
Definition: sftypes.h:373
struct in6_addr sin6_addr
Definition: sftypes.h:375
struct in_addr sin_addr
Definition: sftypes.h:344
in_port_t sin_port
Definition: sftypes.h:343
char sun_path[108]
Definition: sftypes.h:356
Definition: sftypes.h:80
ut64 buflen
Definition: core.c:76
#define fail(test)
Definition: tests.h:29
if(dbg->bits==RZ_SYS_BITS_64)
Definition: windows-arm64.h:4
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode dd[]
Definition: z80_tab.h:844