From 7b73c388ad92936d86b83867373024ee602388c6 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Wed, 11 Aug 2010 00:24:57 -0700 Subject: Fix segfault in test programs Emulation requires that the program be compiled. --- orc-test/orctest.c | 8 ++++++-- orc/orcexecutor.c | 14 ++++++++++++++ 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;ivars[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 @@ -49,6 +49,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) { 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); -- cgit v1.2.3