-1

I'm trying to port a hacked program to GDB-7.6.1. The previous is fine under GDB-3.2.2. However, I meet some compile errors although I didn't touch anything related with these macro defined variables. Most important, the related sentences in the Makefile are the same. But the objdump shows they are different in the macro variables.

After configure, the compiler will complain

libsim.a(engine.o): In function `delayslot32':
/home/ruizhewu/work/gdb/gdb761-5-M3/gdb-7.6.1/lx-bcm-sc/sim/mips/../../../sim/mips/mips.igen:77: undefined reference to `SC_PRE_PROC_DELAY_SLOT'
/home/ruizhewu/work/gdb/gdb761-5-M3/gdb-7.6.1/lx-bcm-sc/sim/mips/../../../sim/mips/mips.igen:85: undefined reference to `SC_POST_PROC_DELAY_SLOT'


bash-3.2$ objdump -t libsim.a |less

........

support.o:     file format elf64-x86-64

SYMBOL TABLE:

000000000000021d g     F .text  00000000000000bd delayslot32
0000000000000000         *UND*  0000000000000000 SC_PRE_PROC_DELAY_SLOT


engine.o:     file format elf64-x86-64

SYMBOL TABLE:
000000000000d72f l     F .text  00000000000000bd delayslot32

...

...

...


0000000000000000         *UND*  0000000000000000 SC_PRE_PROC_DELAY_SLOT

The previous program, the engine.o ONLY has delayslot32, but NO SC_PRE_PROC_DELAY_SLOT

The mips.igen code is:

:function:::address_word:delayslot32:address_word target
{
  instruction_word delay_insn;
  SC_PRE_PROC_DELAY_SLOT(SD, CIA);
  sim_events_slip (SD, 1);
  DSPC = CIA;
  CIA = CIA + 4; /* NOTE not mips16 */
  STATE |= simDELAYSLOT;
  delay_insn = IMEM32 (CIA); /* NOTE not mips16 */
  idecode_issue (CPU_, delay_insn, (CIA));
  STATE &= ~simDELAYSLOT;
  SC_POST_PROC_DELAY_SLOT(SD);
  return target;
}

The makefile is actually the same with the program under gdb3.2.2:

sim/mips/Makefile:

semantics.o: sim-main.h scSupport.h adslExtension.h semantics.c $(SIM_EXTRA_DEPS)
engine.o: sim-main.h scSupport.h adslExtension.h engine.c $(SIM_EXTRA_DEPS)
support.o: sim-main.h support.c $(SIM_EXTRA_DEPS)
idecode.o: sim-main.h scSupport.h adslExtension.h idecode.c $(SIM_EXTRA_DEPS)
itable.o: sim-main.h itable.c $(SIM_EXTRA_DEPS)
scSupport.o: scSupport.h adslExtension.h scSupport.c $(SIM_EXTRA_DEPS)

The undefined variable, which the compiler complain is actually defined in scSupport.h

#define SC_PRE_PROC_DELAY_SLOT(sd, cia)         scEventEndOfInstExe(sd, cia)
#define SC_POST_PROC_DELAY_SLOT(sd)
  • Also, you cannot be "porting" a program to GDB. Maybe GCC. But GDB is a debugger, not a compiler. – Zan Lynx Feb 11 '14 at 00:50
  • GDB can also be used as CPU simulator – user1694917 Feb 11 '14 at 01:05
  • None of the answer is work. 1. Remove all the macro still has the same errors. 2. The old version still can work with an UND SC_POST_PROC_DELAY_SLOT. 3. Most important, the SC_POST_PROC_DELAY_SLOT is defined either #ifdef and #else. So it is impossible caused by undefined macro. – user1694917 Feb 11 '14 at 01:20

1 Answers1

2

It seems obvious to me that the header file scSupport.h did not get included into one of the files that was using the macro. Either that or the macro is conditionally defined, and was not actually set.

Find out why that happened.

Zan Lynx
  • 53,022
  • 10
  • 79
  • 131
  • Yes, it has #ifndef SC_SUPPORT_H #define SC_SUPPORT_H #include "sim-basics.h" /* --------------- Conditional macros */ #ifdef USE_SC but gcc ....-DUSE_SC ... -g -O0 -c -o support.o -MT support.o -MMD -MP -MF .deps/support.Tpo support.c – user1694917 Feb 11 '14 at 00:45
  • Even delete all the #define, it is still the same – user1694917 Feb 11 '14 at 01:01