[Vm-dev] [commit][3291]
Fix ARM sim bug that let preload aborts go a bit weird because of failing to
escape the swi handler fast enough
commits at squeakvm.org
commits at squeakvm.org
Thu Mar 26 03:56:59 UTC 2015
Revision: 3291
Author: rowledge
Date: 2015-03-25 20:56:57 -0700 (Wed, 25 Mar 2015)
Log Message:
-----------
Fix ARM sim bug that let preload aborts go a bit weird because of failing to escape the swi handler fast enough
Modified Paths:
--------------
branches/Cog/processors/ARM/gdb-7.6/sim/arm/armemu.c
branches/Cog/processors/ARM/gdb-7.6/sim/arm/armos.c
branches/Cog/processors/ARM/gdb-7.6/sim/arm/armulmem.c
branches/Cog/processors/ARM/gdb-7.6/sim/arm/config.log
branches/Cog/processors/ARM/gdb-7.6/sim/common/config.log
Modified: branches/Cog/processors/ARM/gdb-7.6/sim/arm/armemu.c
===================================================================
--- branches/Cog/processors/ARM/gdb-7.6/sim/arm/armemu.c 2015-03-26 01:06:41 UTC (rev 3290)
+++ branches/Cog/processors/ARM/gdb-7.6/sim/arm/armemu.c 2015-03-26 03:56:57 UTC (rev 3291)
@@ -503,7 +503,9 @@
/* Execute the next instruction. */
- if (state->NextInstr < PRIMEPIPE)
+ if (state->NextInstr < PRIMEPIPE) /* ie SEQ(0) NONSEQ(1) PCINCEDSEQ(2) PCINCEDNONSEQ(3)
+ - PRIMEPIPE is 4 and RESUME is 8 */
+
{
decoded = state->decoded;
loaded = state->loaded;
@@ -512,12 +514,12 @@
do
{
- /* Just keep going. */
+ /* Just keep going until stopped. */
isize = INSN_SIZE;
switch (state->NextInstr)
{
- case SEQ:
+ case SEQ: /* NORMALCYCLE leads us here unless the state gets changed deeper in the loop */
/* Advance the pipeline, and an S cycle. */
state->Reg[15] += isize;
pc += isize;
@@ -555,21 +557,29 @@
break;
case RESUME:
- /* The program counter has been changed. */
- pc = state->Reg[15];
+ /* The program counter has been changed.
+ We always start here with state->EndCondition=NoError
+ and state->NextInstr=RESUME.
+ See arminit.c>>ARMul_DoProg or ARMul_DoRun.
+ If we are single stepping then state->Emulate=ONCE
+ If we are just running then state->Emulate=RUN but will get changed
+ to PCINCEDSEQ or PCINCEDNONSEQ
+ */
+ pc = state->Reg[15]; // set the pc from the value set in Alien->pc:
#ifndef MODE32
pc = pc & R15PCBITS;
#endif
- state->Reg[15] = pc + (isize * 2);
+ state->Reg[15] = pc + (isize * 2); // bump the r15 by two instructions per ARM hw
state->Aborted = 0;
- instr = ARMul_ReLoadInstr (state, pc, isize);
+ instr = ARMul_ReLoadInstr (state, pc, isize); // load the instruction to actually run
+ // if we get back an SWI_CogPrefetch then the pc was outside limits
decoded = ARMul_ReLoadInstr (state, pc + isize, isize);
loaded = ARMul_ReLoadInstr (state, pc + isize * 2, isize);
-// TPR - save the pc to help in CogVM sim error handling, IFF the instr is not an abort SWI
+ // TPR - save the pc to help in CogVM sim error handling, IFF the instr is not a SWI_CogPrefetch
if ( instr != (0xEF000000 | SWI_CogPrefetch)) {
state->temp = pc;
}
- NORMALCYCLE;
+ NORMALCYCLE; // set to do simple SEQ next time & break to end of switch
break;
default:
@@ -590,7 +600,8 @@
NORMALCYCLE;
break;
}
-
+ // END OF SWITCH stmt, where the above breaks go
+
// TPR - save the pc to help in CogVM sim error handling, IFF the instr is not an abort SWI
if ( instr != (0xEF000000 | SWI_CogPrefetch)) {
state->temp = pc;
@@ -634,7 +645,7 @@
ARMul_Abort (state, ARMul_IRQV);
break;
}
- }
+ } // state->Exception
if (state->CallDebug > 0)
{
@@ -651,10 +662,10 @@
(void) fgetc (stdin);
}
}
- else if (state->Emulate < ONCE)
+ else if (state->Emulate < ONCE) // ie STOP(0) CHANGEMODE(1) ONCE(2) RUN(3)
{
state->NextInstr = RESUME;
- break;
+ break; // if stop or changemode then break out & restart at resume
}
state->NumInstrs++;
@@ -1584,13 +1595,14 @@
{
/* BLX(2) */
ARMword temp;
-
+ // work out the return address of this BLX
if (TFLAG)
temp = (pc + 2) | 1;
else
temp = pc + 4;
-
+ // handle the R15 effects of a BLX
WriteR15Branch (state, state->Reg[RHSReg]);
+ // save the return address
state->Reg[14] = temp;
break;
}
@@ -3885,15 +3897,16 @@
#endif /* NEED_UI_LOOP_HOOK */
if (state->Emulate == ONCE)
- state->Emulate = STOP;
+ state->Emulate = STOP; // If we're single stepping ,stop now
/* If we have changed mode, allow the PC to advance before stopping. */
else if (state->Emulate == CHANGEMODE)
- continue;
+ continue;
else if (state->Emulate != RUN)
- break;
+ break;
}
while (!stop_simulator);
+ // END OF LOOP where breaks to STOP etc end up
state->decoded = decoded;
state->loaded = loaded;
state->pc = pc;
@@ -4158,7 +4171,7 @@
#ifdef MODE32
state->Reg[15] = src & PCBITS;
-#else
+#else // 26bit mode
state->Reg[15] = (src & R15PCBITS) | ECC | ER15INT | EMODE;
ARMul_R15Altered (state);
#endif
Modified: branches/Cog/processors/ARM/gdb-7.6/sim/arm/armos.c
===================================================================
--- branches/Cog/processors/ARM/gdb-7.6/sim/arm/armos.c 2015-03-26 01:06:41 UTC (rev 3290)
+++ branches/Cog/processors/ARM/gdb-7.6/sim/arm/armos.c 2015-03-26 03:56:57 UTC (rev 3291)
@@ -463,6 +463,7 @@
// during execution, the pc points the next fetch address, which is 8 byte after the current instruction.
gdb_log_printf(NULL, "Illegal Instruction fetch address (%#p).", state->Reg[15]-8);
+ return TRUE; // escape immediately
break;
case SWI_Read:
Modified: branches/Cog/processors/ARM/gdb-7.6/sim/arm/armulmem.c
===================================================================
--- branches/Cog/processors/ARM/gdb-7.6/sim/arm/armulmem.c 2015-03-26 01:06:41 UTC (rev 3290)
+++ branches/Cog/processors/ARM/gdb-7.6/sim/arm/armulmem.c 2015-03-26 03:56:57 UTC (rev 3291)
@@ -1,9 +1,15 @@
/*
- This file is a compy of armvirt.c, which is part of the ARMulator distributed e.g. with gdb and skyeye.
- In order to overwrite GetWord and PutWord, I (lars wasserman) had to copy the whole file and alter the Make to use it instead of the default ARM armvirt.c.
- Also changed: ReLoadInstr.
- TPR - changed the errors returned in PutWord & GetWord to discriminate between read & write bounds errors for better simulation
- TPR - changed Get/PutWord to ensure address used is an actual word address ie bottom two bits are zeros. Without that, fetching bytes becomes... fun
+ This file is a replacement copy of armvirt.c, which is part of the ARMulator distributed
+ with gdb.
+ Originally altered by Lars Wasserman to replace PutWord & GetWord, with extensive
+ further mangling by tim at rowlwege.org
+ TPR - changed ReLoadInstr to return a fake SWI_CogPrefetch when fetching an
+ instruction would go past our memory bounds; this stops the sim and returns to the
+ Cog development UI.
+ TPR - changed the errors returned in PutWord & GetWord to discriminate between read &
+ write bounds errors for better simulation
+ TPR - changed Get/PutWord to ensure address used is an actual word address ie bottom
+ two bits are zeros. Without that, fetching bytes becomes... fun
*/
#include "GdbARMPlugin.h"
Modified: branches/Cog/processors/ARM/gdb-7.6/sim/arm/config.log
===================================================================
--- branches/Cog/processors/ARM/gdb-7.6/sim/arm/config.log 2015-03-26 01:06:41 UTC (rev 3290)
+++ branches/Cog/processors/ARM/gdb-7.6/sim/arm/config.log 2015-03-26 03:56:57 UTC (rev 3291)
@@ -447,7 +447,7 @@
configure:8569: result: yes
configure:8569: checking for __setfpucw
configure:8569: gcc -o conftest -g -O2 conftest.c >&5
-/tmp/ccEK9d2W.o: In function `main':
+/tmp/ccymOjvz.o: In function `main':
/mnt/hgfs/tim/Documents/Squeak/Rasbian-VM/Pi-CogVM/Cog/processors/ARM/gdb-7.6/sim/arm/conftest.c:75: undefined reference to `__setfpucw'
collect2: error: ld returned 1 exit status
configure:8569: $? = 1
@@ -599,7 +599,7 @@
configure:8660: result: yes
configure:8686: checking for library containing zlibVersion
configure:8717: gcc -o conftest -g -O2 conftest.c -lnsl >&5
-/tmp/ccE36uq5.o: In function `main':
+/tmp/cct2DOfG.o: In function `main':
/mnt/hgfs/tim/Documents/Squeak/Rasbian-VM/Pi-CogVM/Cog/processors/ARM/gdb-7.6/sim/arm/conftest.c:53: undefined reference to `zlibVersion'
collect2: error: ld returned 1 exit status
configure:8717: $? = 1
@@ -710,7 +710,7 @@
configure:11953: result: immediate
configure:12047: checking for shl_load
configure:12047: gcc -o conftest -g -O2 conftest.c -lz -lnsl >&5
-/tmp/ccwG2viw.o: In function `main':
+/tmp/ccR1zhOm.o: In function `main':
/mnt/hgfs/tim/Documents/Squeak/Rasbian-VM/Pi-CogVM/Cog/processors/ARM/gdb-7.6/sim/arm/conftest.c:78: undefined reference to `shl_load'
collect2: error: ld returned 1 exit status
configure:12047: $? = 1
@@ -864,7 +864,7 @@
configure:12085: result: no
configure:12090: checking for dlopen
configure:12090: gcc -o conftest -g -O2 conftest.c -lz -lnsl >&5
-/tmp/ccZZ9CqF.o: In function `main':
+/tmp/cciImnQq.o: In function `main':
/mnt/hgfs/tim/Documents/Squeak/Rasbian-VM/Pi-CogVM/Cog/processors/ARM/gdb-7.6/sim/arm/conftest.c:78: undefined reference to `dlopen'
collect2: error: ld returned 1 exit status
configure:12090: $? = 1
@@ -961,7 +961,7 @@
configure:12348: result: yes
configure:12353: checking whether a statically linked program can dlopen itself
configure:12433: gcc -o conftest -g -O2 -DHAVE_DLFCN_H -Wl,--export-dynamic -static conftest.c -ldl -lz -lnsl >&5
-/tmp/ccFmMjQP.o: In function `main':
+/tmp/ccCKjI5A.o: In function `main':
/mnt/hgfs/tim/Documents/Squeak/Rasbian-VM/Pi-CogVM/Cog/processors/ARM/gdb-7.6/sim/arm/configure:12413: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in `/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libc.a(strcmp.o)' can not be used when making an executable; recompile with -fPIE and relink with -pie
collect2: error: ld returned 1 exit status
Modified: branches/Cog/processors/ARM/gdb-7.6/sim/common/config.log
===================================================================
--- branches/Cog/processors/ARM/gdb-7.6/sim/common/config.log 2015-03-26 01:06:41 UTC (rev 3290)
+++ branches/Cog/processors/ARM/gdb-7.6/sim/common/config.log 2015-03-26 03:56:57 UTC (rev 3291)
@@ -447,7 +447,7 @@
configure:6839: result: yes
configure:6839: checking for __setfpucw
configure:6839: gcc -o conftest -g -O2 conftest.c >&5
-/tmp/ccumGyEY.o: In function `main':
+/tmp/ccka0ti2.o: In function `main':
/mnt/hgfs/tim/Documents/Squeak/Rasbian-VM/Pi-CogVM/Cog/processors/ARM/gdb-7.6/sim/common/conftest.c:75: undefined reference to `__setfpucw'
collect2: error: ld returned 1 exit status
configure:6839: $? = 1
@@ -599,7 +599,7 @@
configure:6930: result: yes
configure:6956: checking for library containing zlibVersion
configure:6987: gcc -o conftest -g -O2 conftest.c -lnsl >&5
-/tmp/ccw297dY.o: In function `main':
+/tmp/cc6ihiQd.o: In function `main':
/mnt/hgfs/tim/Documents/Squeak/Rasbian-VM/Pi-CogVM/Cog/processors/ARM/gdb-7.6/sim/common/conftest.c:53: undefined reference to `zlibVersion'
collect2: error: ld returned 1 exit status
configure:6987: $? = 1
@@ -710,7 +710,7 @@
configure:10223: result: immediate
configure:10317: checking for shl_load
configure:10317: gcc -o conftest -g -O2 conftest.c -lz -lnsl >&5
-/tmp/ccAVKmQV.o: In function `main':
+/tmp/ccN0Wv6V.o: In function `main':
/mnt/hgfs/tim/Documents/Squeak/Rasbian-VM/Pi-CogVM/Cog/processors/ARM/gdb-7.6/sim/common/conftest.c:78: undefined reference to `shl_load'
collect2: error: ld returned 1 exit status
configure:10317: $? = 1
@@ -864,7 +864,7 @@
configure:10355: result: no
configure:10360: checking for dlopen
configure:10360: gcc -o conftest -g -O2 conftest.c -lz -lnsl >&5
-/tmp/ccGMa0C1.o: In function `main':
+/tmp/ccwcvMF1.o: In function `main':
/mnt/hgfs/tim/Documents/Squeak/Rasbian-VM/Pi-CogVM/Cog/processors/ARM/gdb-7.6/sim/common/conftest.c:78: undefined reference to `dlopen'
collect2: error: ld returned 1 exit status
configure:10360: $? = 1
@@ -961,7 +961,7 @@
configure:10618: result: yes
configure:10623: checking whether a statically linked program can dlopen itself
configure:10703: gcc -o conftest -g -O2 -DHAVE_DLFCN_H -Wl,--export-dynamic -static conftest.c -ldl -lz -lnsl >&5
-/tmp/ccYC6wPb.o: In function `main':
+/tmp/cckBQwCa.o: In function `main':
/mnt/hgfs/tim/Documents/Squeak/Rasbian-VM/Pi-CogVM/Cog/processors/ARM/gdb-7.6/sim/common/configure:10683: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in `/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libc.a(strcmp.o)' can not be used when making an executable; recompile with -fPIE and relink with -pie
collect2: error: ld returned 1 exit status
More information about the Vm-dev
mailing list