Skip to content

Commit

Permalink
struct Process becomes struct process
Browse files Browse the repository at this point in the history
This is for consistency with other structures, and ultimately with
Linux coding style.  The typedef ("Process") was dropped as well for
this reason.

This opportunity was used to fix coding style around the impacted
lines.
  • Loading branch information
Petr Machata committed Dec 17, 2012
1 parent 5cde20b commit 929bd57
Show file tree
Hide file tree
Showing 65 changed files with 623 additions and 554 deletions.
62 changes: 31 additions & 31 deletions backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int wait_for_proc(pid_t pid);
int task_kill(pid_t pid, int sig);

/* Called after PID is attached, but before it is continued. */
void trace_set_options(struct Process *proc);
void trace_set_options(struct process *proc);

/* Called after ltrace forks. Should attach the newly created child,
* in whose context this function is called. */
Expand All @@ -86,7 +86,7 @@ void untrace_pid(pid_t pid);
/* The back end may need to store arbitrary data to a process. This
* is a place where it can initialize PROC->arch_dep. XXX this should
* be dropped in favor of arhc_process_init on pmachata/libs. */
void get_arch_dep(struct Process *proc);
void get_arch_dep(struct process *proc);

/* Return current instruction pointer of PROC.
*
Expand All @@ -95,34 +95,34 @@ void get_arch_dep(struct Process *proc);
* that would otherwise support this. Above we have a definition of
* arch_addr_t. This should be converted to an integral type and
* used for target addresses throughout. */
void *get_instruction_pointer(struct Process *proc);
void *get_instruction_pointer(struct process *proc);

/* Set instruction pointer of PROC to ADDR. XXX see above. */
void set_instruction_pointer(struct Process *proc, void *addr);
void set_instruction_pointer(struct process *proc, void *addr);

/* Return current stack pointer of PROC. XXX see above. */
void *get_stack_pointer(struct Process *proc);
void *get_stack_pointer(struct process *proc);

/* Find and return caller address, i.e. the address where the current
* function returns. */
void *get_return_addr(struct Process *proc, void *stack_pointer);
void *get_return_addr(struct process *proc, void *stack_pointer);

/* Adjust PROC so that when the current function returns, it returns
* to ADDR. */
void set_return_addr(struct Process *proc, void *addr);
void set_return_addr(struct process *proc, void *addr);

/* Enable breakpoint SBP in process PROC. */
void enable_breakpoint(struct Process *proc, struct breakpoint *sbp);
void enable_breakpoint(struct process *proc, struct breakpoint *sbp);

/* Disable breakpoint SBP in process PROC. */
void disable_breakpoint(struct Process *proc, struct breakpoint *sbp);
void disable_breakpoint(struct process *proc, struct breakpoint *sbp);

/* Determine whether the event that we have just seen (and that is
* recorded in STATUS) was a syscall. If it was, return 1. If it was
* a return from syscall, return 2. In both cases, set *SYSNUM to the
* number of said syscall. If it wasn't a syscall, return 0. If
* there was an error, return -1. */
int syscall_p(struct Process *proc, int status, int *sysnum);
int syscall_p(struct process *proc, int status, int *sysnum);

/* Continue execution of the process with given PID. */
void continue_process(pid_t pid);
Expand All @@ -136,17 +136,17 @@ void continue_after_signal(pid_t pid, int signum);
* is system call, otherwise it's return from a system call. The
* callback should do whatever book-keeping is necessary and continue
* the process if necessary. */
void continue_after_syscall(struct Process *proc, int sysnum, int ret_p);
void continue_after_syscall(struct process *proc, int sysnum, int ret_p);

/* Called after we hit a breakpoint SBP. Should do whatever
* book-keeping is necessary and then continue the process. */
void continue_after_breakpoint(struct Process *proc, struct breakpoint *sbp);
void continue_after_breakpoint(struct process *proc, struct breakpoint *sbp);

/* Called after we received a vfork. Should do whatever book-keeping
* is necessary and continue the process if necessary. N.B. right
* now, with Linux/GNU the only back end, this is not necessary. I
* imagine other systems may be different. */
void continue_after_vfork(struct Process *proc);
void continue_after_vfork(struct process *proc);

/* Called when trace_me or primary trace_pid fail. This may plug in
* any platform-specific knowledge of why it could be so. */
Expand All @@ -171,14 +171,14 @@ void os_ltrace_exiting(void);

/* Should copy COUNT bytes from address ADDR of process PROC to local
* buffer BUF. */
size_t umovebytes (struct Process *proc, void *addr, void *buf, size_t count);
size_t umovebytes(struct process *proc, void *addr, void *buf, size_t count);

/* Find out an address of symbol SYM in process PROC, and return.
* Returning NULL delays breakpoint insertion and enables heaps of
* arch-specific black magic that we should clean up some day.
*
* XXX the same points as for get_instruction_pointer apply. */
void *sym2addr(struct Process *proc, struct library_symbol *sym);
void *sym2addr(struct process *proc, struct library_symbol *sym);

/* Obtain address of PLT entry corresponding to relocation RELA in
* file LTE. This is NDX-th PLT entry in the file.
Expand All @@ -189,7 +189,7 @@ GElf_Addr arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela *rela);
/* Called at some point after we have attached to PROC. This callback
* should insert an introspection breakpoint for handling dynamic
* linker library loads. */
int linkmap_init(struct Process *proc, arch_addr_t dyn_addr);
int linkmap_init(struct process *proc, arch_addr_t dyn_addr);

/* This should produce and return the next event of one of the traced
* processes. The returned pointer will not be freed by the core and
Expand All @@ -198,14 +198,14 @@ int linkmap_init(struct Process *proc, arch_addr_t dyn_addr);
struct Event *next_event(void);

/* Called when process PROC was removed. */
void process_removed(struct Process *proc);
void process_removed(struct process *proc);

/* This should extract entry point address and interpreter (dynamic
* linker) bias if possible. Returns 0 if there were no errors, -1
* otherwise. Sets *ENTRYP and *INTERP_BIASP to non-zero values if
* the corresponding value is known, or zero otherwise; this is not
* done for pointers that are NULL. */
int process_get_entry(struct Process *proc,
int process_get_entry(struct process *proc,
arch_addr_t *entryp,
arch_addr_t *interp_biasp);

Expand All @@ -232,7 +232,7 @@ void arch_elf_destroy(struct ltelf *lte);
* destroy, and clone SBP->arch. arch_breakpoint_init and
* arch_breakpoint_clone return 0 on success or a negative value on
* failure. */
int arch_breakpoint_init(struct Process *proc, struct breakpoint *sbp);
int arch_breakpoint_init(struct process *proc, struct breakpoint *sbp);
void arch_breakpoint_destroy(struct breakpoint *sbp);
int arch_breakpoint_clone(struct breakpoint *retp, struct breakpoint *sbp);

Expand All @@ -259,19 +259,19 @@ int arch_library_symbol_clone(struct library_symbol *retp,
* PROC->arch in case that PROC underwent an exec. See notes at
* process_init, process_destroy, process_clone and process_exec in
* proc.h. */
int arch_process_init(struct Process *proc);
void arch_process_destroy(struct Process *proc);
int arch_process_clone(struct Process *retp, struct Process *proc);
int arch_process_exec(struct Process *proc);
int arch_process_init(struct process *proc);
void arch_process_destroy(struct process *proc);
int arch_process_clone(struct process *retp, struct process *proc);
int arch_process_exec(struct process *proc);

/* The following callbacks have to be implemented in OS backend if
* os.h defines OS_HAVE_PROCESS_DATA. The protocol is same as for,
* respectively, arch_process_init, arch_process_destroy,
* arch_process_clone and arch_process_exec. */
int os_process_init(struct Process *proc);
void os_process_destroy(struct Process *proc);
int os_process_clone(struct Process *retp, struct Process *proc);
int os_process_exec(struct Process *proc);
int os_process_init(struct process *proc);
void os_process_destroy(struct process *proc);
int os_process_clone(struct process *retp, struct process *proc);
int os_process_exec(struct process *proc);

/* The following callback has to be implemented in backend if arch.h
* defines ARCH_HAVE_GET_SYM_INFO.
Expand Down Expand Up @@ -306,18 +306,18 @@ enum plt_status {
* calling arch_plt_sym_val, and symbol is allocated. If plt_ok or
* plt_default are returned, the chain of symbols passed back in RET
* is added to library under construction. */
enum plt_status arch_elf_add_plt_entry(struct Process *proc, struct ltelf *lte,
enum plt_status arch_elf_add_plt_entry(struct process *proc, struct ltelf *lte,
const char *name, GElf_Rela *rela,
size_t i, struct library_symbol **ret);

/* This callback needs to be implemented if arch.h defines
* ARCH_HAVE_DYNLINK_DONE. It is called after the dynamic linker is
* done with the process startup. */
void arch_dynlink_done(struct Process *proc);
void arch_dynlink_done(struct process *proc);

/* This callback needs to be implemented if arch.h defines
* ARCH_HAVE_SYMBOL_RET. It is called after a traced call returns. */
void arch_symbol_ret(struct Process *proc, struct library_symbol *libsym);
void arch_symbol_ret(struct process *proc, struct library_symbol *libsym);


/* This callback needs to be implemented if arch.h defines
Expand All @@ -327,7 +327,7 @@ void arch_symbol_ret(struct Process *proc, struct library_symbol *libsym);
* DYN_ADDR holds the address of the dynamic section.
* If the debug area is found, return 0 and fill in the address in *RET.
* If the debug area is not found, return a negative value. */
int arch_find_dl_debug(struct Process *proc, arch_addr_t dyn_addr,
int arch_find_dl_debug(struct process *proc, arch_addr_t dyn_addr,
arch_addr_t *ret);

/* If arch.h defines ARCH_HAVE_FETCH_ARG, the following callbacks have
Expand Down
38 changes: 18 additions & 20 deletions breakpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@

#include "sysdep.h"
#include "library.h"

struct Process;
struct breakpoint;
#include "forward.h"

struct bp_callbacks {
void (*on_hit)(struct breakpoint *bp, struct Process *proc);
void (*on_continue)(struct breakpoint *bp, struct Process *proc);
void (*on_retract)(struct breakpoint *bp, struct Process *proc);
void (*on_hit)(struct breakpoint *bp, struct process *proc);
void (*on_continue)(struct breakpoint *bp, struct process *proc);
void (*on_retract)(struct breakpoint *bp, struct process *proc);
};

struct breakpoint {
Expand All @@ -61,11 +59,11 @@ struct breakpoint {
};

/* Call on-hit handler of BP, if any is set. */
void breakpoint_on_hit(struct breakpoint *bp, struct Process *proc);
void breakpoint_on_hit(struct breakpoint *bp, struct process *proc);

/* Call on-continue handler of BP. If none is set, call
* continue_after_breakpoint. */
void breakpoint_on_continue(struct breakpoint *bp, struct Process *proc);
void breakpoint_on_continue(struct breakpoint *bp, struct process *proc);

/* Call on-retract handler of BP, if any is set. This should be
* called before the breakpoints are destroyed. The reason for a
Expand All @@ -74,21 +72,21 @@ void breakpoint_on_continue(struct breakpoint *bp, struct Process *proc);
* be called every time we disable the breakpoint, which is too often
* (a breakpoint has to be disabled every time that we need to execute
* the instruction underneath it). */
void breakpoint_on_retract(struct breakpoint *bp, struct Process *proc);
void breakpoint_on_retract(struct breakpoint *bp, struct process *proc);

/* Initialize a breakpoint structure. That doesn't actually realize
* the breakpoint. The breakpoint is initially assumed to be
* disabled. orig_value has to be set separately. CBS may be
* NULL. */
int breakpoint_init(struct breakpoint *bp, struct Process *proc,
int breakpoint_init(struct breakpoint *bp, struct process *proc,
arch_addr_t addr, struct library_symbol *libsym);

/* Make a clone of breakpoint BP into the area of memory pointed to by
* RETP. The original breakpoint was assigned to process OLD_PROC,
* the cloned breakpoint will be attached to process NEW_PROC.
* Returns 0 on success or a negative value on failure. */
int breakpoint_clone(struct breakpoint *retp, struct Process *new_proc,
struct breakpoint *bp, struct Process *old_proc);
int breakpoint_clone(struct breakpoint *retp, struct process *new_proc,
struct breakpoint *bp, struct process *old_proc);

/* Set callbacks. If CBS is non-NULL, then BP->cbs shall be NULL. */
void breakpoint_set_callbacks(struct breakpoint *bp, struct bp_callbacks *cbs);
Expand All @@ -98,12 +96,12 @@ void breakpoint_destroy(struct breakpoint *bp);

/* Call enable_breakpoint the first time it's called. Returns 0 on
* success and a negative value on failure. */
int breakpoint_turn_on(struct breakpoint *bp, struct Process *proc);
int breakpoint_turn_on(struct breakpoint *bp, struct process *proc);

/* Call disable_breakpoint when turned off the same number of times
* that it was turned on. Returns 0 on success and a negative value
* on failure. */
int breakpoint_turn_off(struct breakpoint *bp, struct Process *proc);
int breakpoint_turn_off(struct breakpoint *bp, struct process *proc);

/* Utility function that does what typically needs to be done when a
* breakpoint is to be inserted. It checks whether there is another
Expand All @@ -113,7 +111,7 @@ int breakpoint_turn_off(struct breakpoint *bp, struct Process *proc);
* added as well as preexisting breakpoints, it then calls
* BREAKPOINT_TURN_ON. If anything fails, it cleans up and returns
* NULL. Otherwise it returns the breakpoint for ADDR. */
struct breakpoint *insert_breakpoint(struct Process *proc, void *addr,
struct breakpoint *insert_breakpoint(struct process *proc, void *addr,
struct library_symbol *libsym);

/* Name of a symbol associated with BP. May be NULL. */
Expand All @@ -127,12 +125,12 @@ struct library *breakpoint_library(const struct breakpoint *bp);
* - proc_remove_breakpoint
* - breakpoint_destroy
* XXX */
void delete_breakpoint(struct Process *proc, void *addr);
void delete_breakpoint(struct process *proc, void *addr);

/* XXX some of the following belongs to proc.h/proc.c. */
struct breakpoint *address2bpstruct(struct Process *proc, void *addr);
void enable_all_breakpoints(struct Process *proc);
void disable_all_breakpoints(struct Process *proc);
int breakpoints_init(struct Process *proc);
struct breakpoint *address2bpstruct(struct process *proc, void *addr);
void enable_all_breakpoints(struct process *proc);
void disable_all_breakpoints(struct process *proc);
int breakpoints_init(struct process *proc);

#endif /* BREAKPOINT_H */
Loading

0 comments on commit 929bd57

Please sign in to comment.