diff --git a/Makefile b/Makefile index cc84a03..bfd18fd 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ install: mspdebug mspdebug.man mspdebug: main.o fet.o rf2500.o dis.o uif.o olimex.o ihex.o elf32.o stab.o \ util.o bsl.o sim.o symmap.o gdb.o btree.o rtools.o sym.o devcmd.o \ - cproc.o vector.o output_util.o expr.o fet_error.o binfile.o \ + reader.o vector.o output_util.o expr.o fet_error.o binfile.o \ fet_db.o usbutil.o titext.o srec.o device.o coff.o opdb.o output.o \ cmddb.o stdcmd.o $(CC) $(LDFLAGS) $(MACPORTS_LDFLAGS) -o $@ $^ -lusb $(READLINE_LIBS) diff --git a/cmddb.c b/cmddb.c index fbd422a..9e4aabf 100644 --- a/cmddb.c +++ b/cmddb.c @@ -24,7 +24,6 @@ #include "devcmd.h" #include "gdb.h" #include "rtools.h" -#include "cproc.h" #include "sym.h" #include "stdcmd.h" diff --git a/cmddb.h b/cmddb.h index 3119e6d..83c133a 100644 --- a/cmddb.h +++ b/cmddb.h @@ -19,13 +19,11 @@ #ifndef CMDDB_H_ #define CMDDB_H_ -#include "cproc.h" - -typedef int (*cproc_command_func_t)(cproc_t cp, char **arg); +typedef int (*cmddb_func_t)(char **arg); struct cmddb_record { const char *name; - cproc_command_func_t func; + cmddb_func_t func; const char *help; }; diff --git a/devcmd.c b/devcmd.c index 1385304..2fe6cc5 100644 --- a/devcmd.c +++ b/devcmd.c @@ -26,12 +26,12 @@ #include "binfile.h" #include "stab.h" #include "expr.h" -#include "cproc.h" +#include "reader.h" #include "output_util.h" #include "util.h" #include "dis.h" -int cmd_regs(cproc_t cp, char **arg) +int cmd_regs(char **arg) { address_t regs[DEVICE_NUM_REGS]; uint8_t code[16]; @@ -51,7 +51,7 @@ int cmd_regs(cproc_t cp, char **arg) return 0; } -int cmd_md(cproc_t cp, char **arg) +int cmd_md(char **arg) { char *off_text = get_arg(arg); char *len_text = get_arg(arg); @@ -94,7 +94,7 @@ int cmd_md(cproc_t cp, char **arg) return 0; } -int cmd_mw(cproc_t cp, char **arg) +int cmd_mw(char **arg) { char *off_text = get_arg(arg); char *byte_text; @@ -130,12 +130,12 @@ int cmd_mw(cproc_t cp, char **arg) return 0; } -int cmd_reset(cproc_t cp, char **arg) +int cmd_reset(char **arg) { return device_default->ctl(device_default, DEVICE_CTL_RESET); } -int cmd_erase(cproc_t cp, char **arg) +int cmd_erase(char **arg) { if (device_default->ctl(device_default, DEVICE_CTL_HALT) < 0) return -1; @@ -144,7 +144,7 @@ int cmd_erase(cproc_t cp, char **arg) return device_default->ctl(device_default, DEVICE_CTL_ERASE); } -int cmd_step(cproc_t cp, char **arg) +int cmd_step(char **arg) { char *count_text = get_arg(arg); int count = 1; @@ -158,10 +158,10 @@ int cmd_step(cproc_t cp, char **arg) count--; } - return cmd_regs(cp, NULL); + return cmd_regs(NULL); } -int cmd_run(cproc_t cp, char **arg) +int cmd_run(char **arg) { device_status_t status; address_t regs[DEVICE_NUM_REGS]; @@ -207,10 +207,10 @@ int cmd_run(cproc_t cp, char **arg) if (device_default->ctl(device_default, DEVICE_CTL_HALT) < 0) return -1; - return cmd_regs(cp, NULL); + return cmd_regs(NULL); } -int cmd_set(cproc_t cp, char **arg) +int cmd_set(char **arg) { char *reg_text = get_arg(arg); char *val_text = get_arg(arg); @@ -244,7 +244,7 @@ int cmd_set(cproc_t cp, char **arg) return 0; } -int cmd_dis(cproc_t cp, char **arg) +int cmd_dis(char **arg) { char *off_text = get_arg(arg); char *len_text = get_arg(arg); @@ -393,7 +393,7 @@ static int hexout_feed(struct hexout_data *hexout, return 0; } -int cmd_hexout(cproc_t cp, char **arg) +int cmd_hexout(char **arg) { char *off_text = get_arg(arg); char *len_text = get_arg(arg); @@ -523,12 +523,12 @@ static int prog_feed(void *user_data, return 0; } -int cmd_prog(cproc_t cp, char **arg) +int cmd_prog(char **arg) { FILE *in; struct prog_data prog; - if (cproc_prompt_abort(cp, CPROC_MODIFY_SYMS)) + if (prompt_abort(MODIFY_SYMS)) return 0; in = fopen(*arg, "r"); @@ -564,11 +564,11 @@ int cmd_prog(cproc_t cp, char **arg) return -1; } - cproc_unmodify(cp, CPROC_MODIFY_SYMS); + unmark_modified(MODIFY_SYMS); return 0; } -int cmd_setbreak(cproc_t cp, char **arg) +int cmd_setbreak(char **arg) { char *addr_text = get_arg(arg); char *index_text = get_arg(arg); @@ -606,7 +606,7 @@ int cmd_setbreak(cproc_t cp, char **arg) return 0; } -int cmd_delbreak(cproc_t cp, char **arg) +int cmd_delbreak(char **arg) { char *index_text = get_arg(arg); int ret = 0; @@ -633,7 +633,7 @@ int cmd_delbreak(cproc_t cp, char **arg) return ret; } -int cmd_break(cproc_t cp, char **arg) +int cmd_break(char **arg) { int i; diff --git a/devcmd.h b/devcmd.h index 327d68c..365c972 100644 --- a/devcmd.h +++ b/devcmd.h @@ -19,21 +19,19 @@ #ifndef DEVCMD_H_ #define DEVCMD_H_ -#include "cproc.h" - -int cmd_regs(cproc_t cp, char **arg); -int cmd_md(cproc_t cp, char **arg); -int cmd_mw(cproc_t cp, char **arg); -int cmd_reset(cproc_t cp, char **arg); -int cmd_erase(cproc_t cp, char **arg); -int cmd_step(cproc_t cp, char **arg); -int cmd_run(cproc_t cp, char **arg); -int cmd_set(cproc_t cp, char **arg); -int cmd_dis(cproc_t cp, char **arg); -int cmd_hexout(cproc_t cp, char **arg); -int cmd_prog(cproc_t cp, char **arg); -int cmd_setbreak(cproc_t cp, char **arg); -int cmd_delbreak(cproc_t cp, char **arg); -int cmd_break(cproc_t cp, char **arg); +int cmd_regs(char **arg); +int cmd_md(char **arg); +int cmd_mw(char **arg); +int cmd_reset(char **arg); +int cmd_erase(char **arg); +int cmd_step(char **arg); +int cmd_run(char **arg); +int cmd_set(char **arg); +int cmd_dis(char **arg); +int cmd_hexout(char **arg); +int cmd_prog(char **arg); +int cmd_setbreak(char **arg); +int cmd_delbreak(char **arg); +int cmd_break(char **arg); #endif diff --git a/gdb.c b/gdb.c index 90e61ec..e7fe7f4 100644 --- a/gdb.c +++ b/gdb.c @@ -662,7 +662,7 @@ static int gdb_server(int port) return data.error ? -1 : 0; } -int cmd_gdb(cproc_t cp, char **arg) +int cmd_gdb(char **arg) { char *port_text = get_arg(arg); int port = 2000; diff --git a/gdb.h b/gdb.h index 017f3a0..6e4a789 100644 --- a/gdb.h +++ b/gdb.h @@ -19,8 +19,6 @@ #ifndef GDB_H_ #define GDB_H_ -#include "cproc.h" - -int cmd_gdb(cproc_t cp, char **arg); +int cmd_gdb(char **arg); #endif diff --git a/main.c b/main.c index fb93c63..7dc91c6 100644 --- a/main.c +++ b/main.c @@ -36,6 +36,7 @@ #include "devcmd.h" #include "expr.h" #include "opdb.h" +#include "reader.h" #include "sim.h" #include "bsl.h" @@ -282,7 +283,7 @@ static void usage(const char *progname) } } -static void process_rc_file(cproc_t cp) +static void process_rc_file(void) { const char *home = getenv("HOME"); char text[256]; @@ -292,7 +293,7 @@ static void process_rc_file(cproc_t cp) snprintf(text, sizeof(text), "%s/.mspdebug", home); if (!access(text, F_OK)) - cproc_process_file(cp, text); + process_file(text); } static int add_fet_device(void *user_data, const struct fet_db_record *r) @@ -405,10 +406,9 @@ static int parse_cmdline_args(int argc, char **argv, return 0; } -cproc_t setup_cproc(struct cmdline_args *args) +int setup_driver(struct cmdline_args *args) { int i; - cproc_t cp; i = 0; while (i < ARRAY_LEN(driver_table) && @@ -417,33 +417,25 @@ cproc_t setup_cproc(struct cmdline_args *args) if (i >= ARRAY_LEN(driver_table)) { fprintf(stderr, "Unknown driver: %s. Try --help for a list.\n", args->driver_name); - return NULL; + return -1; } stab_default = stab_new(); if (!stab_default) - return NULL; + return -1; device_default = driver_table[i].func(args); if (!device_default) { stab_destroy(stab_default); - return NULL; + return -1; } - cp = cproc_new(); - if (!cp) { - device_default->destroy(device_default); - stab_destroy(stab_default); - return NULL; - } - - return cp; + return 0; } int main(int argc, char **argv) { struct cmdline_args args = {0}; - cproc_t cp; int ret = 0; puts( @@ -460,26 +452,24 @@ int main(int argc, char **argv) ctrlc_init(); opdb_reset(); - cp = setup_cproc(&args); - if (!cp) + if (setup_driver(&args) < 0) return -1; if (!args.no_rc) - process_rc_file(cp); + process_rc_file(); /* Process commands */ if (optind < argc) { while (optind < argc) { - if (cproc_process_command(cp, argv[optind++]) < 0) { + if (process_command(argv[optind++]) < 0) { ret = -1; break; } } } else { - cproc_reader_loop(cp); + reader_loop(); } - cproc_destroy(cp); stab_destroy(stab_default); device_default->destroy(device_default); diff --git a/cproc.c b/reader.c similarity index 72% rename from cproc.c rename to reader.c index c65e646..cab2187 100644 --- a/cproc.c +++ b/reader.c @@ -28,52 +28,31 @@ #include #endif -#include "opdb.h" -#include "expr.h" -#include "cproc.h" #include "vector.h" -#include "stab.h" #include "util.h" #include "output.h" #include "cmddb.h" #include "stdcmd.h" +#include "reader.h" -struct cproc { - int modify_flags; - int in_reader_loop; -}; +static int modify_flags; +static int in_reader_loop; -cproc_t cproc_new(void) +void mark_modified(int flags) { - cproc_t cp = malloc(sizeof(*cp)); - - if (!cp) - return NULL; - - memset(cp, 0, sizeof(*cp)); - return cp; + modify_flags |= flags; } -void cproc_destroy(cproc_t cp) +void unmark_modified(int flags) { - free(cp); + modify_flags &= ~flags; } -void cproc_modify(cproc_t cp, int flags) -{ - cp->modify_flags |= flags; -} - -void cproc_unmodify(cproc_t cp, int flags) -{ - cp->modify_flags &= ~flags; -} - -int cproc_prompt_abort(cproc_t cp, int flags) +int prompt_abort(int flags) { char buf[32]; - if (!(cp->in_reader_loop && (cp->modify_flags & flags))) + if (!(in_reader_loop && (modify_flags & flags))) return 0; for (;;) { @@ -129,7 +108,7 @@ static char *readline(const char *prompt) #define add_history(x) #endif -static int process_command(cproc_t cp, char *arg, int interactive) +static int do_command(char *arg, int interactive) { const char *cmd_text; int len = strlen(arg); @@ -143,12 +122,12 @@ static int process_command(cproc_t cp, char *arg, int interactive) struct cmddb_record cmd; if (!cmddb_get(cmd_text, &cmd)) { - int old = cp->in_reader_loop; + int old = in_reader_loop; int ret; - cp->in_reader_loop = interactive; - ret = cmd.func(cp, &arg); - cp->in_reader_loop = old; + in_reader_loop = interactive; + ret = cmd.func(&arg); + in_reader_loop = old; return ret; } @@ -161,14 +140,14 @@ static int process_command(cproc_t cp, char *arg, int interactive) return 0; } -void cproc_reader_loop(cproc_t cp) +void reader_loop(void) { - int old = cp->in_reader_loop; + int old = in_reader_loop; - cp->in_reader_loop = 1; + in_reader_loop = 1; printf("\n"); - cmd_help(cp, NULL); + cmd_help(NULL); printf("\n"); do { @@ -179,21 +158,21 @@ void cproc_reader_loop(cproc_t cp) break; add_history(buf); - process_command(cp, buf, 1); + do_command(buf, 1); free(buf); } - } while (cproc_prompt_abort(cp, CPROC_MODIFY_SYMS)); + } while (prompt_abort(MODIFY_SYMS)); printf("\n"); - cp->in_reader_loop = old; + in_reader_loop = old; } -int cproc_process_command(cproc_t cp, char *cmd) +int process_command(char *cmd) { - return process_command(cp, cmd, 0); + return do_command(cmd, 0); } -int cproc_process_file(cproc_t cp, const char *filename) +int process_file(const char *filename) { FILE *in; char buf[1024]; @@ -217,7 +196,7 @@ int cproc_process_file(cproc_t cp, const char *filename) if (*cmd == '#') continue; - if (process_command(cp, cmd, 0) < 0) { + if (do_command(cmd, 0) < 0) { fprintf(stderr, "read: error processing %s (line %d)\n", filename, line_no); fclose(in); diff --git a/cproc.h b/reader.h similarity index 65% rename from cproc.h rename to reader.h index 88219b3..cc898d3 100644 --- a/cproc.h +++ b/reader.h @@ -16,16 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef CPROC_H_ -#define CPROC_H_ - -/* Command processor. - * - * This contains a list of all defined commands and options, plus modification - * flags. - */ -struct cproc; -typedef struct cproc *cproc_t; +#ifndef READER_H_ +#define READER_H_ /* Commmand processor modification flags. * @@ -38,17 +30,10 @@ typedef struct cproc *cproc_t; * processor. */ -#define CPROC_MODIFY_SYMS 0x01 +#define MODIFY_SYMS 0x01 -/* Create/destroy a command processor. The init function returns 0 if - * successful, or -1 if an error occurs. - * - * The command processor takes responsibility for the device object it - * has been given. When you destroy a command processor, the device is - * also destroyed. - */ -cproc_t cproc_new(void); -void cproc_destroy(cproc_t cp); +void mark_modified(int flags); +void unmark_modified(int flags); /* This should be called before a destructive operation to give the user * a chance to abort. If it returns 1, then the operation should be aborted. @@ -56,17 +41,15 @@ void cproc_destroy(cproc_t cp); * The flags argument should be a bitwise combination representing the bits * modify_flags that will be affected by the operation. */ -void cproc_modify(cproc_t cp, int flags); -void cproc_unmodify(cproc_t cp, int flags); -int cproc_prompt_abort(cproc_t cp, int flags); +int prompt_abort(int flags); /* Run the reader loop */ -void cproc_reader_loop(cproc_t cp); +void reader_loop(void); /* Commands can be fed directly to the processor either one at a time, * or by specifying a file to read from. */ -int cproc_process_command(cproc_t cp, char *cmd); -int cproc_process_file(cproc_t cp, const char *filename); +int process_command(char *cmd); +int process_file(const char *filename); #endif diff --git a/rtools.c b/rtools.c index 5d5f793..e775d0a 100644 --- a/rtools.c +++ b/rtools.c @@ -50,7 +50,7 @@ struct isearch_query { struct msp430_instruction insn; }; -static int isearch_opcode(cproc_t cp, const char *term, char **arg, +static int isearch_opcode(const char *term, char **arg, struct isearch_query *q) { const char *opname = get_arg(arg); @@ -77,7 +77,7 @@ static int isearch_opcode(cproc_t cp, const char *term, char **arg, return 0; } -static int isearch_bw(cproc_t cp, const char *term, char **arg, +static int isearch_bw(const char *term, char **arg, struct isearch_query *q) { if (q->flags & ISEARCH_DSIZE) { @@ -103,7 +103,7 @@ static int isearch_bw(cproc_t cp, const char *term, char **arg, return 0; } -static int isearch_type(cproc_t cp, const char *term, char **arg, +static int isearch_type(const char *term, char **arg, struct isearch_query *q) { if (q->flags & ISEARCH_TYPE) { @@ -135,7 +135,7 @@ static int isearch_type(cproc_t cp, const char *term, char **arg, return 0; } -static int isearch_addr(cproc_t cp, const char *term, char **arg, +static int isearch_addr(const char *term, char **arg, struct isearch_query *q) { int which = toupper(*term) == 'S' ? @@ -166,7 +166,7 @@ static int isearch_addr(cproc_t cp, const char *term, char **arg, return 0; } -static int isearch_reg(cproc_t cp, const char *term, char **arg, +static int isearch_reg(const char *term, char **arg, struct isearch_query *q) { int which = toupper(*term) == 'S' ? @@ -201,7 +201,7 @@ static int isearch_reg(cproc_t cp, const char *term, char **arg, return 0; } -static int isearch_mode(cproc_t cp, const char *term, char **arg, +static int isearch_mode(const char *term, char **arg, struct isearch_query *q) { int which = toupper(*term) == 'S' ? @@ -340,7 +340,7 @@ static int isearch_match(const struct msp430_instruction *insn, return 1; } -static int do_isearch(cproc_t cp, address_t addr, address_t len, +static int do_isearch(address_t addr, address_t len, const struct isearch_query *q) { uint8_t *mbuf; @@ -373,12 +373,11 @@ static int do_isearch(cproc_t cp, address_t addr, address_t len, return 0; } -int cmd_isearch(cproc_t cp, char **arg) +int cmd_isearch(char **arg) { const static struct { const char *name; - int (*func)(cproc_t cp, - const char *term, char **arg, + int (*func)(const char *term, char **arg, struct isearch_query *q); } term_handlers[] = { {"opcode", isearch_opcode}, @@ -424,8 +423,7 @@ int cmd_isearch(cproc_t cp, char **arg) for (i = 0; i < ARRAY_LEN(term_handlers); i++) if (!strcasecmp(term_handlers[i].name, term)) { - if (term_handlers[i].func(cp, term, arg, - &q) < 0) + if (term_handlers[i].func(term, arg, &q) < 0) return -1; break; } @@ -437,7 +435,7 @@ int cmd_isearch(cproc_t cp, char **arg) return -1; } - return do_isearch(cp, addr, len, &q); + return do_isearch(addr, len, &q); } /************************************************************************ @@ -776,7 +774,7 @@ static int cgraph_init(address_t offset, address_t len, uint8_t *memory, return -1; } -static void cgraph_summary(struct call_graph *graph, cproc_t cp) +static void cgraph_summary(struct call_graph *graph) { int i; int j = 0; /* Edge from index */ @@ -819,8 +817,7 @@ static void cgraph_summary(struct call_graph *graph, cproc_t cp) } } -static void cgraph_func_info(struct call_graph *graph, cproc_t cp, - int addr) +static void cgraph_func_info(struct call_graph *graph, address_t addr) { int i = 0; int j = 0; @@ -900,7 +897,7 @@ static void cgraph_func_info(struct call_graph *graph, cproc_t cp, } } -int cmd_cgraph(cproc_t cp, char **arg) +int cmd_cgraph(char **arg) { char *offset_text, *len_text, *addr_text;; address_t offset, len, addr; @@ -958,9 +955,9 @@ int cmd_cgraph(cproc_t cp, char **arg) free(memory); if (addr_text) - cgraph_func_info(&graph, cp, addr); + cgraph_func_info(&graph, addr); else - cgraph_summary(&graph, cp); + cgraph_summary(&graph); cgraph_destroy(&graph); return 0; diff --git a/rtools.h b/rtools.h index 84d4685..e88b5fc 100644 --- a/rtools.h +++ b/rtools.h @@ -19,9 +19,7 @@ #ifndef RTOOLS_H_ #define RTOOLS_H_ -#include "cproc.h" - -int cmd_isearch(cproc_t cp, char **arg); -int cmd_cgraph(cproc_t cp, char **arg); +int cmd_isearch(char **arg); +int cmd_cgraph(char **arg); #endif diff --git a/stdcmd.c b/stdcmd.c index d41c75b..ffe721e 100644 --- a/stdcmd.c +++ b/stdcmd.c @@ -23,9 +23,9 @@ #include "cmddb.h" #include "opdb.h" #include "vector.h" -#include "cproc.h" #include "stdcmd.h" #include "output.h" +#include "reader.h" #include "expr.h" static int namelist_cmp(const void *a, const void *b) @@ -101,7 +101,7 @@ static int push_command_name(void *user_data, const struct cmddb_record *rec) return vector_push((struct vector *)user_data, &rec->name, 1); } -int cmd_help(cproc_t cp, char **arg) +int cmd_help(char **arg) { const char *topic = get_arg(arg); @@ -200,7 +200,7 @@ static int display_option(void *user_data, const struct opdb_key *key, return 0; } -int cmd_opt(cproc_t cp, char **arg) +int cmd_opt(char **arg) { const char *opt_text = get_arg(arg); struct opdb_key key; @@ -231,7 +231,7 @@ int cmd_opt(cproc_t cp, char **arg) return 0; } -int cmd_read(cproc_t cp, char **arg) +int cmd_read(char **arg) { char *filename = get_arg(arg); @@ -240,5 +240,5 @@ int cmd_read(cproc_t cp, char **arg) return -1; } - return cproc_process_file(cp, filename); + return process_file(filename); } diff --git a/stdcmd.h b/stdcmd.h index dad0706..c267045 100644 --- a/stdcmd.h +++ b/stdcmd.h @@ -20,8 +20,8 @@ #define STDCMD_H_ /* Built-in commands */ -int cmd_help(cproc_t cp, char **arg); -int cmd_read(cproc_t cp, char **arg); -int cmd_opt(cproc_t cp, char **arg); +int cmd_help(char **arg); +int cmd_read(char **arg); +int cmd_opt(char **arg); #endif diff --git a/sym.c b/sym.c index 55185a5..61febae 100644 --- a/sym.c +++ b/sym.c @@ -29,8 +29,9 @@ #include "util.h" #include "vector.h" #include "sym.h" +#include "reader.h" -int cmd_eval(cproc_t cp, char **arg) +int cmd_eval(char **arg) { address_t addr; address_t offset; @@ -52,11 +53,11 @@ int cmd_eval(cproc_t cp, char **arg) return 0; } -static int cmd_sym_load_add(cproc_t cp, int clear, char **arg) +static int cmd_sym_load_add(int clear, char **arg) { FILE *in; - if (clear && cproc_prompt_abort(cp, CPROC_MODIFY_SYMS)) + if (clear && prompt_abort(MODIFY_SYMS)) return 0; in = fopen(*arg, "r"); @@ -67,9 +68,9 @@ static int cmd_sym_load_add(cproc_t cp, int clear, char **arg) if (clear) { stab_clear(stab_default); - cproc_unmodify(cp, CPROC_MODIFY_SYMS); + unmark_modified(MODIFY_SYMS); } else { - cproc_modify(cp, CPROC_MODIFY_SYMS); + mark_modified(MODIFY_SYMS); } if (binfile_syms(in, stab_default) < 0) { @@ -93,7 +94,7 @@ static int savemap_cb(void *user_data, const char *name, address_t value) return 0; } -static int cmd_sym_savemap(cproc_t cp, char **arg) +static int cmd_sym_savemap(char **arg) { FILE *savemap_out; char *fname = get_arg(arg); @@ -120,7 +121,7 @@ static int cmd_sym_savemap(cproc_t cp, char **arg) return -1; } - cproc_unmodify(cp, CPROC_MODIFY_SYMS); + unmark_modified(MODIFY_SYMS); return 0; } @@ -140,7 +141,7 @@ static int find_sym(void *user_data, const char *name, address_t value) return 0; } -static int cmd_sym_find(cproc_t cp, char **arg) +static int cmd_sym_find(char **arg) { regex_t find_preg; char *expr = get_arg(arg); @@ -232,7 +233,7 @@ static int find_renames(void *user_data, const char *name, address_t value) return 0; } -static int cmd_sym_rename(cproc_t cp, char **arg) +static int cmd_sym_rename(char **arg) { const char *expr = get_arg(arg); const char *replace = get_arg(arg); @@ -263,12 +264,12 @@ static int cmd_sym_rename(cproc_t cp, char **arg) vector_destroy(&rename.list); if (ret > 0) - cproc_modify(cp, CPROC_MODIFY_SYMS); + mark_modified(MODIFY_SYMS); return ret >= 0 ? 0 : -1; } -static int cmd_sym_del(cproc_t cp, char **arg) +static int cmd_sym_del(char **arg) { char *name = get_arg(arg); @@ -284,11 +285,11 @@ static int cmd_sym_del(cproc_t cp, char **arg) return -1; } - cproc_modify(cp, CPROC_MODIFY_SYMS); + mark_modified(MODIFY_SYMS); return 0; } -int cmd_sym(cproc_t cp, char **arg) +int cmd_sym(char **arg) { char *subcmd = get_arg(arg); @@ -299,10 +300,10 @@ int cmd_sym(cproc_t cp, char **arg) } if (!strcasecmp(subcmd, "clear")) { - if (cproc_prompt_abort(cp, CPROC_MODIFY_SYMS)) + if (prompt_abort(MODIFY_SYMS)) return 0; stab_clear(stab_default); - cproc_unmodify(cp, CPROC_MODIFY_SYMS); + unmark_modified(MODIFY_SYMS); return 0; } @@ -326,22 +327,22 @@ int cmd_sym(cproc_t cp, char **arg) if (stab_set(stab_default, name, value) < 0) return -1; - cproc_modify(cp, CPROC_MODIFY_SYMS); + mark_modified(MODIFY_SYMS); return 0; } if (!strcasecmp(subcmd, "del")) - return cmd_sym_del(cp, arg); + return cmd_sym_del(arg); if (!strcasecmp(subcmd, "import")) - return cmd_sym_load_add(cp, 1, arg); + return cmd_sym_load_add(1, arg); if (!strcasecmp(subcmd, "import+")) - return cmd_sym_load_add(cp, 0, arg); + return cmd_sym_load_add(0, arg); if (!strcasecmp(subcmd, "export")) - return cmd_sym_savemap(cp, arg); + return cmd_sym_savemap(arg); if (!strcasecmp(subcmd, "rename")) - return cmd_sym_rename(cp, arg); + return cmd_sym_rename(arg); if (!strcasecmp(subcmd, "find")) - return cmd_sym_find(cp, arg); + return cmd_sym_find(arg); fprintf(stderr, "sym: unknown subcommand: %s\n", subcmd); return -1; diff --git a/sym.h b/sym.h index aa59848..918c090 100644 --- a/sym.h +++ b/sym.h @@ -19,9 +19,7 @@ #ifndef SYM_H_ #define SYM_H_ -#include "cproc.h" - -int cmd_eval(cproc_t cp, char **arg); -int cmd_sym(cproc_t cp, char **arg); +int cmd_eval(char **arg); +int cmd_sym(char **arg); #endif