Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
target_linux_userproc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, 2012, 2013, 2014 The University of Utah
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef __TARGET_LINUX_USERPROC_H__
20 #define __TARGET_LINUX_USERPROC_H__
21 
22 #include <sys/ptrace.h>
23 #include <sys/user.h>
24 #include <glib.h>
25 
26 #include "evloop.h"
27 
28 #include "target_api.h"
29 
31 
32 /* linux userproc target ops */
33 
35  struct evloop *evloop);
38 int linux_userproc_spec_to_argv(struct target_spec *spec,int *argc,char ***argv);
39 
40 int linux_userproc_attach_thread(struct target *target,tid_t parent,tid_t tid);
42  int detaching_all,int stay_paused);
43 
44 /*
45  * Once attached to a process, attach to one of its threads.
46  */
47 
48 
51 
53 int linux_userproc_at_exec(struct target *target,tid_t tid);
54 int linux_userproc_at_exit(struct target *target,tid_t tid);
55 
56 int linux_userproc_pid(struct target *target);
57 
58 #if __WORDSIZE == 64
59 typedef unsigned long int ptrace_reg_t;
60 #else
61 typedef int ptrace_reg_t;
62 #endif
63 
65  int pid;
66  char *program;
67  char **argv;
68  char **envp;
69 };
70 
72  int8_t ctl_sig_sent:1, /* If set, don't reinject a signal on restart. */
73  ctl_sig_recv:1, /* If set, don't reinject a signal on restart. */
74  ctl_sig_synch:1,/* If set, don't handle any signals in evloop. */
78 
79  struct user_regs_struct regs;
80 
81  /* XXX: can we debug a 32-bit target on a 64-bit host? If yes, how
82  * we use this might have to change.
83  */
85 };
86 
88  int pid;
89  int memfd;
90 
91  int8_t initdidattach:1,
93 
94  /*
95  * This is weird, but for the ptrace target, we always "know" which
96  * thread is the current one, because wait() tells us. BUT, we need
97  * to communicate this to various other target API functions like
98  * load_current_thread(), so save it off here.
99  */
101 
102  int32_t ptrace_opts;
104  enum __ptrace_request ptrace_type;
105 
106  /*
107  * If a newly-cloned thread signals its initial ptrace SIGSTOP, and
108  * we get that signal before we get notified about the clone event
109  * via SIGCHLD, don't die on error IF the thread exists in /proc.
110  *
111  * We also have to save its waitpid status here so we can know if we
112  * saw it when we actually DO get the SIGCHLD and add the new thread
113  * -- so we don't try to wait for the SIGSTOP again.
114  */
115  GHashTable *new_racy_threads;
116 };
117 
120  int pstatus;
121 };
122 
123 #endif /* __TARGET_LINUX_USERPROC_H__ */
int linux_userproc_pid(struct target *target)
int linux_userproc_at_syscall(struct target *target, tid_t tid)
int linux_userproc_attach_thread(struct target *target, tid_t parent, tid_t tid)
int32_t tid_t
Definition: common.h:36
int linux_userproc_spec_to_argv(struct target_spec *spec, int *argc, char ***argv)
Definition: evloop.h:66
enum __ptrace_request ptrace_type
int linux_userproc_last_status(struct target *target, tid_t tid)
void linux_userproc_free_spec(struct linux_userproc_spec *lspec)
int linux_userproc_last_signo(struct target *target, tid_t tid)
int ptrace_reg_t
int linux_userproc_at_exit(struct target *target, tid_t tid)
int linux_userproc_at_exec(struct target *target, tid_t tid)
struct target * linux_userproc_instantiate(struct target_spec *spec, struct evloop *evloop)
struct target_spec * spec
Definition: target_api.h:2605
struct user_regs_struct regs
int linux_userproc_detach_thread(struct target *target, tid_t tid, int detaching_all, int stay_paused)
struct target_ops linux_userspace_process_ops
struct linux_userproc_spec * linux_userproc_build_spec(void)