diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | README | 4 | ||||
-rw-r--r-- | breakpoints.c | 52 | ||||
-rw-r--r-- | debug.c | 4 | ||||
-rw-r--r-- | debug.h | 2 | ||||
-rw-r--r-- | display_args.c | 258 | ||||
-rw-r--r-- | elf.c | 64 | ||||
-rw-r--r-- | elf.h | 6 | ||||
-rw-r--r-- | etc/ltrace.conf | 2 | ||||
-rw-r--r-- | ltrace.c | 12 | ||||
-rw-r--r-- | ltrace.h | 7 | ||||
-rw-r--r-- | output.c | 21 | ||||
-rw-r--r-- | process_event.c | 45 | ||||
-rw-r--r-- | read_config_file.c | 622 | ||||
-rw-r--r-- | sysdeps/linux-gnu/alpha/trace.c | 4 | ||||
-rw-r--r-- | sysdeps/linux-gnu/arm/trace.c | 4 | ||||
-rw-r--r-- | sysdeps/linux-gnu/i386/trace.c | 4 | ||||
-rw-r--r-- | sysdeps/linux-gnu/ia64/trace.c | 3 | ||||
-rw-r--r-- | sysdeps/linux-gnu/m68k/trace.c | 4 | ||||
-rw-r--r-- | sysdeps/linux-gnu/mipsel/trace.c | 2 | ||||
-rw-r--r-- | sysdeps/linux-gnu/ppc/trace.c | 4 | ||||
-rw-r--r-- | sysdeps/linux-gnu/s390/trace.c | 3 | ||||
-rw-r--r-- | sysdeps/linux-gnu/sparc/trace.c | 4 | ||||
-rw-r--r-- | sysdeps/linux-gnu/x86_64/trace.c | 4 | ||||
-rw-r--r-- | wait_for_something.c | 2 |
25 files changed, 549 insertions, 597 deletions
@@ -1,8 +1,15 @@ +2007-09-04 Juan Cespedes <cespedes@debian.org> + + * ltrace.h: Take arg_num out of arg_type_info + * linux-gnu/*/trace.c: gimme_arg(): Add arg_num as argument + * ltrace.c: check for existence of $HOME before using it + * General: Small fixes (indentation) + 2007-08-31 Juan Cespedes <cespedes@debian.org> * General: Small fixes (indentation, typos, clean-up of code) * ltrace.c: Close output file on exit - * ltrace.c: use getenf("HOME") instead of getpwuid(geteuid())->pw_dir + * ltrace.c: use getenv("HOME") instead of getpwuid(geteuid())->pw_dir * read_config_file.c, display_args.c: remove "ignore" argtype; that's what "void" is for * packaging/debian/: misc fixes, sync with version 0.5-2 @@ -2,7 +2,7 @@ A Dynamic Library Tracer - Copyright 1997-2006 Juan Cespedes <cespedes@debian.org> + Copyright 1997-2007 Juan Cespedes <cespedes@debian.org> Contents @@ -65,7 +65,7 @@ This file is very incomplete and out-of-date. 6. License ---------- - Copyright (C) 1997-2006 Juan Cespedes <cespedes@debian.org> + Copyright (C) 1997-2007 Juan Cespedes <cespedes@debian.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/breakpoints.c b/breakpoints.c index 952acd3..18de1e2 100644 --- a/breakpoints.c +++ b/breakpoints.c @@ -100,32 +100,32 @@ void enable_all_breakpoints(struct process *proc) proc); } #ifdef __mips__ - { - // I'm sure there is a nicer way to do this. We need to - // insert breakpoints _after_ the child has been started. - struct library_symbol *sym; - struct library_symbol *new_sym; - sym=proc->list_of_symbols; - while(sym){ - void *addr= sym2addr(proc,sym); - if(!addr){ - sym=sym->next; - continue; - } - if(dict_find_entry(proc->breakpoints,addr)){ - sym=sym->next; - continue; - } - debug(2,"inserting bp %p %s",addr,sym->name); - new_sym=malloc(sizeof(*new_sym)); - memcpy(new_sym,sym,sizeof(*new_sym)); - new_sym->next=proc->list_of_symbols; - proc->list_of_symbols=new_sym; - new_sym->brkpnt=0; - insert_breakpoint(proc, addr, new_sym); - sym=sym->next; - } - } + { + // I'm sure there is a nicer way to do this. We need to + // insert breakpoints _after_ the child has been started. + struct library_symbol *sym; + struct library_symbol *new_sym; + sym=proc->list_of_symbols; + while(sym){ + void *addr= sym2addr(proc,sym); + if(!addr){ + sym=sym->next; + continue; + } + if(dict_find_entry(proc->breakpoints,addr)){ + sym=sym->next; + continue; + } + debug(2,"inserting bp %p %s",addr,sym->name); + new_sym=malloc(sizeof(*new_sym)); + memcpy(new_sym,sym,sizeof(*new_sym)); + new_sym->next=proc->list_of_symbols; + proc->list_of_symbols=new_sym; + new_sym->brkpnt=0; + insert_breakpoint(proc, addr, new_sym); + sym=sym->next; + } + } #endif } proc->breakpoints_enabled = 1; @@ -6,8 +6,8 @@ #include "output.h" void -debug_(int level, const char *file, int line, const char *func, const char *fmt, - ...) +debug_(int level, const char *file, int line, const char *func, + const char *fmt, ...) { char buf[1024]; va_list args; @@ -1,7 +1,7 @@ #include <features.h> void debug_(int level, const char *file, int line, const char *func, - const char *fmt, ...) __attribute__((format(printf,5,6))); + const char *fmt, ...) __attribute__((format(printf,5,6))); int xinfdump(long, void *, int); diff --git a/display_args.c b/display_args.c index bd050e7..92f3e7d 100644 --- a/display_args.c +++ b/display_args.c @@ -26,29 +26,28 @@ static int array_maxlength = INT_MAX; static long get_length(enum tof type, struct process *proc, int len_spec, void *st, arg_type_info* st_info) { - long len; - arg_type_info info; + long len; + arg_type_info info; - if (len_spec > 0) - return len_spec; - if (type == LT_TOF_STRUCT) { - umovelong(proc, st + st_info->u.struct_info.offset[-len_spec-1], &len); - return len; - } + if (len_spec > 0) + return len_spec; + if (type == LT_TOF_STRUCT) { + umovelong(proc, st + st_info->u.struct_info.offset[-len_spec-1], &len); + return len; + } - info.arg_num = -len_spec - 1; - info.type = ARGTYPE_INT; - return gimme_arg(type, proc, &info); + info.type = ARGTYPE_INT; + return gimme_arg(type, proc, -len_spec-1, &info); } static int display_ptrto(enum tof type, struct process *proc, long item, arg_type_info * info, void *st, arg_type_info* st_info) { - arg_type_info temp; - temp.type = ARGTYPE_POINTER; - temp.u.ptr_info.info = info; - return display_value(type, proc, item, &temp, st, st_info); + arg_type_info temp; + temp.type = ARGTYPE_POINTER; + temp.u.ptr_info.info = info; + return display_value(type, proc, item, &temp, st, st_info); } /* @@ -63,97 +62,97 @@ static int display_arrayptr(enum tof type, struct process *proc, void *addr, arg_type_info * info, void *st, arg_type_info* st_info) { - int len = 0; - int i; - int array_len; - - if (addr == NULL) - return fprintf(output, "NULL"); - - array_len = get_length(type, proc, info->u.array_info.len_spec, - st, st_info); - len += fprintf(output, "[ "); - for (i = 0; i < opt_A && i < array_maxlength && i < array_len; i++) { - arg_type_info *elt_type = info->u.array_info.elt_type; - size_t elt_size = info->u.array_info.elt_size; - if (i != 0) - len += fprintf(output, ", "); - if (opt_d) - len += fprintf(output, "%p=", addr); - len += - display_ptrto(type, proc, (long) addr, elt_type, st, st_info); - addr += elt_size; - } - if (i < array_len) - len += fprintf(output, "..."); - len += fprintf(output, " ]"); - return len; + int len = 0; + int i; + int array_len; + + if (addr == NULL) + return fprintf(output, "NULL"); + + array_len = get_length(type, proc, info->u.array_info.len_spec, + st, st_info); + len += fprintf(output, "[ "); + for (i = 0; i < opt_A && i < array_maxlength && i < array_len; i++) { + arg_type_info *elt_type = info->u.array_info.elt_type; + size_t elt_size = info->u.array_info.elt_size; + if (i != 0) + len += fprintf(output, ", "); + if (opt_d) + len += fprintf(output, "%p=", addr); + len += + display_ptrto(type, proc, (long) addr, elt_type, st, st_info); + addr += elt_size; + } + if (i < array_len) + len += fprintf(output, "..."); + len += fprintf(output, " ]"); + return len; } - + /* addr - A pointer to the beginning of the memory region occupied by * the struct (aka a pointer to the struct) */ static int display_structptr(enum tof type, struct process *proc, void *addr, arg_type_info * info) { - int i; - arg_type_info *field; - int len = 0; - - if (addr == NULL) - return fprintf(output, "NULL"); - - len += fprintf(output, "{ "); - for (i = 0; (field = info->u.struct_info.fields[i]) != NULL; i++) { - if (i != 0) - len += fprintf(output, ", "); - if (opt_d) - len += - fprintf(output, "%p=", - addr + info->u.struct_info.offset[i]); - len += - display_ptrto(LT_TOF_STRUCT, proc, - (long) addr + info->u.struct_info.offset[i], - field, addr, info); - } - len += fprintf(output, " }"); - - return len; + int i; + arg_type_info *field; + int len = 0; + + if (addr == NULL) + return fprintf(output, "NULL"); + + len += fprintf(output, "{ "); + for (i = 0; (field = info->u.struct_info.fields[i]) != NULL; i++) { + if (i != 0) + len += fprintf(output, ", "); + if (opt_d) + len += + fprintf(output, "%p=", + addr + info->u.struct_info.offset[i]); + len += + display_ptrto(LT_TOF_STRUCT, proc, + (long) addr + info->u.struct_info.offset[i], + field, addr, info); + } + len += fprintf(output, " }"); + + return len; } static int display_pointer(enum tof type, struct process *proc, long value, arg_type_info * info, void *st, arg_type_info* st_info) { - long pointed_to; - arg_type_info *inner = info->u.ptr_info.info; + long pointed_to; + arg_type_info *inner = info->u.ptr_info.info; - if (inner->type == ARGTYPE_ARRAY) { - return display_arrayptr(type, proc, (void*) value, inner, + if (inner->type == ARGTYPE_ARRAY) { + return display_arrayptr(type, proc, (void*) value, inner, st, st_info); - } else if (inner->type == ARGTYPE_STRUCT) { - return display_structptr(type, proc, (void *) value, inner); - } else { - if (value == 0) - return fprintf(output, "NULL"); - else if (umovelong(proc, (void *) value, &pointed_to) < 0) - return fprintf(output, "?"); - else - return display_value(type, proc, pointed_to, inner, - st, st_info); - } + } else if (inner->type == ARGTYPE_STRUCT) { + return display_structptr(type, proc, (void *) value, inner); + } else { + if (value == 0) + return fprintf(output, "NULL"); + else if (umovelong(proc, (void *) value, &pointed_to) < 0) + return fprintf(output, "?"); + else + return display_value(type, proc, pointed_to, inner, + st, st_info); + } } static int display_enum(enum tof type, struct process *proc, - arg_type_info* info, long value) + arg_type_info* info, long value) { - int ii; - for (ii = 0; ii < info->u.enum_info.entries; ++ii) { - if (info->u.enum_info.values[ii] == value) - return fprintf(output, "%s", info->u.enum_info.keys[ii]); - } + int ii; + for (ii = 0; ii < info->u.enum_info.entries; ++ii) { + if (info->u.enum_info.values[ii] == value) + return fprintf(output, "%s", info->u.enum_info.keys[ii]); + } - return display_unknown(type, proc, value); + return display_unknown(type, proc, value); } /* Args: @@ -168,8 +167,8 @@ static int display_enum(enum tof type, struct process *proc, strings whose length is given by another structure element. */ int display_value(enum tof type, struct process *proc, - long value, arg_type_info *info, - void *st, arg_type_info* st_info) + long value, arg_type_info *info, + void *st, arg_type_info* st_info) { int tmp; @@ -228,31 +227,31 @@ int display_value(enum tof type, struct process *proc, info->u.string_n_info.size_spec, st, st_info)); case ARGTYPE_ARRAY: return fprintf(output, "<array without address>"); - case ARGTYPE_ENUM: + case ARGTYPE_ENUM: return display_enum(type, proc, info, value); case ARGTYPE_STRUCT: return fprintf(output, "<struct without address>"); case ARGTYPE_POINTER: return display_pointer(type, proc, value, info, st, st_info); - case ARGTYPE_UNKNOWN: + case ARGTYPE_UNKNOWN: default: return display_unknown(type, proc, value); } } -int display_arg(enum tof type, struct process *proc, arg_type_info * info) +int display_arg(enum tof type, struct process *proc, int arg_num, arg_type_info * info) { - long arg; - - if (info->type == ARGTYPE_VOID) { - return 0; - } else if (info->type == ARGTYPE_FORMAT) { - return display_format(type, proc, info->arg_num); - } else { - arg = gimme_arg(type, proc, info); - return display_value(type, proc, arg, info, NULL, NULL); - } + long arg; + + if (info->type == ARGTYPE_VOID) { + return 0; + } else if (info->type == ARGTYPE_FORMAT) { + return display_format(type, proc, arg_num); + } else { + arg = gimme_arg(type, proc, arg_num, info); + return display_value(type, proc, arg, info, NULL, NULL); + } } static int display_char(int what) @@ -335,9 +334,8 @@ static int display_format(enum tof type, struct process *proc, int arg_num) int len = 0; arg_type_info info; - info.arg_num = arg_num; info.type = ARGTYPE_POINTER; - addr = (void *)gimme_arg(type, proc, &info); + addr = (void *)gimme_arg(type, proc, arg_num, &info); if (!addr) { return fprintf(output, "NULL"); } @@ -380,68 +378,48 @@ static int display_format(enum tof type, struct process *proc, int arg_num) break; } } else if (c == 'd' || c == 'i') { - info.arg_num = ++arg_num; info.type = ARGTYPE_LONG; if (!is_long || proc->mask_32bit) len += fprintf(output, ", %d", - (int)gimme_arg(type, - proc, - &info)); + (int)gimme_arg(type, proc, ++arg_num, &info)); else len += fprintf(output, ", %ld", - gimme_arg(type, - proc, - &info)); + gimme_arg(type, proc, ++arg_num, &info)); break; } else if (c == 'u') { - info.arg_num = ++arg_num; info.type = ARGTYPE_LONG; if (!is_long || proc->mask_32bit) len += fprintf(output, ", %u", - (int)gimme_arg(type, - proc, - &info)); + (int)gimme_arg(type, proc, ++arg_num, &info)); else len += fprintf(output, ", %lu", - gimme_arg(type, - proc, - &info)); + gimme_arg(type, proc, ++arg_num, &info)); break; } else if (c == 'o') { - info.arg_num = ++arg_num; info.type = ARGTYPE_LONG; if (!is_long || proc->mask_32bit) len += fprintf(output, ", 0%o", - (int)gimme_arg(type, - proc, - &info)); + (int)gimme_arg(type, proc, ++arg_num, &info)); else len += fprintf(output, ", 0%lo", - gimme_arg(type, - proc, - &info)); + gimme_arg(type, proc, ++arg_num, &info)); break; } else if (c == 'x' || c == 'X') { - info.arg_num = ++arg_num; info.type = ARGTYPE_LONG; if (!is_long || proc->mask_32bit) len += fprintf(output, ", %#x", - (int)gimme_arg(type, - proc, - &info)); + (int)gimme_arg(type, proc, ++arg_num, &info)); else len += fprintf(output, ", %#lx", - gimme_arg(type, - proc, - &info)); + gimme_arg(type, proc, ++arg_num, &info)); break; } else if (strchr("eEfFgGaACS", c) || (is_long @@ -450,42 +428,32 @@ static int display_format(enum tof type, struct process *proc, int arg_num) str1[i + 1] = '\0'; break; } else if (c == 'c') { - info.arg_num = ++arg_num; info.type = ARGTYPE_LONG; len += fprintf(output, ", '"); len += display_char((int) - gimme_arg(type, proc, - &info)); + gimme_arg(type, proc, ++arg_num, &info)); len += fprintf(output, "'"); break; } else if (c == 's') { - info.arg_num = ++arg_num; info.type = ARGTYPE_POINTER; len += fprintf(output, ", "); len += display_string(type, proc, - (void *)gimme_arg(type, - proc, - &info), + (void *)gimme_arg(type, proc, ++arg_num, &info), string_maxlength); break; } else if (c == 'p' || c == 'n') { - info.arg_num = ++arg_num; info.type = ARGTYPE_POINTER; len += fprintf(output, ", %p", - (void *)gimme_arg(type, - proc, - &info)); + (void *)gimme_arg(type, proc, ++arg_num, &info)); break; } else if (c == '*') { - info.arg_num = ++arg_num; info.type = ARGTYPE_LONG; len += fprintf(output, ", %d", - (int)gimme_arg(type, proc, - &info)); + (int)gimme_arg(type, proc, ++arg_num, &info)); } } } @@ -176,15 +176,15 @@ static void do_init_elf(struct ltelf *lte, const char *filename) table. */ - if(dyn.d_tag==DT_PLTGOT){ - lte->pltgot_addr=dyn.d_un.d_ptr; - } - if(dyn.d_tag==DT_MIPS_LOCAL_GOTNO){ - lte->mips_local_gotno=dyn.d_un.d_val; - } - if(dyn.d_tag==DT_MIPS_GOTSYM){ - lte->mips_gotsym=dyn.d_un.d_val; - } + if(dyn.d_tag==DT_PLTGOT){ + lte->pltgot_addr=dyn.d_un.d_ptr; + } + if(dyn.d_tag==DT_MIPS_LOCAL_GOTNO){ + lte->mips_local_gotno=dyn.d_un.d_val; + } + if(dyn.d_tag==DT_MIPS_GOTSYM){ + lte->mips_gotsym=dyn.d_un.d_val; + } #endif // __mips__ if (dyn.d_tag == DT_JMPREL) relplt_addr = dyn.d_un.d_ptr; @@ -469,28 +469,28 @@ struct library_symbol *read_elf(struct process *proc) for (i = 0; i < library_num; ++i) do_init_elf(<e[i + 1], library[i]); #ifdef __mips__ - // MIPS doesn't use the PLT and the GOT entries get changed - // on startup. - proc->need_to_reinitialize_breakpoints = 1; - for(i=lte->mips_gotsym; i<lte->dynsym_count;i++){ - GElf_Sym sym; - const char *name; - GElf_Addr addr = arch_plt_sym_val(lte, i, 0); - if (gelf_getsym(lte->dynsym, i, &sym) == NULL){ - error(EXIT_FAILURE, 0, - "Couldn't get relocation from \"%s\"", - proc->filename); - } - name=lte->dynstr+sym.st_name; - if(ELF64_ST_TYPE(sym.st_info) != STT_FUNC){ - debug(2,"sym %s not a function",name); - continue; - } - add_library_symbol(addr, name, &library_symbols, 0, - ELF64_ST_BIND(sym.st_info) != 0); - if (!lib_tail) - lib_tail = &(library_symbols->next); - } + // MIPS doesn't use the PLT and the GOT entries get changed + // on startup. + proc->need_to_reinitialize_breakpoints = 1; + for(i=lte->mips_gotsym; i<lte->dynsym_count;i++){ + GElf_Sym sym; + const char *name; + GElf_Addr addr = arch_plt_sym_val(lte, i, 0); + if (gelf_getsym(lte->dynsym, i, &sym) == NULL){ + error(EXIT_FAILURE, 0, + "Couldn't get relocation from \"%s\"", + proc->filename); + } + name=lte->dynstr+sym.st_name; + if(ELF64_ST_TYPE(sym.st_info) != STT_FUNC){ + debug(2,"sym %s not a function",name); + continue; + } + add_library_symbol(addr, name, &library_symbols, 0, + ELF64_ST_BIND(sym.st_info) != 0); + if (!lib_tail) + lib_tail = &(library_symbols->next); + } #else for (i = 0; i < lte->relplt_count; ++i) { GElf_Rel rel; @@ -538,7 +538,7 @@ struct library_symbol *read_elf(struct process *proc) if (proc->need_to_reinitialize_breakpoints) { /* Add "PLTs_initialized_by_here" to opt_x list, if not - already there. */ + already there. */ main_cheat = (struct opt_x_t *)malloc(sizeof(struct opt_x_t)); if (main_cheat == NULL) error(EXIT_FAILURE, 0, "Couldn't allocate memory"); @@ -27,9 +27,9 @@ struct ltelf { int hash_type; int lte_flags; #ifdef __mips__ - size_t pltgot_addr; - size_t mips_local_gotno; - size_t mips_gotsym; + size_t pltgot_addr; + size_t mips_local_gotno; + size_t mips_gotsym; #endif // __mips__ }; diff --git a/etc/ltrace.conf b/etc/ltrace.conf index 96dc807..ed4fc5a 100644 --- a/etc/ltrace.conf +++ b/etc/ltrace.conf @@ -97,7 +97,7 @@ ; arpa/inet.h int inet_aton(string,addr); -string inet_ntoa(addr); ; It isn't a ADDR but an hexa number... +string inet_ntoa(addr); ; It isn't an ADDR but an hexa number... addr inet_addr(string); ; bfd.h @@ -118,11 +118,13 @@ int main(int argc, char **argv) if (opt_F->filename[0] == '~') { char path[PATH_MAX]; char *home_dir = getenv("HOME"); - strncpy(path, home_dir, PATH_MAX - 1); - path[PATH_MAX - 1] = '\0'; - strncat(path, opt_F->filename + 1, - PATH_MAX - strlen(path) - 1); - read_config_file(path); + if (home_dir) { + strncpy(path, home_dir, PATH_MAX - 1); + path[PATH_MAX - 1] = '\0'; + strncat(path, opt_F->filename + 1, + PATH_MAX - strlen(path) - 1); + read_config_file(path); + } } else { read_config_file(opt_F->filename); } @@ -55,7 +55,6 @@ enum arg_type { typedef struct arg_type_info_t { enum arg_type type; - int arg_num; union { // ARGTYPE_ENUM struct { @@ -106,7 +105,7 @@ enum tof { LT_TOF_FUNCTIONR, /* Return from a real library function */ LT_TOF_SYSCALL, /* A syscall */ LT_TOF_SYSCALLR, /* Return from a syscall */ - LT_TOF_STRUCT /* Not a function; read args from struct */ + LT_TOF_STRUCT /* Not a function; read args from struct */ }; struct function { @@ -211,7 +210,7 @@ extern void *instruction_pointer; extern struct event *wait_for_something(void); extern void process_event(struct event *event); extern void execute_program(struct process *, char **); -extern int display_arg(enum tof type, struct process *proc, arg_type_info *info); +extern int display_arg(enum tof type, struct process *proc, int arg_num, arg_type_info *info); extern struct breakpoint *address2bpstruct(struct process *proc, void *addr); extern void breakpoints_init(struct process *proc); extern void insert_breakpoint(struct process *proc, void *addr, @@ -248,7 +247,7 @@ extern void continue_after_signal(pid_t pid, int signum); extern void continue_after_breakpoint(struct process *proc, struct breakpoint *sbp); extern void continue_enabling_breakpoint(pid_t pid, struct breakpoint *sbp); -extern long gimme_arg(enum tof type, struct process *proc, arg_type_info *); +extern long gimme_arg(enum tof type, struct process *proc, int arg_num, arg_type_info *info); extern void save_register_args(enum tof type, struct process *proc); extern int umovestr(struct process *proc, void *addr, int len, void *laddr); extern int umovelong(struct process *proc, void *addr, long *result); @@ -191,26 +191,23 @@ void output_left(enum tof type, struct process *proc, char *function_name) func = name2func(function_name); if (!func) { int i; - arg_type_info info = *arg_unknown; for (i = 0; i < 4; i++) { - info.arg_num = i; current_column += - display_arg(type, proc, &info); + display_arg(type, proc, i, arg_unknown); current_column += fprintf(output, ", "); } - info.arg_num = 4; - current_column += display_arg(type, proc, &info); + current_column += display_arg(type, proc, 4, arg_unknown); return; } else { int i; for (i = 0; i < func->num_params - func->params_right - 1; i++) { current_column += - display_arg(type, proc, func->arg_info[i]); + display_arg(type, proc, i, func->arg_info[i]); current_column += fprintf(output, ", "); } if (func->num_params > func->params_right) { current_column += - display_arg(type, proc, func->arg_info[i]); + display_arg(type, proc, i, func->arg_info[i]); if (func->params_right) { current_column += fprintf(output, ", "); } @@ -279,23 +276,21 @@ void output_right(enum tof type, struct process *proc, char *function_name) } if (!func) { - arg_type_info info = *arg_unknown; current_column += fprintf(output, ") "); tabto(opt_a - 1); fprintf(output, "= "); - info.arg_num = -1; - display_arg(type, proc, &info); + display_arg(type, proc, -1, arg_unknown); } else { int i; for (i = func->num_params - func->params_right; i < func->num_params - 1; i++) { current_column += - display_arg(type, proc, func->arg_info[i]); + display_arg(type, proc, i, func->arg_info[i]); current_column += fprintf(output, ", "); } if (func->params_right) { current_column += - display_arg(type, proc, func->arg_info[i]); + display_arg(type, proc, i, func->arg_info[i]); } current_column += fprintf(output, ") "); tabto(opt_a - 1); @@ -303,7 +298,7 @@ void output_right(enum tof type, struct process *proc, char *function_name) if (func->return_info->type == ARGTYPE_VOID) { fprintf(output, "<void>"); } else { - display_arg(type, proc, func->return_info); + display_arg(type, proc, -1, func->return_info); } } if (opt_T) { diff --git a/process_event.c b/process_event.c index c770647..419eb9c 100644 --- a/process_event.c +++ b/process_event.c @@ -225,10 +225,9 @@ static void process_sysret(struct event *event) if (fork_p(event->proc, event->e_un.sysnum)) { if (opt_f) { arg_type_info info; - info.arg_num = -1; /* Return value */ info.type = ARGTYPE_LONG; pid_t child = - gimme_arg(LT_TOF_SYSCALLR, event->proc, &info); + gimme_arg(LT_TOF_SYSCALLR, event->proc, -1, &info); if (child > 0) { open_pid(child, 0); } @@ -253,10 +252,10 @@ static void process_breakpoint(struct event *event) #ifdef __powerpc__ struct breakpoint *nxtbp; char nop_inst[] = PPC_NOP; - if (memcmp(sbp->orig_value, nop_inst, PPC_NOP_LENGTH) == 0) { - nxtbp = address2bpstruct(event->proc, - event->e_un.brk_addr + - PPC_NOP_LENGTH); + if (memcmp(sbp->orig_value, nop_inst, PPC_NOP_LENGTH) == 0) { + nxtbp = address2bpstruct(event->proc, + event->e_un.brk_addr + + PPC_NOP_LENGTH); if (nxtbp != 0) { enable_breakpoint(event->proc->pid, sbp); continue_after_breakpoint(event->proc, nxtbp); @@ -308,22 +307,22 @@ static void process_breakpoint(struct event *event) } } #elif defined(__mips__) - void *addr; - void *old_addr; - struct library_symbol *sym= event->proc->callstack[i].c_un.libfunc; - assert(sym && sym->brkpnt); - old_addr=sym->brkpnt->addr; - addr=sym2addr(event->proc,sym); - assert(old_addr !=0 && addr !=0); - if(addr != old_addr){ - struct library_symbol *new_sym; - new_sym=malloc(sizeof(*new_sym)); - memcpy(new_sym,sym,sizeof(*new_sym)); - new_sym->next=event->proc->list_of_symbols; - event->proc->list_of_symbols=new_sym; - new_sym->brkpnt=0; - insert_breakpoint(event->proc, addr, new_sym); - } + void *addr; + void *old_addr; + struct library_symbol *sym= event->proc->callstack[i].c_un.libfunc; + assert(sym && sym->brkpnt); + old_addr=sym->brkpnt->addr; + addr=sym2addr(event->proc,sym); + assert(old_addr !=0 && addr !=0); + if(addr != old_addr){ + struct library_symbol *new_sym; + new_sym=malloc(sizeof(*new_sym)); + memcpy(new_sym,sym,sizeof(*new_sym)); + new_sym->next=event->proc->list_of_symbols; + event->proc->list_of_symbols=new_sym; + new_sym->brkpnt=0; + insert_breakpoint(event->proc, addr, new_sym); + } #endif for (j = event->proc->callstack_depth - 1; j > i; j--) { callstack_pop(event->proc); @@ -404,7 +403,7 @@ callstack_push_symfunc(struct process *proc, struct library_symbol *sym) elem->c_un.libfunc = sym; elem->return_addr = proc->return_addr; - if (elem->return_addr) { + if (elem->return_addr) { insert_breakpoint(proc, elem->return_addr, 0); } diff --git a/read_config_file.c b/read_config_file.c index 6c42ca5..8cfa6e8 100644 --- a/read_config_file.c +++ b/read_config_file.c @@ -88,7 +88,7 @@ static arg_type_info *str2type(char **str) while (tmp->name) { if (!strncmp(*str, tmp->name, strlen(tmp->name)) - && index(" ,()#*;012345[", *(*str + strlen(tmp->name)))) { + && index(" ,()#*;012345[", *(*str + strlen(tmp->name)))) { *str += strlen(tmp->name); return lookup_prototype(tmp->pt); } @@ -106,28 +106,28 @@ static void eat_spaces(char **str) static char *xstrndup(char *str, size_t len) { - char *ret = (char *) malloc(len + 1); - strncpy(ret, str, len); - ret[len] = 0; - return ret; + char *ret = (char *) malloc(len + 1); + strncpy(ret, str, len); + ret[len] = 0; + return ret; } static char *parse_ident(char **str) { - char *ident = *str; + char *ident = *str; - if (!isalnum(**str) && **str != '_') { - output_line(0, "Syntax error in `%s', line %d: Bad identifier", - filename, line_no); - error_count++; - return NULL; - } + if (!isalnum(**str) && **str != '_') { + output_line(0, "Syntax error in `%s', line %d: Bad identifier", + filename, line_no); + error_count++; + return NULL; + } - while (**str && (isalnum(**str) || **str == '_')) { - ++(*str); - } + while (**str && (isalnum(**str) || **str == '_')) { + ++(*str); + } - return xstrndup(ident, *str - ident); + return xstrndup(ident, *str - ident); } /* @@ -164,17 +164,17 @@ static char *start_of_arg_sig(char *str) static int parse_int(char **str) { - char *end; - long n = strtol(*str, &end, 0); - if (end == *str) { - output_line(0, "Syntax error in `%s', line %d: Bad number (%s)", - filename, line_no, *str); - error_count++; - return 0; - } - - *str = end; - return n; + char *end; + long n = strtol(*str, &end, 0); + if (end == *str) { + output_line(0, "Syntax error in `%s', line %d: Bad number (%s)", + filename, line_no, *str); + error_count++; + return 0; + } + + *str = end; + return n; } /* @@ -192,192 +192,192 @@ static int parse_int(char **str) */ static int parse_argnum(char **str) { - int multiplier = 1; - int n = 0; - - if (strncmp(*str, "arg", 3) == 0) { - (*str) += 3; - multiplier = -1; - } else if (strncmp(*str, "elt", 3) == 0) { - (*str) += 3; - multiplier = -1; - } else if (strncmp(*str, "retval", 6) == 0) { - (*str) += 6; - return 0; - } - - n = parse_int(str); - - return n * multiplier; + int multiplier = 1; + int n = 0; + + if (strncmp(*str, "arg", 3) == 0) { + (*str) += 3; + multiplier = -1; + } else if (strncmp(*str, "elt", 3) == 0) { + (*str) += 3; + multiplier = -1; + } else if (strncmp(*str, "retval", 6) == 0) { + (*str) += 6; + return 0; + } + + n = parse_int(str); + + return n * multiplier; } struct typedef_node_t { - char *name; - arg_type_info *info; - struct typedef_node_t *next; + char *name; + arg_type_info *info; + struct typedef_node_t *next; } *typedefs = NULL; static arg_type_info *lookup_typedef(char **str) { - struct typedef_node_t *node; - char *end = *str; - while (*end && (isalnum(*end) || *end == '_')) - ++end; - if (end == *str) - return NULL; + struct typedef_node_t *node; + char *end = *str; + while (*end && (isalnum(*end) || *end == '_')) + ++end; + if (end == *str) + return NULL; - for (node = typedefs; node != NULL; node = node->next) { - if (strncmp(*str, node->name, end - *str) == 0) { - (*str) += strlen(node->name); - return node->info; + for (node = typedefs; node != NULL; node = node->next) { + if (strncmp(*str, node->name, end - *str) == 0) { + (*str) += strlen(node->name); + return node->info; + } } - } - return NULL; + return NULL; } static void parse_typedef(char **str) { - char *name; - arg_type_info *info; - struct typedef_node_t *binding; - - (*str) += strlen("typedef"); - eat_spaces(str); - - // Grab out the name of the type - name = parse_ident(str); - - // Skip = sign - eat_spaces(str); - if (**str != '=') { - output_line(0, - "Syntax error in `%s', line %d: expected '=', got '%c'", - filename, line_no, **str); - error_count++; - return; - } - (*str)++; - eat_spaces(str); - - // Parse the type - info = parse_type(str); - - // Insert onto beginning of linked list - binding = malloc(sizeof(*binding)); - binding->name = name; - binding->info = info; - binding->next = typedefs; - typedefs = binding; + char *name; + arg_type_info *info; + struct typedef_node_t *binding; + + (*str) += strlen("typedef"); + eat_spaces(str); + + // Grab out the name of the type + name = parse_ident(str); + + // Skip = sign + eat_spaces(str); + if (**str != '=') { + output_line(0, + "Syntax error in `%s', line %d: expected '=', got '%c'", + filename, line_no, **str); + error_count++; + return; + } + (*str)++; + eat_spaces(str); + + // Parse the type + info = parse_type(str); + + // Insert onto beginning of linked list + binding = malloc(sizeof(*binding)); + binding->name = name; + binding->info = info; + binding->next = typedefs; + typedefs = binding; } static size_t arg_sizeof(arg_type_info * arg) { - if (arg->type == ARGTYPE_CHAR) { - return sizeof(char); - } else if (arg->type == ARGTYPE_SHORT || arg->type == ARGTYPE_USHORT) { - return sizeof(short); - } else if (arg->type == ARGTYPE_FLOAT) { - return sizeof(float); - } else if (arg->type == ARGTYPE_DOUBLE) { - return sizeof(double); - } else if (arg->type == ARGTYPE_ENUM) { - return sizeof(int); - } else if (arg->type == ARGTYPE_STRUCT) { - return arg->u.struct_info.size; - } else if (arg->type == ARGTYPE_POINTER) { - return sizeof(void*); - } else if (arg->type == ARGTYPE_ARRAY) { - if (arg->u.array_info.len_spec > 0) - return arg->u.array_info.len_spec * arg->u.array_info.elt_size; - else - return sizeof(void *); - } else { - return sizeof(int); - } + if (arg->type == ARGTYPE_CHAR) { + return sizeof(char); + } else if (arg->type == ARGTYPE_SHORT || arg->type == ARGTYPE_USHORT) { + return sizeof(short); + } else if (arg->type == ARGTYPE_FLOAT) { + return sizeof(float); + } else if (arg->type == ARGTYPE_DOUBLE) { + return sizeof(double); + } else if (arg->type == ARGTYPE_ENUM) { + return sizeof(int); + } else if (arg->type == ARGTYPE_STRUCT) { + return arg->u.struct_info.size; + } else if (arg->type == ARGTYPE_POINTER) { + return sizeof(void*); + } else if (arg->type == ARGTYPE_ARRAY) { + if (arg->u.array_info.len_spec > 0) + return arg->u.array_info.len_spec * arg->u.array_info.elt_size; + else + return sizeof(void *); + } else { + return sizeof(int); + } } #undef alignof #define alignof(field,st) ((size_t) ((char*) &st.field - (char*) &st)) static size_t arg_align(arg_type_info * arg) { - struct { char c; char C; } cC; - struct { char c; short s; } cs; - struct { char c; int i; } ci; - struct { char c; long l; } cl; - struct { char c; void* p; } cp; - struct { char c; float f; } cf; - struct { char c; double d; } cd; - - static size_t char_alignment = alignof(C, cC); - static size_t short_alignment = alignof(s, cs); - static size_t int_alignment = alignof(i, ci); - static size_t long_alignment = alignof(l, cl); - static size_t ptr_alignment = alignof(p, cp); - static size_t float_alignment = alignof(f, cf); - static size_t double_alignment = alignof(d, cd); - - switch (arg->type) { - case ARGTYPE_LONG: - case ARGTYPE_ULONG: - return long_alignment; - case ARGTYPE_CHAR: - return char_alignment; - case ARGTYPE_SHORT: - case ARGTYPE_USHORT: - return short_alignment; - case ARGTYPE_FLOAT: - return float_alignment; - case ARGTYPE_DOUBLE: - return double_alignment; - case ARGTYPE_ADDR: - case ARGTYPE_FILE: - case ARGTYPE_FORMAT: - case ARGTYPE_STRING: - case ARGTYPE_STRING_N: - case ARGTYPE_POINTER: - return ptr_alignment; - - case ARGTYPE_ARRAY: - return arg_align(&arg->u.array_info.elt_type[0]); - - case ARGTYPE_STRUCT: - return arg_align(arg->u.struct_info.fields[0]); - - default: - return int_alignment; - } + struct { char c; char C; } cC; + struct { char c; short s; } cs; + struct { char c; int i; } ci; + struct { char c; long l; } cl; + struct { char c; void* p; } cp; + struct { char c; float f; } cf; + struct { char c; double d; } cd; + + static size_t char_alignment = alignof(C, cC); + static size_t short_alignment = alignof(s, cs); + static size_t int_alignment = alignof(i, ci); + static size_t long_alignment = alignof(l, cl); + static size_t ptr_alignment = alignof(p, cp); + static size_t float_alignment = alignof(f, cf); + static size_t double_alignment = alignof(d, cd); + + switch (arg->type) { + case ARGTYPE_LONG: + case ARGTYPE_ULONG: + return long_alignment; + case ARGTYPE_CHAR: + return char_alignment; + case ARGTYPE_SHORT: + case ARGTYPE_USHORT: + return short_alignment; + case ARGTYPE_FLOAT: + return float_alignment; + case ARGTYPE_DOUBLE: + return double_alignment; + case ARGTYPE_ADDR: + case ARGTYPE_FILE: + case ARGTYPE_FORMAT: + case ARGTYPE_STRING: + case ARGTYPE_STRING_N: + case ARGTYPE_POINTER: + return ptr_alignment; + + case ARGTYPE_ARRAY: + return arg_align(&arg->u.array_info.elt_type[0]); + + case ARGTYPE_STRUCT: + return arg_align(arg->u.struct_info.fields[0]); + + default: + return int_alignment; + } } static size_t align_skip(size_t alignment, size_t offset) { - if (offset % alignment) - return alignment - (offset % alignment); - else - return 0; + if (offset % alignment) + return alignment - (offset % alignment); + else + return 0; } /* I'm sure this isn't completely correct, but just try to get most of * them right for now. */ static void align_struct(arg_type_info* info) { - size_t offset; - int i; - - if (info->u.struct_info.size != 0) - return; // Already done - - // Compute internal padding due to alignment constraints for - // various types. - offset = 0; - for (i = 0; info->u.struct_info.fields[i] != NULL; i++) { - arg_type_info *field = info->u.struct_info.fields[i]; - offset += align_skip(arg_align(field), offset); - info->u.struct_info.offset[i] = offset; - offset += arg_sizeof(field); - } - - info->u.struct_info.size = offset; + size_t offset; + int i; + + if (info->u.struct_info.size != 0) + return; // Already done + + // Compute internal padding due to alignment constraints for + // various types. + offset = 0; + for (i = 0; info->u.struct_info.fields[i] != NULL; i++) { + arg_type_info *field = info->u.struct_info.fields[i]; + offset += align_skip(arg_align(field), offset); + info->u.struct_info.offset[i] = offset; + offset += arg_sizeof(field); + } + + info->u.struct_info.size = offset; } static arg_type_info *parse_nonpointer_type(char **str) @@ -386,17 +386,17 @@ static arg_type_info *parse_nonpointer_type(char **str) arg_type_info *info; if (strncmp(*str, "typedef", 7) == 0) { - parse_typedef(str); - return lookup_prototype(ARGTYPE_UNKNOWN); + parse_typedef(str); + return lookup_prototype(ARGTYPE_UNKNOWN); } simple = str2type(str); if (simple->type == ARGTYPE_UNKNOWN) { - info = lookup_typedef(str); - if (info) - return info; - else - return simple; // UNKNOWN + info = lookup_typedef(str); + if (info) + return info; + else + return simple; // UNKNOWN } info = malloc(sizeof(*info)); @@ -409,149 +409,149 @@ static arg_type_info *parse_nonpointer_type(char **str) /* Syntax: array ( type, N|argN ) */ case ARGTYPE_ARRAY: - (*str)++; // Get past open paren - eat_spaces(str); - if ((info->u.array_info.elt_type = parse_type(str)) == NULL) - return NULL; - info->u.array_info.elt_size = - arg_sizeof(info->u.array_info.elt_type); - (*str)++; // Get past comma - eat_spaces(str); - info->u.array_info.len_spec = parse_argnum(str); - (*str)++; // Get past close paren - return info; + (*str)++; // Get past open paren + eat_spaces(str); + if ((info->u.array_info.elt_type = parse_type(str)) == NULL) + return NULL; + info->u.array_info.elt_size = + arg_sizeof(info->u.array_info.elt_type); + (*str)++; // Get past comma + eat_spaces(str); + info->u.array_info.len_spec = parse_argnum(str); + (*str)++; // Get past close paren + return info; /* Syntax: enum ( keyname=value,keyname=value,... ) */ case ARGTYPE_ENUM:{ - struct enum_opt { - char *key; - int value; - struct enum_opt *next; - }; - struct enum_opt *list = NULL; - struct enum_opt *p; - int entries = 0; - int ii; - - eat_spaces(str); - (*str)++; // Get past open paren - eat_spaces(str); - - while (**str && **str != ')') { - p = (struct enum_opt *) malloc(sizeof(*p)); + struct enum_opt { + char *key; + int value; + struct enum_opt *next; + }; + struct enum_opt *list = NULL; + struct enum_opt *p; + int entries = 0; + int ii; + eat_spaces(str); - p->key = parse_ident(str); - if (error_count) { - free(p); - return NULL; - } + (*str)++; // Get past open paren eat_spaces(str); - if (**str != '=') { - free(p->key); - free(p); - output_line(0, - "Syntax error in `%s', line %d: expected '=', got '%c'", - filename, line_no, **str); - error_count++; - return NULL; + + while (**str && **str != ')') { + p = (struct enum_opt *) malloc(sizeof(*p)); + eat_spaces(str); + p->key = parse_ident(str); + if (error_count) { + free(p); + return NULL; + } + eat_spaces(str); + if (**str != '=') { + free(p->key); + free(p); + output_line(0, + "Syntax error in `%s', line %d: expected '=', got '%c'", + filename, line_no, **str); + error_count++; + return NULL; + } + ++(*str); + eat_spaces(str); + p->value = parse_int(str); + p->next = list; + list = p; + ++entries; + + // Skip comma + eat_spaces(str); + if (**str == ',') { + (*str)++; + eat_spaces(str); + } } - ++(*str); - eat_spaces(str); - p->value = parse_int(str); - p->next = list; - list = p; - ++entries; - // Skip comma - eat_spaces(str); - if (**str == ',') { - (*str)++; - eat_spaces(str); + info->u.enum_info.entries = entries; + info->u.enum_info.keys = + (char **) malloc(entries * sizeof(char *)); + info->u.enum_info.values = + (int *) malloc(entries * sizeof(int)); + for (ii = 0, p = NULL; list; ++ii, list = list->next) { + if (p) + free(p); + info->u.enum_info.keys[ii] = list->key; + info->u.enum_info.values[ii] = list->value; + p = list; } - } - - info->u.enum_info.entries = entries; - info->u.enum_info.keys = - (char **) malloc(entries * sizeof(char *)); - info->u.enum_info.values = - (int *) malloc(entries * sizeof(int)); - for (ii = 0, p = NULL; list; ++ii, list = list->next) { if (p) - free(p); - info->u.enum_info.keys[ii] = list->key; - info->u.enum_info.values[ii] = list->value; - p = list; - } - if (p) - free(p); - - return info; + free(p); + + return info; } case ARGTYPE_STRING: - if (!isdigit(**str) && **str != '[') { - /* Oops, was just a simple string after all */ - free(info); - return simple; - } + if (!isdigit(**str) && **str != '[') { + /* Oops, was just a simple string after all */ + free(info); + return simple; + } - info->type = ARGTYPE_STRING_N; + info->type = ARGTYPE_STRING_N; - /* Backwards compatibility for string0, string1, ... */ - if (isdigit(**str)) { - info->u.string_n_info.size_spec = -parse_int(str); - return info; - } + /* Backwards compatibility for string0, string1, ... */ + if (isdigit(**str)) { + info->u.string_n_info.size_spec = -parse_int(str); + return info; + } - (*str)++; // Skip past opening [ - eat_spaces(str); - info->u.string_n_info.size_spec = parse_argnum(str); - eat_spaces(str); - (*str)++; // Skip past closing ] - return info; + (*str)++; // Skip past opening [ + eat_spaces(str); + info->u.string_n_info.size_spec = parse_argnum(str); + eat_spaces(str); + (*str)++; // Skip past closing ] + return info; // Syntax: struct ( type,type,type,... ) - case ARGTYPE_STRUCT:{ - int field_num = 0; - (*str)++; // Get past open paren - info->u.struct_info.fields = - malloc((MAX_ARGS + 1) * sizeof(void *)); - info->u.struct_info.offset = - malloc((MAX_ARGS + 1) * sizeof(size_t)); - info->u.struct_info.size = 0; - eat_spaces(str); // Empty arg list with whitespace inside - while (**str && **str != ')') { - if (field_num == MAX_ARGS) { - output_line(0, - "Error in `%s', line %d: Too many structure elements", - filename, line_no); - error_count++; - return NULL; - } - eat_spaces(str); - if (field_num != 0) { - (*str)++; // Get past comma - eat_spaces(str); + case ARGTYPE_STRUCT:{ + int field_num = 0; + (*str)++; // Get past open paren + info->u.struct_info.fields = + malloc((MAX_ARGS + 1) * sizeof(void *)); + info->u.struct_info.offset = + malloc((MAX_ARGS + 1) * sizeof(size_t)); + info->u.struct_info.size = 0; + eat_spaces(str); // Empty arg list with whitespace inside + while (**str && **str != ')') { + if (field_num == MAX_ARGS) { + output_line(0, + "Error in `%s', line %d: Too many structure elements", + filename, line_no); + error_count++; + return NULL; + } + eat_spaces(str); + if (field_num != 0) { + (*str)++; // Get past comma + eat_spaces(str); + } + if ((info->u.struct_info.fields[field_num++] = + parse_type(str)) == NULL) + return NULL; + + // Must trim trailing spaces so the check for + // the closing paren is simple + eat_spaces(str); } - if ((info->u.struct_info.fields[field_num++] = - parse_type(str)) == NULL) - return NULL; - - // Must trim trailing spaces so the check for - // the closing paren is simple - eat_spaces(str); - } - (*str)++; // Get past closing paren - info->u.struct_info.fields[field_num] = NULL; - align_struct(info); - return info; + (*str)++; // Get past closing paren + info->u.struct_info.fields[field_num] = NULL; + align_struct(info); + return info; } default: if (info->type == ARGTYPE_UNKNOWN) { output_line(0, "Syntax error in `%s', line %d: " - "Unknown type encountered", - filename, line_no); + "Unknown type encountered", + filename, line_no); free(info); error_count++; return NULL; @@ -593,13 +593,12 @@ static struct function *process_line(char *buf) debug(3, " Skipping line %d", line_no); return NULL; } - fun.return_info->arg_num = -1; debug(4, " return_type = %d", fun.return_info->type); eat_spaces(&str); tmp = start_of_arg_sig(str); if (!tmp) { output_line(0, "Syntax error in `%s', line %d", filename, - line_no); + line_no); error_count++; return NULL; } @@ -622,8 +621,8 @@ static struct function *process_line(char *buf) fun.arg_info[i] = parse_type(&str); if (fun.arg_info[i] == NULL) { output_line(0, "Syntax error in `%s', line %d" - ": unknown argument type", - filename, line_no); + ": unknown argument type", + filename, line_no); error_count++; return NULL; } @@ -631,7 +630,6 @@ static struct function *process_line(char *buf) fun.arg_info[i]->u.float_info.float_index = float_num++; else if (fun.arg_info[i]->type == ARGTYPE_DOUBLE) fun.arg_info[i]->u.double_info.float_index = float_num++; - fun.arg_info[i]->arg_num = i; eat_spaces(&str); if (*str == ',') { str++; @@ -642,7 +640,7 @@ static struct function *process_line(char *buf) if (str[strlen(str) - 1] == '\n') str[strlen(str) - 1] = '\0'; output_line(0, "Syntax error in `%s', line %d at ...\"%s\"", - filename, line_no, str); + filename, line_no, str); error_count++; return NULL; } diff --git a/sysdeps/linux-gnu/alpha/trace.c b/sysdeps/linux-gnu/alpha/trace.c index 459efa6..3099500 100644 --- a/sysdeps/linux-gnu/alpha/trace.c +++ b/sysdeps/linux-gnu/alpha/trace.c @@ -47,10 +47,8 @@ int syscall_p(struct process *proc, int status, int *sysnum) return 0; } -long gimme_arg(enum tof type, struct process *proc, arg_type_info *info) +long gimme_arg(enum tof type, struct process *proc, int arg_num, arg_type_info *info) { - int arg_num = info->arg_num; - if (arg_num == -1) { /* return value */ return ptrace(PTRACE_PEEKUSER, proc->pid, 0 /* REG_R0 */ , 0); } diff --git a/sysdeps/linux-gnu/arm/trace.c b/sysdeps/linux-gnu/arm/trace.c index efa625e..b5c2122 100644 --- a/sysdeps/linux-gnu/arm/trace.c +++ b/sysdeps/linux-gnu/arm/trace.c @@ -51,10 +51,8 @@ int syscall_p(struct process *proc, int status, int *sysnum) return 0; } -long gimme_arg(enum tof type, struct process *proc, arg_type_info *info) +long gimme_arg(enum tof type, struct process *proc, int arg_num, arg_type_info *info) { - int arg_num = info->arg_num; - if (arg_num == -1) { /* return value */ return ptrace(PTRACE_PEEKUSER, proc->pid, off_r0, 0); } diff --git a/sysdeps/linux-gnu/i386/trace.c b/sysdeps/linux-gnu/i386/trace.c index 6406272..6e64c46 100644 --- a/sysdeps/linux-gnu/i386/trace.c +++ b/sysdeps/linux-gnu/i386/trace.c @@ -43,10 +43,8 @@ int syscall_p(struct process *proc, int status, int *sysnum) return 0; } -long gimme_arg(enum tof type, struct process *proc, arg_type_info *info) +long gimme_arg(enum tof type, struct process *proc, int arg_num, arg_type_info *info) { - int arg_num = info->arg_num; - if (arg_num == -1) { /* return value */ return ptrace(PTRACE_PEEKUSER, proc->pid, 4 * EAX, 0); } diff --git a/sysdeps/linux-gnu/ia64/trace.c b/sysdeps/linux-gnu/ia64/trace.c index ce07d86..565cd6f 100644 --- a/sysdeps/linux-gnu/ia64/trace.c +++ b/sysdeps/linux-gnu/ia64/trace.c @@ -245,9 +245,8 @@ static double gimme_float_arg(enum tof type, struct process *proc, int arg_num) exit(1); } -long gimme_arg(enum tof type, struct process *proc, arg_type_info *info) +long gimme_arg(enum tof type, struct process *proc, int arg_num, arg_type_info *info) { - int arg_num = info->arg_num; union { long l; float f; diff --git a/sysdeps/linux-gnu/m68k/trace.c b/sysdeps/linux-gnu/m68k/trace.c index c05959c..14053db 100644 --- a/sysdeps/linux-gnu/m68k/trace.c +++ b/sysdeps/linux-gnu/m68k/trace.c @@ -48,10 +48,8 @@ int syscall_p(struct process *proc, int status, int *sysnum) return 0; } -long gimme_arg(enum tof type, struct process *proc, arg_type_info *info) +long gimme_arg(enum tof type, struct process *proc, int arg_num, arg_type_info *info) { - int arg_num = info->arg_num; - if (arg_num == -1) { /* return value */ return ptrace(PTRACE_PEEKUSER, proc->pid, 4 * PT_D0, 0); } diff --git a/sysdeps/linux-gnu/mipsel/trace.c b/sysdeps/linux-gnu/mipsel/trace.c index 3932f26..fa513e3 100644 --- a/sysdeps/linux-gnu/mipsel/trace.c +++ b/sysdeps/linux-gnu/mipsel/trace.c @@ -118,7 +118,7 @@ arguments somewhere on the call. I'm not doing any floating point support here. */ -long gimme_arg(enum tof type, struct process *proc, int arg_num) +long gimme_arg(enum tof type, struct process *proc, int arg_num, arg_type_info *info) { long ret; debug(2,"type %d arg %d",type,arg_num); diff --git a/sysdeps/linux-gnu/ppc/trace.c b/sysdeps/linux-gnu/ppc/trace.c index 888c38f..1bd3efd 100644 --- a/sysdeps/linux-gnu/ppc/trace.c +++ b/sysdeps/linux-gnu/ppc/trace.c @@ -56,10 +56,8 @@ int syscall_p(struct process *proc, int status, int *sysnum) return 0; } -long gimme_arg(enum tof type, struct process *proc, arg_type_info *info) +long gimme_arg(enum tof type, struct process *proc, int arg_num, arg_type_info *info) { - int arg_num = info->arg_num; - if (arg_num == -1) { /* return value */ return ptrace(PTRACE_PEEKUSER, proc->pid, sizeof(long) * PT_R3, 0); diff --git a/sysdeps/linux-gnu/s390/trace.c b/sysdeps/linux-gnu/s390/trace.c index 0e93f39..51c55de 100644 --- a/sysdeps/linux-gnu/s390/trace.c +++ b/sysdeps/linux-gnu/s390/trace.c @@ -161,9 +161,8 @@ int syscall_p(struct process *proc, int status, int *sysnum) return 0; } -long gimme_arg(enum tof type, struct process *proc, arg_type_info *info) +long gimme_arg(enum tof type, struct process *proc, int arg_num, arg_type_info *info) { - int arg_num = info->arg_num; long ret; switch (arg_num) { diff --git a/sysdeps/linux-gnu/sparc/trace.c b/sysdeps/linux-gnu/sparc/trace.c index 0533998..354f7e7 100644 --- a/sysdeps/linux-gnu/sparc/trace.c +++ b/sysdeps/linux-gnu/sparc/trace.c @@ -48,10 +48,8 @@ int syscall_p(struct process *proc, int status, int *sysnum) return 0; } -long gimme_arg(enum tof type, struct process *proc, arg_type_info *info) +long gimme_arg(enum tof type, struct process *proc, int arg_num, arg_type_info *info) { - int arg_num = info->arg_num; - proc_archdep *a = (proc_archdep *) proc->arch_ptr; if (!a->valid) { fprintf(stderr, "Could not get child registers\n"); diff --git a/sysdeps/linux-gnu/x86_64/trace.c b/sysdeps/linux-gnu/x86_64/trace.c index 56622c9..57d0e1f 100644 --- a/sysdeps/linux-gnu/x86_64/trace.c +++ b/sysdeps/linux-gnu/x86_64/trace.c @@ -86,10 +86,8 @@ gimme_arg32(enum tof type, struct process *proc, int arg_num) exit(1); } -long gimme_arg(enum tof type, struct process *proc, arg_type_info *info) +long gimme_arg(enum tof type, struct process *proc, int arg_num, arg_type_info *info) { - int arg_num = info->arg_num; - if (proc->mask_32bit) return (unsigned int)gimme_arg32(type, proc, arg_num); diff --git a/wait_for_something.c b/wait_for_something.c index f699663..c65de41 100644 --- a/wait_for_something.c +++ b/wait_for_something.c @@ -111,7 +111,7 @@ struct event *wait_for_something(void) if (stop_signal != (SIGTRAP | event.proc->tracesysgood) && stop_signal != SIGTRAP) { event.thing = LT_EV_SIGNAL; - event.e_un.signum = stop_signal; + event.e_un.signum = stop_signal; return &event; } |