diff options
author | Maria Jan Matejka <mq@jmq.cz> | 2017-10-19 12:39:44 +0200 |
---|---|---|
committer | Jan Maria Matejka <mq@ucw.cz> | 2018-03-13 16:29:33 +0100 |
commit | 5a14df395053f4094a1e3ebea98e3487cbfc0e63 (patch) | |
tree | 08c1fb75e34628239034a3f2a59fc1bc3006c765 /filter/f-util.c | |
parent | 2d6d4b80539be13aa53c6751fb33689b263e4010 (diff) |
Filter: Instruction codes named as enum
The two-letter instructions were quite messy but they could be easily
read from memory dumps. Now GDB (since 2012) supports pretty printing
enum values and GCC checks the switch construction for missing enum
values so we are converting the nice two-byte values to enums.
Anyway, the enum still keeps the old two-byte values to be able to read
the instruction codes even without GDB from plain memory dump.
Diffstat (limited to 'filter/f-util.c')
-rw-r--r-- | filter/f-util.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/filter/f-util.c b/filter/f-util.c index def2b248..42b08868 100644 --- a/filter/f-util.c +++ b/filter/f-util.c @@ -2,6 +2,7 @@ * Filters: utility functions * * Copyright 1998 Pavel Machek <pavel@ucw.cz> + * 2017 Jan Maria Matejka <mq@ucw.cz> * * Can be freely distributed and used under the terms of the GNU GPL. */ @@ -13,43 +14,48 @@ #define P(a,b) ((a<<8) | b) struct f_inst * -f_new_inst(void) +f_new_inst(enum f_instruction_code fi_code) { struct f_inst * ret; - ret = cfg_alloc(sizeof(struct f_inst)); - ret->code = ret->aux = 0; - ret->arg1 = ret->arg2 = ret->next = NULL; + ret = cfg_allocz(sizeof(struct f_inst)); + ret->fi_code = fi_code; ret->lineno = ifs->lino; return ret; } struct f_inst * -f_new_dynamic_attr(int type, int f_type UNUSED, int code) +f_new_inst_da(enum f_instruction_code fi_code, struct f_dynamic_attr da) { - /* FIXME: Remove the f_type parameter? */ - struct f_inst *f = f_new_inst(); - f->aux = type; - f->a2.i = code; - return f; + struct f_inst *ret = f_new_inst(fi_code); + ret->aux = da.type; + ret->a2.i = da.ea_code; + return ret; +} + +struct f_inst * +f_new_inst_sa(enum f_instruction_code fi_code, struct f_static_attr sa) +{ + struct f_inst *ret = f_new_inst(fi_code); + ret->aux = sa.f_type; + ret->a2.i = sa.sa_code; + ret->a1.i = sa.readonly; + return ret; } /* * Generate set_dynamic( operation( get_dynamic(), argument ) ) */ struct f_inst * -f_generate_complex(int operation, int operation_aux, struct f_inst *dyn, struct f_inst *argument) +f_generate_complex(int operation, int operation_aux, struct f_dynamic_attr da, struct f_inst *argument) { - struct f_inst *set_dyn = f_new_inst(), - *oper = f_new_inst(), - *get_dyn = dyn; + struct f_inst *set_dyn = f_new_inst_da(FI_EA_SET, da), + *oper = f_new_inst(operation), + *get_dyn = f_new_inst_da(FI_EA_GET, da); - *set_dyn = *get_dyn; - get_dyn->code = P('e','a'); - oper->code = operation; oper->aux = operation_aux; oper->a1.p = get_dyn; oper->a2.p = argument; - set_dyn->code = P('e','S'); + set_dyn->a1.p = oper; return set_dyn; } @@ -59,7 +65,7 @@ struct f_inst * f_generate_roa_check(struct symbol *sym, struct f_inst *prefix, struct f_inst *asn) { struct f_inst_roa_check *ret = cfg_allocz(sizeof(struct f_inst_roa_check)); - ret->i.code = P('R','C'); + ret->i.fi_code = FI_ROA_CHECK; ret->i.lineno = ifs->lino; ret->i.arg1 = prefix; ret->i.arg2 = asn; |