diff options
author | David Schleef <ds@schleef.org> | 2010-08-11 00:24:57 -0700 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2010-08-11 00:24:57 -0700 |
commit | 7b73c388ad92936d86b83867373024ee602388c6 (patch) | |
tree | 4c38a6401f5439ef0ab9e329a90bbb746cd7e6a9 | |
parent | 57b08c9095797c2521a66ced0ca985aa8ae2ba00 (diff) |
Fix segfault in test programs
Emulation requires that the program be compiled.
-rw-r--r-- | orc-test/orctest.c | 8 | ||||
-rw-r--r-- | orc/orcexecutor.c | 14 | ||||
-rw-r--r-- | orc/orcprogram.h | 1 |
3 files changed, 21 insertions, 2 deletions
diff --git a/orc-test/orctest.c b/orc-test/orctest.c index 07bb334..8aedc47 100644 --- a/orc-test/orctest.c +++ b/orc-test/orctest.c @@ -511,7 +511,7 @@ orc_test_compare_output_full (OrcProgram *program, int flags) ORC_DEBUG ("got here"); - if (!(flags & ORC_TEST_FLAGS_BACKUP)) { + { OrcTarget *target; unsigned int flags; @@ -575,7 +575,11 @@ orc_test_compare_output_full (OrcProgram *program, int flags) } } ORC_DEBUG ("running"); - orc_executor_run (ex); + if (flags & ORC_TEST_FLAGS_BACKUP) { + orc_executor_run_backup (ex); + } else { + orc_executor_run (ex); + } ORC_DEBUG ("done running"); for(i=0;i<ORC_N_VARIABLES;i++){ if (program->vars[i].vartype == ORC_VAR_TYPE_ACCUMULATOR) { diff --git a/orc/orcexecutor.c b/orc/orcexecutor.c index debe81b..19ba4ba 100644 --- a/orc/orcexecutor.c +++ b/orc/orcexecutor.c @@ -50,6 +50,20 @@ orc_executor_run (OrcExecutor *ex) } void +orc_executor_run_backup (OrcExecutor *ex) +{ + void (*func) (OrcExecutor *); + + func = ex->program->backup_func; + if (func) { + func (ex); + //ORC_ERROR("counters %d %d %d", ex->counter1, ex->counter2, ex->counter3); + } else { + orc_executor_emulate (ex); + } +} + +void orc_executor_set_program (OrcExecutor *ex, OrcProgram *program) { ex->program = program; diff --git a/orc/orcprogram.h b/orc/orcprogram.h index 44b8c78..90526ec 100644 --- a/orc/orcprogram.h +++ b/orc/orcprogram.h @@ -627,6 +627,7 @@ void orc_executor_set_n (OrcExecutor *ex, int n); void orc_executor_set_m (OrcExecutor *ex, int m); void orc_executor_emulate (OrcExecutor *ex); void orc_executor_run (OrcExecutor *ex); +void orc_executor_run_backup (OrcExecutor *ex); OrcOpcodeSet *orc_opcode_set_get (const char *name); OrcOpcodeSet *orc_opcode_set_get_nth (int opcode_major); |