summaryrefslogtreecommitdiff
path: root/proc.h
diff options
context:
space:
mode:
authorChanho Park <chanho61.park@samsung.com>2014-08-22 20:34:56 +0900
committerChanho Park <chanho61.park@samsung.com>2014-08-22 20:34:56 +0900
commit517f5529d7008eba87b8b2fee5ec9ec0a5075f6e (patch)
treec71720a9b41309713c089478f921165bd2d63b25 /proc.h
parent689b9dbb8d7f88ab91e7741932ed000b6e49be9a (diff)
downloadltrace-517f5529d7008eba87b8b2fee5ec9ec0a5075f6e.tar.gz
ltrace-517f5529d7008eba87b8b2fee5ec9ec0a5075f6e.tar.bz2
ltrace-517f5529d7008eba87b8b2fee5ec9ec0a5075f6e.zip
Imported Upstream version 0.7.91upstream/0.7.91upstream
Diffstat (limited to 'proc.h')
-rw-r--r--proc.h108
1 files changed, 57 insertions, 51 deletions
diff --git a/proc.h b/proc.h
index a97796c..e8032fa 100644
--- a/proc.h
+++ b/proc.h
@@ -1,6 +1,6 @@
/*
* This file is part of ltrace.
- * Copyright (C) 2010,2011,2012 Petr Machata, Red Hat Inc.
+ * Copyright (C) 2010,2011,2012,2013 Petr Machata, Red Hat Inc.
* Copyright (C) 2010 Joe Damato
* Copyright (C) 1998,2001,2008,2009 Juan Cespedes
*
@@ -26,6 +26,7 @@
#include "config.h"
#include <sys/time.h>
+#include <stdint.h>
#if defined(HAVE_LIBUNWIND)
# include <libunwind.h>
@@ -64,7 +65,7 @@ struct callstack_element {
struct library_symbol * libfunc;
} c_un;
int is_syscall;
- void * return_addr;
+ arch_addr_t return_addr;
struct timeval time_spent;
struct fetch_context *fetch_context;
struct value_dict *arguments;
@@ -75,22 +76,19 @@ struct callstack_element {
#define MAX_CALLDEPTH 64
/* XXX We would rather have this all organized a little differently,
- * have Process for the whole group and Task for what's there for
- * per-thread stuff. But for now this is the less invasive way of
- * structuring it. */
-typedef struct Process Process;
-struct Process {
+ * have struct process for the whole group and struct task (or struct
+ * lwp, struct thread) for what's there for per-thread stuff. But for
+ * now this is the less invasive way of structuring it. */
+struct process {
enum process_state state;
- Process * parent; /* needed by STATE_BEING_CREATED */
+ struct process *parent; /* needed by STATE_BEING_CREATED */
char * filename;
pid_t pid;
/* Dictionary of breakpoints (which is a mapping
* address->breakpoint). This is NULL for non-leader
- * processes. XXX note that we store addresses (keys) by
- * value. That assumes that arch_addr_t fits in host
- * pointer. */
- Dict * breakpoints;
+ * processes. */
+ struct dict *breakpoints;
int mask_32bit; /* 1 if 64-bit ltrace is tracing 32-bit process */
unsigned int personality;
@@ -106,7 +104,6 @@ struct Process {
/* Arch-dependent: */
void * instruction_pointer;
void * stack_pointer; /* To get return addr, args... */
- void * return_addr;
void * arch_ptr;
/* XXX We would like to replace this with a pointer to ABI
@@ -116,11 +113,6 @@ struct Process {
short e_machine;
char e_class;
- /* XXX this shoudl go to ARM's arch_process_data. */
-#ifdef __arm__
- int thumb_mode; /* ARM execution mode: 0: ARM, 1: Thumb */
-#endif
-
#if defined(HAVE_LIBUNWIND)
/* libunwind address space */
unw_addr_space_t unwind_as;
@@ -133,15 +125,15 @@ struct Process {
/**
* Process chaining.
**/
- Process * next;
+ struct process *next;
/* LEADER points to the leader thread of the POSIX.1 process.
If X->LEADER == X, then X is the leader thread and the
- Process structures chained by NEXT represent other threads,
+ process structures chained by NEXT represent other threads,
up until, but not including, the next leader thread.
LEADER may be NULL after the leader has already exited. In
that case this process is waiting to be collected. */
- Process * leader;
+ struct process *leader;
struct os_process_data os;
struct arch_process_data arch;
@@ -149,12 +141,12 @@ struct Process {
/* Initialize a process given a path to binary FILENAME, with a PID,
* and add the process to an internal chain of traced processes. */
-int process_init(struct Process *proc, const char *filename, pid_t pid);
+int process_init(struct process *proc, const char *filename, pid_t pid);
/* PROC underwent an exec. This is a bit like process_destroy
* followed by process_init, except that some state is kept and the
* process doesn't lose it's place in the list of processes. */
-int process_exec(struct Process *proc);
+int process_exec(struct process *proc);
/* Release any memory allocated for PROC (but not PROC itself). Does
* NOT remove PROC from internal chain.
@@ -162,74 +154,79 @@ int process_exec(struct Process *proc);
* XXX clearly this init/destroy pair is different than others and
* should be fixed. process_init should presumably be separate from
* process_add. */
-void process_destroy(struct Process *proc);
+void process_destroy(struct process *proc);
-struct Process *open_program(const char *filename, pid_t pid);
+struct process *open_program(const char *filename, pid_t pid);
void open_pid(pid_t pid);
-Process * pid2proc(pid_t pid);
+struct process *pid2proc(pid_t pid);
/* Clone the contents of PROC into the memory referenced by RETP.
* Returns 0 on success or a negative value on failure. */
-int process_clone(struct Process *retp, struct Process *proc, pid_t pid);
+int process_clone(struct process *retp, struct process *proc, pid_t pid);
/* Iterate through the processes that ltrace currently traces. Tasks
* are considered to be processes for the purpose of this iterator.
* See callback.h for notes on iteration interfaces. */
-Process *each_process(Process *start_after,
- enum callback_status (*cb)(struct Process *proc,
- void *data),
- void *data);
+struct process *each_process(struct process *start_after,
+ enum callback_status (*cb)(struct process *proc,
+ void *data),
+ void *data);
/* Iterate through list of tasks of given process PROC. See
* callback.h for notes on iteration interfaces. */
-Process *each_task(struct Process *proc, struct Process *start_after,
- enum callback_status (*cb)(struct Process *proc,
- void *data),
- void *data);
+struct process *each_task(struct process *proc, struct process *start_after,
+ enum callback_status (*cb)(struct process *proc,
+ void *data),
+ void *data);
+
+void change_process_leader(struct process *proc, struct process *leader);
-void change_process_leader(Process *proc, Process *leader);
+/* Prepare those parts of process initialization that need to be done
+ * after _start is hit (i.e. after dynamic linking was done). */
+void process_hit_start(struct process *proc);
/* Remove process from the list of traced processes, drop any events
* in the event queue, destroy it and free memory. */
-void remove_process(struct Process *proc);
+void remove_process(struct process *proc);
-void install_event_handler(Process *proc, struct event_handler *handler);
-void destroy_event_handler(Process *proc);
+void install_event_handler(struct process *proc, struct event_handler *handler);
+void destroy_event_handler(struct process *proc);
/* Add a library LIB to the list of PROC's libraries. */
-void proc_add_library(struct Process *proc, struct library *lib);
+void proc_add_library(struct process *proc, struct library *lib);
/* Remove LIB from list of PROC's libraries. Returns 0 if the library
* was found and unlinked, otherwise returns a negative value. */
-int proc_remove_library(struct Process *proc, struct library *lib);
+int proc_remove_library(struct process *proc, struct library *lib);
/* Clear a delayed flag. If a symbol is neither latent, nor delayed,
* a breakpoint is inserted for it. Returns 0 if the activation was
* successful or a negative value if it failed. Note that if a symbol
* is both latent and delayed, this will not enable the corresponding
* breakpoint. */
-int proc_activate_delayed_symbol(struct Process *proc,
+int proc_activate_delayed_symbol(struct process *proc,
struct library_symbol *libsym);
/* Iterate through the libraries of PROC. See callback.h for notes on
* iteration interfaces. */
-struct library *proc_each_library(struct Process *proc, struct library *start,
- enum callback_status (*cb)(struct Process *p,
+struct library *proc_each_library(struct process *proc,
+ struct library *start_after,
+ enum callback_status (*cb)(struct process *p,
struct library *l,
void *data),
void *data);
/* Insert BP into PROC. */
-int proc_add_breakpoint(struct Process *proc, struct breakpoint *bp);
+int proc_add_breakpoint(struct process *proc, struct breakpoint *bp);
/* Remove BP from PROC. This has no reason to fail in runtime. If it
* does not find BP in PROC, it's hard error guarded by assertion. */
-void proc_remove_breakpoint(struct Process *proc, struct breakpoint *bp);
+void proc_remove_breakpoint(struct process *proc, struct breakpoint *bp);
/* Iterate through the breakpoints of PROC. See callback.h for notes
* on iteration interfaces. */
-void *proc_each_breakpoint(struct Process *proc, void *start,
- enum callback_status (*cb)(struct Process *proc,
+void *proc_each_breakpoint(struct process *proc, void *start,
+ enum callback_status (*cb)(struct process *proc,
struct breakpoint *bp,
void *data),
void *data);
@@ -237,21 +234,30 @@ void *proc_each_breakpoint(struct Process *proc, void *start,
/* Iterate through the dynamic section at src_addr looking for D_TAG.
* If tag is found, fill it's value in RET and return 0.
* If tag is not found, return a negative value. */
-int proc_find_dynamic_entry_addr(struct Process *proc, arch_addr_t src_addr,
+int proc_find_dynamic_entry_addr(struct process *proc, arch_addr_t src_addr,
int d_tag, arch_addr_t *ret);
/* Finds a symbol corresponding to LIBSYM in a process PROC. Returns
* 0 and sets *RETLIB and *RETSYM if the corresponding pointer is
* non-NULL. Returns a negative value when the symbols couldn't be
* found. */
-int proc_find_symbol(struct Process *proc, struct library_symbol *sym,
+int proc_find_symbol(struct process *proc, struct library_symbol *sym,
struct library **retlib, struct library_symbol **retsym);
/* Iterate through all symbols in all libraries of PROC. See
* callback.h for notes on this interface. */
struct library_symbol *proc_each_symbol
- (struct Process *proc, struct library_symbol *start_after,
+ (struct process *proc, struct library_symbol *start_after,
enum callback_status (*cb)(struct library_symbol *, void *),
void *data);
+/* Read 8, 16, 32 or 64-bit quantity located at ADDR in PROC. The
+ * resulting value is stored in *LP. 0 is returned on success or a
+ * negative value on failure. This uses umovebytes under the hood
+ * (see backend.h). */
+int proc_read_8(struct process *proc, arch_addr_t addr, uint8_t *lp);
+int proc_read_16(struct process *proc, arch_addr_t addr, uint16_t *lp);
+int proc_read_32(struct process *proc, arch_addr_t addr, uint32_t *lp);
+int proc_read_64(struct process *proc, arch_addr_t addr, uint64_t *lp);
+
#endif /* _PROC_H_ */