[Vm-dev] [commit][2822] Merge Lars' latest changes to the GdbARMPlugin ( from a while back).

commits at squeakvm.org commits at squeakvm.org
Mon Dec 9 18:15:56 UTC 2013


Revision: 2822
Author:   eliot
Date:     2013-12-09 10:15:54 -0800 (Mon, 09 Dec 2013)
Log Message:
-----------
Merge Lars' latest changes to the GdbARMPlugin (from a while back).

Modified Paths:
--------------
    trunk/platforms/Cross/plugins/GdbARMPlugin/Makefile
    trunk/platforms/Cross/plugins/GdbARMPlugin/Makefile.win32
    trunk/platforms/Cross/plugins/GdbARMPlugin/armulmem.c
    trunk/platforms/Cross/plugins/GdbARMPlugin/sqGdbARMPlugin.c

Added Paths:
-----------
    trunk/platforms/Cross/plugins/GdbARMPlugin/HowToBuild
    trunk/platforms/Cross/plugins/GdbARMPlugin/Makefile.unix

Added: trunk/platforms/Cross/plugins/GdbARMPlugin/HowToBuild
===================================================================
--- trunk/platforms/Cross/plugins/GdbARMPlugin/HowToBuild	                        (rev 0)
+++ trunk/platforms/Cross/plugins/GdbARMPlugin/HowToBuild	2013-12-09 18:15:54 UTC (rev 2822)
@@ -0,0 +1,81 @@
+Building the GdbARMPlugin
+------------------------------
+
+Build the normal VM on your Platform. Consult Cog/{cygwinbuild|unixbuild|macbuild}/HowToBuild 
+for additional information.
+When generating sources, update to the latest 
+versions of Cog and VMMaker.oscog.
+You might want/need to change VMMaker 
+class>generateSqueakCogVM to point to the right 
+directories and remove FT2Plugin from the plugin-
+list (even if skipped, generates a messageNotUnderstood). 
+You can also change VMMaker>plugins:do: removing 
+the return in the false block, in order to skip 
+when a plugin is not found, instead of aborting 
+the generation process.
+
+Building on Windows
+------------------------------
+(so far tried with Windows 7 64bit unsing mingw/MSYS 32bit)
+
+Besides the normal build environment, you need the package gettext.
+Also, downgrade your mingwrt package to 3.20 (not 3.20-2) by unpacking
+the respective -dev tarball into your mingw-folder.
+
+When compiling the Squeak VM you need a version 3 gcc/g++. 
+For configuration of gdb, you need a version 4 gcc (you don't need 
+to switch g++). For switching between compilers in mingw, 
+you may use 
+	mingw-get install/remove gcc/gcc-v3/g++/gcc-v3-g++.
+
+Compile gdb/bfd and gdb/opcodes with a gcc 4.*.
+	cd <gdb>/bfd
+	./configure --enable-targets=arm-linux
+	make
+	cd <gdb>/opcodes
+	./configure --enable-targets=arm-linux
+	make
+Then switch to gcc-v3.
+	cd <gdb>/bfd
+	make clean && make
+	cd <gdb>/opcodes
+	make clean && make
+	
+For libsim.a, the gcc version is not important.
+	cd sim/common
+	./configure
+	cd ../arm
+	./configure && make libsim.a
+
+Change Makefile.win32 to point to your gdb folder.
+Then copy the plugin files to your svn-checkout, 
+for example changing <plugin>/Makefile and running it.
+Change <cog>/cygwinbuild/plugins.ext to include GdbARMPlugin.
+Change to gcc 3, then build the VM (again).
+
+Building on Linux
+------------------------------
+(so far tried on Ubuntu 12.04 LTS 32bit)
+
+Download the gdb sources (http://ftp.gnu.org/gnu/gdb) and 
+unpack them. Change Makefile and Makefile.unix, setting 
+GDBBUILDFOLDER to the correct place.
+
+Compile libopcodes.a:
+	cd GDBBUILDFOLDER
+	./configure --enable-targets=arm-linux
+Making gdb takes quite some time. It may fail, as long as 
+it generates <gdb>/bfd/bfd.h and <gdb>/opcodes/libopcodes.a.
+	make
+Compile libsim.a
+	cd sim/common
+	./configure
+	cd ../arm
+	./configure
+	make
+Ensure libsim.a exists in <gdb>/sim/arm.
+
+Make the plugin which just copies the plugin-files 
+to the appropriate directories. Then change 
+Cog/unixbuild/bld/plugins.ext to include GdbARMPlugin.
+Build the VM (again).


Property changes on: trunk/platforms/Cross/plugins/GdbARMPlugin/HowToBuild
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/platforms/Cross/plugins/GdbARMPlugin/Makefile
===================================================================
--- trunk/platforms/Cross/plugins/GdbARMPlugin/Makefile	2013-12-06 23:53:30 UTC (rev 2821)
+++ trunk/platforms/Cross/plugins/GdbARMPlugin/Makefile	2013-12-09 18:15:54 UTC (rev 2822)
@@ -1,15 +1,24 @@
+GDBBUILDFOLDER = /d/build/gdb-7.4
+
 CC      = gcc
-CFLAGS  = 
-LDFLAGS = libsim.a $(GDBBUILDFOLDER)/opcodes/libopcodes.a -lbfd -lintl -liberty -Wl,-wrap,ARMul_OSHandleSWI
-GDBBUILDFOLDER = /d/build/gdb-7.4
+CFLAGS  = -I$(GBDBUILDFOLDER)/bfd 
+LDFLAGS = $(GDBBUILDFOLDER)/sim/arm/libsim.a $(GDBBUILDFOLDER)/opcodes/libopcodes.a -lbfd -lintl -liberty -Wl,-wrap,ARMul_OSHandleSWI -L$(GDBBUILDFOLDER)/bfd/ 
 SHAREDLIBRARYFLAGS = 
 
 all:
-	$(CC) $(CFLAGS) armulmem.c -c -I$(GDBBUILDFOLDER)/sim/arm/
-	$(CC) $(CFLAGS) sqGdbARMPlugin.c -c -fPIC -I$(GDBBUILDFOLDER)/sim/arm/
-	gcc -shared $(SHAREDLIBRARYFLAGS) -o GdbARMPlugin.dll sqGdbARMPlugin.o armulmem.o $(LDFLAGS)
-#	mkdir ../cog/platforms/Cross/plugins/GdbARMPlugin
-#	mkdir ../cog/platforms/win32/plugins/GdbARMPlugin
+# another test on linux:
+#	$(CC) $(CFLAGS) armulmem.c -c -I$(GDBBUILDFOLDER)/sim/arm/ -I$(GDBBUILDFOLDER)/include/
+#	$(CC) $(CFLAGS) sqGdbARMPlugin.c -c -fPIC -I$(GDBBUILDFOLDER)/sim/arm/ -I$(GDBBUILDFOLDER)/include/ -I$(GDBBUILDFOLDER)/bfd/ 
+#	$(CC) -shared $(SHAREDLIBRARYFLAGS) -o GdbARMPlugin.dll sqGdbARMPlugin.o armulmem.o $(LDFLAGS)
+
+	mkdir -p ../cog/platforms/Cross/plugins/GdbARMPlugin
+	mkdir -p ../cog/platforms/win32/plugins/GdbARMPlugin
+	mkdir -p ../cog/platforms/unix/plugins/GdbARMPlugin
+
 	cp sqGdbARMPlugin.c GdbARMPlugin.h armulmem.c ../cog/platforms/Cross/plugins/GdbARMPlugin/
 	cp Makefile.win32 ../cog/platforms/win32/plugins/GdbARMPlugin/Makefile
-	cd ../cog/cygwinbuild; make
+	cp Makefile.unix ../cog/platforms/unix/plugins/GdbARMPlugin/Makefile.inc
+#unix
+#	cd ../cog/unixbuild/bld; make install #prefix=
+#windows
+	cd ../cog/cygwinbuild/;make

Added: trunk/platforms/Cross/plugins/GdbARMPlugin/Makefile.unix
===================================================================
--- trunk/platforms/Cross/plugins/GdbARMPlugin/Makefile.unix	                        (rev 0)
+++ trunk/platforms/Cross/plugins/GdbARMPlugin/Makefile.unix	2013-12-09 18:15:54 UTC (rev 2822)
@@ -0,0 +1,10 @@
+GDBBUILDFOLDER	= $(topdir)/../gdb
+XCFLAGS		= -m32 -DNEED_UI_LOOP_HOOK
+
+XINCLUDES	+= -I$(GDBBUILDFOLDER)/sim/arm
+XINCLUDES	:= -I$(GDBBUILDFOLDER)/bfd $(XINCLUDES)
+
+XLDFLAGS=	$(GDBBUILDFOLDER)/sim/arm/libsim.a \
+		$(GDBBUILDFOLDER)/opcodes/libopcodes.a \
+		-lbfd -liberty \
+		-Wl,-wrap,ARMul_OSHandleSWI


Property changes on: trunk/platforms/Cross/plugins/GdbARMPlugin/Makefile.unix
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/platforms/Cross/plugins/GdbARMPlugin/Makefile.win32
===================================================================
--- trunk/platforms/Cross/plugins/GdbARMPlugin/Makefile.win32	2013-12-06 23:53:30 UTC (rev 2821)
+++ trunk/platforms/Cross/plugins/GdbARMPlugin/Makefile.win32	2013-12-09 18:15:54 UTC (rev 2822)
@@ -1,14 +1,13 @@
-DLLTOOLEXTRA := /d/Dateien/cog/squeakvm-armulator-plugin/libsim.a \
-				/d/build/gdb-7.4/opcodes/libopcodes.a
-DLLWRAPEXTRA := $(DLLTOOLEXTRA)
+GDBBUILDFOLDER = /d/Programming/cog/gdb
 
 LINK_WITH_GPP := yes
-EXTRALIBS:= -L/d/Dateien/cog/squeakvm-armulator-plugin \
-			-L/d/build/gdb-7.4/opcodes \
+EXTRALIBS:= -L$(GDBBUILDFOLDER)/opcodes \
+			-L$(GDBBUILDFOLDER)/sim/arm \
 			-lsim -lopcodes -lbfd -lintl -liberty -Wl,-wrap,ARMul_OSHandleSWI
 
 include ../../Makefile.plugin
 
-INCLUDES:= $(INCLUDES) -I/d/build/gdb-7.4/sim/arm
+INCLUDES:= $(INCLUDES) -I$(GDBBUILDFOLDER)/sim/arm
 
-
+# Copy libgcc_s_dw2-1.dll, libiconv-2.dll and libintl-8.dll from your MinGW/bin 
+# folder to the VM folder, to make it work on other Windows (7?) systems

Modified: trunk/platforms/Cross/plugins/GdbARMPlugin/armulmem.c
===================================================================
--- trunk/platforms/Cross/plugins/GdbARMPlugin/armulmem.c	2013-12-06 23:53:30 UTC (rev 2821)
+++ trunk/platforms/Cross/plugins/GdbARMPlugin/armulmem.c	2013-12-09 18:15:54 UTC (rev 2822)
@@ -73,7 +73,7 @@
     //raise memory access error
     state->EndCondition = MemoryBoundsError;
     state->Emulate = FALSE;
-    gdb_log_printf(NULL, "Illegal memory read at 0x%p. ", address);
+    gdb_log_printf(NULL, "Illegal memory read at %#p. ", address);
     return 0;
   }
   else
@@ -93,7 +93,7 @@
   {
     state->Emulate = FALSE;
     state->EndCondition = MemoryBoundsError;
-    gdb_log_printf(NULL, "Illegal memory write at 0x%p. ", address);
+    gdb_log_printf(NULL, "Illegal memory write at %#p. ", address);
   } 
   else
   {

Modified: trunk/platforms/Cross/plugins/GdbARMPlugin/sqGdbARMPlugin.c
===================================================================
--- trunk/platforms/Cross/plugins/GdbARMPlugin/sqGdbARMPlugin.c	2013-12-06 23:53:30 UTC (rev 2821)
+++ trunk/platforms/Cross/plugins/GdbARMPlugin/sqGdbARMPlugin.c	2013-12-09 18:15:54 UTC (rev 2822)
@@ -15,6 +15,9 @@
 
 ARMul_State*	lastCPU = NULL;
 
+/* When compiling armulator, it generally sets NEED_UI_LOOP_HOOK, which 
+	makes the main emulation step require this symbol to be set. */
+extern int (*deprecated_ui_loop_hook) (int) = NULL;
 
 // These two variables exist, in case there are library-functions which write to a stream.
 // In that case, we would write functions which print to that stream instead of stderr or similar
@@ -112,9 +115,8 @@
 	return runOnCPU(cpu, memory, byteSize, minAddr, minWriteMaxExecAddr, ARMul_DoProg);
 }
 
-// next functions reason for existence is not clear
 /*
- * Currently a dummy for Bochs.
+ * Currently a dummy for ARM Processor Alien.
  */
 void
 flushICacheFromTo(void *cpu, ulong saddr, ulong eaddr)
@@ -158,23 +160,14 @@
 	
 	// sets some fields in the structure dis to architecture specific values
 	disassemble_init_for_target( dis );
-	// Given a bfd, the disassembler can find the arch by itself.
-	// Unfortunately, we don't have bfd-structures, so we have to choose the function by hand.
-	//disassemble = disassembler( c );
-	disassembler_ftype disassembler = print_insn_little_arm;
-	//other possible functions are listed in opcodes/dissassemble.c
 	
 	dis->buffer_vma = 0;
 	dis->buffer = memory;
 	dis->buffer_length = byteSize;
 	
-	// while-loop for calling single instruction decoding:
-	unsigned int isize = 0;
-	size_t pos = laddr;
-	size_t max_pos = dis->buffer_vma+dis->buffer_length;
+	//other possible functions are listed in opcodes/dissassemble.c
+	unsigned int size = print_insn_little_arm((bfd_vma) laddr, dis);
 	
-	unsigned int size = disassembler((bfd_vma) pos, dis);
-	
 	free(dis);
 	gdb_log[gdblog_index+1] = 0;
 	
@@ -212,7 +205,7 @@
 			state->EndCondition = MemoryBoundsError;
 			
 			// 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 (0x%p).", state->Reg[15]-8);
+			gdb_log_printf(NULL, "Illegal Instruction fetch address (%#p).", state->Reg[15]-8);
 			return TRUE;
 	  }
 	return __real_ARMul_OSHandleSWI(state, number);



More information about the Vm-dev mailing list