run Lindent over source to get everything looking about the same
diff --git a/breakpoints.c b/breakpoints.c
index d9ea6e9..96dd0b7 100644
--- a/breakpoints.c
+++ b/breakpoints.c
@@ -18,63 +18,69 @@
/*****************************************************************************/
-struct breakpoint *
-address2bpstruct(struct process * proc, void * addr) {
+struct breakpoint *address2bpstruct(struct process *proc, void *addr)
+{
return dict_find_entry(proc->breakpoints, addr);
}
void
-insert_breakpoint(struct process * proc, void * addr, struct library_symbol * libsym) {
- struct breakpoint * sbp;
+insert_breakpoint(struct process *proc, void *addr,
+ struct library_symbol *libsym)
+{
+ struct breakpoint *sbp;
if (!proc->breakpoints) {
- proc->breakpoints = dict_init(dict_key2hash_int, dict_key_cmp_int);
- /* atexit(brk_dict_clear); */ /* why bother to do this on exit? */
+ proc->breakpoints =
+ dict_init(dict_key2hash_int, dict_key_cmp_int);
+ /* atexit(brk_dict_clear); *//* why bother to do this on exit? */
}
- if (!addr)
- return;
+ if (!addr)
+ return;
- if (libsym)
+ if (libsym)
libsym->needs_init = 0;
sbp = dict_find_entry(proc->breakpoints, addr);
if (!sbp) {
sbp = calloc(1, sizeof(struct breakpoint));
if (!sbp) {
- return; /* TODO FIXME XXX: error_mem */
+ return; /* TODO FIXME XXX: error_mem */
}
dict_enter(proc->breakpoints, addr, sbp);
sbp->addr = addr;
- sbp->libsym = libsym;
- if (libsym)
- libsym->brkpnt = sbp;
+ sbp->libsym = libsym;
+ if (libsym)
+ libsym->brkpnt = sbp;
}
sbp->enabled++;
- if (sbp->enabled==1 && proc->pid) enable_breakpoint(proc->pid, sbp);
+ if (sbp->enabled == 1 && proc->pid)
+ enable_breakpoint(proc->pid, sbp);
}
-void
-delete_breakpoint(struct process * proc, void * addr) {
- struct breakpoint * sbp = dict_find_entry(proc->breakpoints, addr);
- assert(sbp); /* FIXME: remove after debugging has been done. */
+void delete_breakpoint(struct process *proc, void *addr)
+{
+ struct breakpoint *sbp = dict_find_entry(proc->breakpoints, addr);
+ assert(sbp); /* FIXME: remove after debugging has been done. */
/* This should only happen on out-of-memory conditions. */
- if (sbp == NULL) return;
+ if (sbp == NULL)
+ return;
sbp->enabled--;
- if (sbp->enabled == 0) disable_breakpoint(proc->pid, sbp);
+ if (sbp->enabled == 0)
+ disable_breakpoint(proc->pid, sbp);
assert(sbp->enabled >= 0);
}
-static void
-enable_bp_cb(void * addr, void * sbp, void * proc) {
+static void enable_bp_cb(void *addr, void *sbp, void *proc)
+{
if (((struct breakpoint *)sbp)->enabled) {
enable_breakpoint(((struct process *)proc)->pid, sbp);
}
}
-void
-enable_all_breakpoints(struct process * proc) {
+void enable_all_breakpoints(struct process *proc)
+{
if (proc->breakpoints_enabled <= 0) {
#ifdef __powerpc__
unsigned long a;
@@ -85,7 +91,10 @@
* dont enable the breakpoints
*/
if (opt_L) {
- a = ptrace(PTRACE_PEEKTEXT, proc->pid, plt2addr(proc, proc->list_of_symbols->enter_addr), 0);
+ a = ptrace(PTRACE_PEEKTEXT, proc->pid,
+ plt2addr(proc,
+ proc->list_of_symbols->enter_addr),
+ 0);
if (a == 0x0)
return;
}
@@ -93,21 +102,22 @@
debug(1, "Enabling breakpoints for pid %u...", proc->pid);
if (proc->breakpoints) {
- dict_apply_to_all(proc->breakpoints, enable_bp_cb, proc);
+ dict_apply_to_all(proc->breakpoints, enable_bp_cb,
+ proc);
}
}
proc->breakpoints_enabled = 1;
}
-static void
-disable_bp_cb(void * addr, void * sbp, void * proc) {
+static void disable_bp_cb(void *addr, void *sbp, void *proc)
+{
if (((struct breakpoint *)sbp)->enabled) {
disable_breakpoint(((struct process *)proc)->pid, sbp);
}
}
-void
-disable_all_breakpoints(struct process * proc) {
+void disable_all_breakpoints(struct process *proc)
+{
if (proc->breakpoints_enabled) {
debug(1, "Disabling breakpoints for pid %u...", proc->pid);
dict_apply_to_all(proc->breakpoints, disable_bp_cb, proc);
@@ -115,17 +125,17 @@
proc->breakpoints_enabled = 0;
}
-static void
-free_bp_cb(void * addr, void * sbp, void * data) {
+static void free_bp_cb(void *addr, void *sbp, void *data)
+{
assert(sbp);
free(sbp);
}
-void
-breakpoints_init(struct process * proc) {
- struct library_symbol * sym;
+void breakpoints_init(struct process *proc)
+{
+ struct library_symbol *sym;
- if (proc->breakpoints) { /* let's remove that struct */
+ if (proc->breakpoints) { /* let's remove that struct */
/* TODO FIXME XXX: free() all "struct breakpoint"s */
dict_apply_to_all(proc->breakpoints, free_bp_cb, NULL);
dict_clear(proc->breakpoints);
@@ -135,12 +145,12 @@
if (opt_L && proc->filename) {
proc->list_of_symbols = read_elf(proc);
if (opt_e) {
- struct library_symbol ** tmp1 = &(proc->list_of_symbols);
- while(*tmp1) {
- struct opt_e_t * tmp2 = opt_e;
+ struct library_symbol **tmp1 = &(proc->list_of_symbols);
+ while (*tmp1) {
+ struct opt_e_t *tmp2 = opt_e;
int keep = !opt_e_enable;
- while(tmp2) {
+ while (tmp2) {
if (!strcmp((*tmp1)->name, tmp2->name)) {
keep = opt_e_enable;
}
@@ -158,11 +168,11 @@
}
sym = proc->list_of_symbols;
while (sym) {
- /* proc->pid==0 delays enabling. */
+ /* proc->pid==0 delays enabling. */
if (sym->static_plt2addr) {
insert_breakpoint(proc, sym->enter_addr, sym);
- } else {
- insert_breakpoint(proc, plt2addr(proc, sym->enter_addr), sym); /* proc->pid==0 delays enabling. */
+ } else {
+ insert_breakpoint(proc, plt2addr(proc, sym->enter_addr), sym); /* proc->pid==0 delays enabling. */
}
sym = sym->next;
}
@@ -170,19 +180,21 @@
proc->breakpoints_enabled = -1;
}
-void
-reinitialize_breakpoints (struct process * proc) {
- struct library_symbol * sym = proc->list_of_symbols;
-
- while (sym) {
- if (sym->needs_init) {
- insert_breakpoint(proc, plt2addr(proc, sym->enter_addr), sym);
- if (sym->needs_init && !sym->is_weak) {
- fprintf(stderr, "could not re-initialize breakpoint for \"%s\" in file \"%s\"\n", sym->name, proc->filename);
- exit(1);
- }
- }
- sym = sym->next;
- }
-}
+void reinitialize_breakpoints(struct process *proc)
+{
+ struct library_symbol *sym = proc->list_of_symbols;
+ while (sym) {
+ if (sym->needs_init) {
+ insert_breakpoint(proc, plt2addr(proc, sym->enter_addr),
+ sym);
+ if (sym->needs_init && !sym->is_weak) {
+ fprintf(stderr,
+ "could not re-initialize breakpoint for \"%s\" in file \"%s\"\n",
+ sym->name, proc->filename);
+ exit(1);
+ }
+ }
+ sym = sym->next;
+ }
+}