This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] fix trap in parallel for m32r-sim

Kazuhiro Inaoka writes:
 > Hi Doug,
 > I want to fix the following problem.
 > test pattern is:
 > main()
 > {
 >   asm("trap #0 || ldi r0,#1"); /* the same as exit() ? */
 >   abort();
 > }

Ah hah!  So this is about TRAP_SYSCALL. :-)
TRAP_SYSCALL is a simulator-only facility to simplify printf,exit,etc.

I gather you want r0 to be 1 before the trap is taken,
violating standard parallel execution semantics: all inputs
read before any outputs written.
i.e. you want the trap to _read_ the value of r0 and get 1.
This is different than the violation I refered to previously
where the trap will _write_ the value of r0, say, before
other insns have read their inputs.

It seems like you're trying to fix a broken program by breaking
(or at least hacking) the simulator.  How about instead just having
a rule that says the TRAP_SYSCALL trap cannot be paired with instructions
that set up inputs for the syscall?  This would be no different
than trying to make

    asm ("add r1,r0 || ldi r0,#1"); // increment r1 by 1

work.  It doesn't work because the `add' will read the value of r0
before the ldi has set it to 1.
[apologies if I got the syntax wrong, haven't programmed m32r
assembler in a while :-)]

 > command line:
 > m32r-elf-gcc -m32rx test.c
 > In this case, it will pass through an asm function without exit.
 > At the time of m32r_trap() execution, r0 is not 1 yet.
 > It's not a problem of the current simulator implementation for trap
 > instruction.
 > I think it's a problem of timing to call back system call when trap is in
 > parallel.
 > Changed a patch and comment.
 > Regards,
 > Kazuhiro Inaoka
 > sim/m32r/ChangeLog
 > 2004-01-19  Kazuhiro Inaoka < inaoka dot kazuhiro at renesas dot com >
 >  * (xextract-pbb): Fixed trap for system calls operation
 >  in parallel.
 >  * (xextract-pbb): Ditto.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]