Skip to content

Commit

Permalink
Add a somewhat cut down version of the gdb 8.3.1 source tree that can…
Browse files Browse the repository at this point in the history
… provide

ARMv8 simulation (and should be able to provide ARMv5,6,7 simulation too).
Add library build dirctories for 64-bit linux & macos.  Add the source
generation files to generate the processor simulator accessors.  The build has
been tested on 64-bit MacOS (10.13.x) and 64-bit Linux (CentOS 6.5).
The next step is to build a simulator plugin for "aarch64" a.k.a. ARMv8.
  • Loading branch information
eliotmiranda committed Nov 14, 2019
1 parent 8484aec commit 91b7b98
Show file tree
Hide file tree
Showing 2,400 changed files with 2,141,960 additions and 0 deletions.
16 changes: 16 additions & 0 deletions build.linux64x64/gdbarm64/conf.COG
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
S=../../../processors/ARM/gdb-8.3.1
export CFLAGS="-g -O2 -m64"
CONFFLAGS='--target=aarch64-linux --with-system-zlib=yes'
#mkdir -p zlib
#for d in zlib; do
# (cd $d; $S/$d/configure COG=1 CFLAGS="$CFLAGS" $CONFFLAGS)
#done
mkdir -p bfd gdb libiberty opcodes sim/common sim/aarch64
for d in bfd gdb libiberty opcodes; do
(cd $d; $S/$d/configure COG=1 CFLAGS="$CFLAGS" $CONFFLAGS)
done
for d in sim/common sim/aarch64; do
(cd $d;
../$S/$d/configure COG=1 CFLAGS="$CFLAGS" $CONFFLAGS --without-profile)
done
6 changes: 6 additions & 0 deletions build.linux64x64/gdbarm64/makeem
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh -e
test -d bfd || ./conf.COG
(cd ./bfd; make COG=1 bfdver.h targmatch.h elf32-target.h elf64-target.h libbfd.a)
(cd ./libiberty; make COG=1 libiberty.a)
(cd ./opcodes; make COG=1 libopcodes.a)
(cd ./sim/aarch64; make version.c; mv version.c-tmp version.c; make COG=1 libsim.a)
16 changes: 16 additions & 0 deletions build.macos64x64/gdbarm64/conf.COG
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
S=../../../processors/ARM/gdb-8.3.1
export CFLAGS="-g -O2 -m64"
CONFFLAGS='--target=aarch64-apple-darwin CC=clang CXX=clang++ --with-system-zlib=yes'
#mkdir -p zlib
#for d in zlib; do
# (cd $d; $S/$d/configure COG=1 CFLAGS="$CFLAGS" $CONFFLAGS)
#done
mkdir -p bfd gdb libiberty opcodes sim/common sim/aarch64
for d in bfd gdb libiberty opcodes; do
(cd $d; $S/$d/configure COG=1 CFLAGS="$CFLAGS" $CONFFLAGS)
done
for d in sim/common sim/aarch64; do
(cd $d;
../$S/$d/configure COG=1 CFLAGS="$CFLAGS" $CONFFLAGS --without-profile)
done
6 changes: 6 additions & 0 deletions build.macos64x64/gdbarm64/makeem
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh -e
test -d bfd || ./conf.COG
(cd ./bfd; make COG=1 bfdver.h targmatch.h libbfd.a)
(cd ./libiberty; make COG=1 libiberty.a)
(cd ./opcodes; make COG=1 libopcodes.a)
(cd ./sim/aarch64; make version.c; mv version.c-tmp version.c; make COG=1 libsim.a)
39 changes: 39 additions & 0 deletions processors/ARM/exploration64/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
LIBDEPS=../cpu/libcpu.a
ARMGDB=../../../processors/ARM/gdb-8.3.1
INCLUDES := -I$(ARMGDB)/include \
-I$(ARMGDB)/sim/aarch64 \
-I$(ARMGDB)/bfd \
-I../bfd -I../gdb -I..
LIBS:=-L../bfd -L../libiberty -L../opcodes -L../sim/aarch64 \
-lbfd -liberty -lopcodes -lopcodes -lsim -lz
CFLAGS=-m32 -DCOG=1 -DMODET $(INCLUDES) $(LIBS)

GDBARMEXP=.
CLASS=GdbARMv8Alien

.PHONY: $(LIBDEPS)

all: ${CLASS}-regs.st ${CLASS}-ctrl.st ${CLASS}-vfp.st

${CLASS}-regs.st: printcpu
./printcpu >${CLASS}-regs.st

${CLASS}-ctrl.st: printcpuctrl
./printcpuctrl >${CLASS}-ctrl.st

${CLASS}-vfp.st: printcpuvfp
./printcpuvfp >${CLASS}-vfp.st

clean:
rm -f ${CLASS}-regs.st ${CLASS}-vfp.st
rm -f printcpu printcpuctrl printcpuvfp
rm -f printcpu.exe printcpuctrl.exe printcpuvfp.exe

printcpu: $(GDBARMEXP)/printcpu.c $(LIBDEPS)
$(CC) -o $@ $< $(CFLAGS)

printcpuctrl: $(GDBARMEXP)/printcpuctrl.c $(LIBDEPS)
$(CC) -o $@ $< $(CFLAGS)

printcpuvfp: $(GDBARMEXP)/printcpuvfp.c $(LIBDEPS)
$(CC) -o $@ $< $(CFLAGS)
39 changes: 39 additions & 0 deletions processors/ARM/exploration64/Makefile64
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
LIBDEPS=../cpu/libcpu.a
ARMGDB=../../../processors/ARM/gdb-8.3.1
INCLUDES := -I../sim/aarch64 -I../bfd -I../gdb -I.. \
-I$(ARMGDB)/include \
-I$(ARMGDB)/sim/aarch64 \
-I$(ARMGDB)/sim/common \
-I$(ARMGDB)/bfd
LIBS:=-L../bfd -L../libiberty -L../opcodes -L../sim/aarch64 \
-lbfd -liberty -lopcodes -lopcodes -lsim
CFLAGS=-m64 -DCOG=1 -DFOR64BITS=1 -DMODET -DWITH_PROFILE=-1 $(INCLUDES) $(LIBS)

GDBARMEXP=.
CLASS=GdbARMv8Alien64

.PHONY: $(LIBDEPS)

all: ${CLASS}-regs.st ${CLASS}-ctrl.st ${CLASS}-vfp.st

${CLASS}-regs.st: printcpu64
./printcpu64 >${CLASS}-regs.st

${CLASS}-ctrl.st: printcpuctrl64
./printcpuctrl64 >${CLASS}-ctrl.st

${CLASS}-vfp.st: printcpuvfp64
./printcpuvfp64 >${CLASS}-vfp.st

clean:
rm -f ${CLASS}-regs.st ${CLASS}-vfp.st
rm -f printcpu64 printcpuctrl64 printcpuvfp64

printcpu64: $(GDBARMEXP)/printcpu.c $(LIBDEPS)
$(CC) -o $@ $< $(CFLAGS)

printcpuctrl64: $(GDBARMEXP)/printcpuctrl.c $(LIBDEPS)
$(CC) -o $@ $< $(CFLAGS)

printcpuvfp64: $(GDBARMEXP)/printcpuvfp.c $(LIBDEPS)
$(CC) -o $@ $< $(CFLAGS)
98 changes: 98 additions & 0 deletions processors/ARM/exploration64/printcpu.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>

#define COG 1
#define FOR_COG_PLUGIN 1

#include <config.h>
#include <sim-main.h>

static char buf[10];

char *
lower(char *s)
{
int i;
for (i = 0; i < strlen(s); i++)
buf[i] = tolower(s[i]);
buf[i] = 0;
return buf;
}

#if FOR64BITS
# define CLASS "!GdbARMAlien64"
#else
# define CLASS "!GdbARMAlien"
#endif

int
main()
{
//#define offsetof(type,field) (long)(&(((type *)0)->field))
#define stoffsetof(type,field) (offsetof(type,field)+1)
#define print(n,r) \
printf(CLASS " methodsFor: 'accessing' stamp: 'eem %d/%d/%d %d:%02d'!\r"\
"%s\r\t^self unsignedLongLongAt: %ld! !\r", m,d,y,h,i, lower(#r), \
stoffsetof(struct _sim_cpu,gr[n]));\
printf(CLASS " methodsFor: 'accessing' stamp: 'eem %d/%d/%d %d:%02d'!\r"\
"%s: anUnsignedInteger\r\t^self unsignedLongLongAt: %ld put: anUnsignedInteger! !\r", m,d,y,h,i, lower(#r), \
stoffsetof(struct _sim_cpu,gr[n]))

#define printpc(r) \
printf(CLASS " methodsFor: 'accessing' stamp: 'eem %d/%d/%d %d:%02d'!\r"\
"%s\r\t^self unsignedLongLongAt: %ld! !\r", m,d,y,h,i, lower(#r), \
stoffsetof(struct _sim_cpu,pc));\
printf(CLASS " methodsFor: 'accessing' stamp: 'eem %d/%d/%d %d:%02d'!\r"\
"%s: anUnsignedInteger\r\t^self unsignedLongLongAt: %ld put: anUnsignedInteger! !\r", m,d,y,h,i, lower(#r), \
stoffsetof(struct _sim_cpu,pc))

time_t nowsecs = time(0);
struct tm now = *localtime(&nowsecs);
int m = now.tm_mon + 1; /* strange but true */
int d = now.tm_mday;
int y = now.tm_year + 1900;
int h = now.tm_hour;
int i = now.tm_min;

printf("\"Hello world!!\"!\r");
printf(CLASS " class methodsFor: 'instance creation' stamp: 'eem %d/%d/%d %d:%02d'!\r"
"dataSize\r\t^%ld! !\r", m,d,y,h,i, sizeof(struct sim_state));

print(0,r0);
print(1,r1);
print(2,r2);
print(3,r3);
print(4,r4);
print(5,r5);
print(6,r6);
print(7,r7);
print(8,r8);
print(9,r9);
print(10,r10);
print(11,r11);
print(12,r12);
print(13,r13);
print(14,r14);
print(15,r15);
print(16,r16);
print(17,r17);
print(18,r18);
print(19,r19);
print(20,r20);
print(21,r21);
print(22,r22);
print(23,r23);
print(24,r24);
print(25,r25);
print(26,r26);
print(27,r27);
print(28,r28);
print(29,FP);
print(30,LR);
print(31,SP);
printpc(pc);

return 0;
}
61 changes: 61 additions & 0 deletions processors/ARM/exploration64/printcpuctrl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>

#define COG 1
#define FOR_COG_PLUGIN 1

#include <config.h>
#include <sim-main.h>

static char buf[10];

char *
lower(char *s)
{
int i;
for (i = 0; i < strlen(s); i++)
buf[i] = tolower(s[i]);
buf[i] = 0;
return buf;
}

#if FOR64BITS
# define CLASS "!GdbARMAlien64"
#else
# define CLASS "!GdbARMAlien"
#endif

int
main()
{
//#define offsetof(type,field) (long)(&(((type *)0)->field))
#define stoffsetof(type,field) (offsetof(type,field)+1)
#define print(f,s) \
printf(CLASS " methodsFor: 'accessing' stamp: 'eem %d/%d/%d %d:%02d'!\r"\
"%s\r\t^self unsignedLongLongAt: %ld! !\r", m,d,y,h,i, #s, \
stoffsetof(struct _sim_cpu,f));\
printf(CLASS " methodsFor: 'accessing' stamp: 'eem %d/%d/%d %d:%02d'!\r"\
"%s: anUnsignedInteger\r\t^self unsignedLongLongAt: %ld put: anUnsignedInteger! !\r", m,d,y,h,i, #s, \
stoffsetof(struct _sim_cpu,f))

time_t nowsecs = time(0);
struct tm now = *localtime(&nowsecs);
int m = now.tm_mon + 1; /* strange but true */
int d = now.tm_mday;
int y = now.tm_year + 1900;
int h = now.tm_hour;
int i = now.tm_min;

printf("\"Hello world!!\"!\r");
printf(CLASS " class methodsFor: 'instance creation' stamp: 'eem %d/%d/%d %d:%02d'!\r"
"dataSize\r\t^%ld! !\r", m,d,y,h,i, sizeof(struct _sim_cpu));

print(CPSR,rawCPSR);
print(FPSR,fpCPSR);
print(FPCR,fpCPCR);
print(nextpc,nextpc);

return 0;
}
89 changes: 89 additions & 0 deletions processors/ARM/exploration64/printcpuvfp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>

#define COG 1
#define FOR_COG_PLUGIN 1

#include <config.h>
#include <sim-main.h>

static char buf[10];

char *
lower(char *s)
{
int i;
for (i = 0; i < strlen(s); i++)
buf[i] = tolower(s[i]);
buf[i] = 0;
return buf;
}

#if FOR64BITS
# define CLASS "!GdbARMAlien64"
#else
# define CLASS "!GdbARMAlien"
#endif

int
main()
{
//#define offsetof(type,field) (long)(&(((type *)0)->field))
#define stoffsetof(type,field) (offsetof(type,field)+1)
#define print(n,r) \
printf(CLASS " methodsFor: 'accessing' stamp: 'eem %d/%d/%d %d:%02d'!\r"\
"%s\r\t^self unsignedLongLongAt: %ld! !\r", m,d,y,h,i, lower(#r), \
stoffsetof(struct _sim_cpu,fr[n]));\
printf(CLASS " methodsFor: 'accessing' stamp: 'eem %d/%d/%d %d:%02d'!\r"\
"%s: anUnsignedInteger\r\t^self unsignedLongLongAt: %ld put: anUnsignedInteger! !\r", m,d,y,h,i, lower(#r), \
stoffsetof(struct _sim_cpu,fr[n]))

time_t nowsecs = time(0);
struct tm now = *localtime(&nowsecs);
int m = now.tm_mon + 1; /* strange but true */
int d = now.tm_mday;
int y = now.tm_year + 1900;
int h = now.tm_hour;
int i = now.tm_min;

printf("\"Hello world!!\"!\r");
printf(CLASS " class methodsFor: 'instance creation' stamp: 'eem %d/%d/%d %d:%02d'!\r"
"dataSize\r\t^%ld! !\r", m,d,y,h,i, sizeof(struct _sim_cpu));

print(0,d0);
print(1,d1);
print(2,d2);
print(3,d3);
print(4,d4);
print(5,d5);
print(6,d6);
print(7,d7);
print(8,d8);
print(9,d9);
print(10,d10);
print(11,d11);
print(12,d12);
print(13,d13);
print(14,d14);
print(15,d15);
print(16,d16);
print(17,d17);
print(18,d18);
print(19,d19);
print(20,d20);
print(21,d21);
print(22,d22);
print(23,d23);
print(24,d24);
print(25,d25);
print(26,d26);
print(27,d27);
print(28,d28);
print(29,d29);
print(30,d30);
print(31,d31);

return 0;
}
Loading

0 comments on commit 91b7b98

Please sign in to comment.