From 5e2eec749173135a9639e5732f229e002c0b02d0 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 4 Oct 2012 12:09:47 +0800 Subject: [PATCH] AcessNative - Misc testing and bugfixing --- AcessNative/RunTest | 4 ++-- AcessNative/acesskernel_src/main.c | 26 ++++++++++++++++++-------- AcessNative/acesskernel_src/server.c | 21 +++++++++++++++++---- AcessNative/ld-acess_src/Makefile | 5 +++-- AcessNative/ld-acess_src/request.c | 1 + 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/AcessNative/RunTest b/AcessNative/RunTest index f2621d4f..6ea88b67 100755 --- a/AcessNative/RunTest +++ b/AcessNative/RunTest @@ -1,6 +1,6 @@ #!/bin/sh trap '' 2 -$1 ./AcessKernel --rootapp /Acess/SBin/login -#$1 ./AcessKernel --rootapp /Acess/Apps/AxWin/3.0/AxWinWM +#$1 ./AcessKernel --rootapp /Acess/SBin/login +$1 ./AcessKernel --rootapp /Acess/Apps/AxWin/3.0/AxWinWM trap 2 killall ld-acess diff --git a/AcessNative/acesskernel_src/main.c b/AcessNative/acesskernel_src/main.c index fbb457cf..8f03f9a4 100644 --- a/AcessNative/acesskernel_src/main.c +++ b/AcessNative/acesskernel_src/main.c @@ -14,6 +14,8 @@ #include #include +#define VALGRIND_CLIENT 0 + // === IMPORTS === extern int UI_Initialise(int Width, int Height); extern void UI_MainLoop(void); @@ -97,15 +99,19 @@ int main(int argc, char *argv[]) if( rootapp ) { int pid; - char *args[7+rootapp_argc+1]; - - args[0] = "ld-acess"; - args[1] = "--open"; args[2] = "/Devices/VTerm/0"; - args[3] = "--open"; args[4] = "/Devices/VTerm/0"; - args[5] = "--open"; args[6] = "/Devices/VTerm/0"; + int argcount = 0; + char *args[7+rootapp_argc+1+1]; + + #if VALGRIND_CLIENT + args[argcount++] = "valgrind"; + #endif + args[argcount++] = "./ld-acess"; + args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0"; + args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0"; + args[argcount++] = "--open"; args[argcount++] = "/Devices/VTerm/0"; for( i = 0; i < rootapp_argc; i ++ ) - args[7+i] = rootapp[i]; - args[7+rootapp_argc] = NULL; + args[argcount+i] = rootapp[i]; + args[argcount+rootapp_argc] = NULL; pid = fork(); if(pid < 0) { @@ -117,7 +123,11 @@ int main(int argc, char *argv[]) #ifdef __LINUX__ prctl(PR_SET_PDEATHSIG, SIGHUP); // LINUX ONLY! #endif + #if VALGRIND_CLIENT + execv("valgrind", args); + #else execv("./ld-acess", args); + #endif } printf("Root application running as PID %i\n", pid); } diff --git a/AcessNative/acesskernel_src/server.c b/AcessNative/acesskernel_src/server.c index 37694bfc..bdc98795 100644 --- a/AcessNative/acesskernel_src/server.c +++ b/AcessNative/acesskernel_src/server.c @@ -19,6 +19,7 @@ #endif #include "../syscalls.h" //#include +#include #define USE_TCP 1 #define MAX_CLIENTS 16 @@ -159,6 +160,11 @@ int Server_WorkerThread(void *ClientPtr) size_t len = recv(Client->Socket, hdr, sizeof(*hdr), 0); Log_Debug("Server", "%i bytes of header", len); if( len == 0 ) break; + if( len == -1 ) { + perror("recv header"); +// Log_Warning("Server", "recv() error - %s", strerror(errno)); + break; + } if( len != sizeof(*hdr) ) { // Oops? Log_Warning("Server", "FD%i bad sized (%i != exp %i)", @@ -173,10 +179,17 @@ int Server_WorkerThread(void *ClientPtr) continue ; } - len = recv(Client->Socket, hdr->Params, hdr->NParams*sizeof(tRequestValue), 0); - Log_Debug("Server", "%i bytes of params", len); - if( len != hdr->NParams*sizeof(tRequestValue) ) { - // Oops. + if( hdr->NParams > 0 ) + { + len = recv(Client->Socket, hdr->Params, hdr->NParams*sizeof(tRequestValue), 0); + Log_Debug("Server", "%i bytes of params", len); + if( len != hdr->NParams*sizeof(tRequestValue) ) { + // Oops. + } + } + else + { + Log_Debug("Server", "No params?"); } // Get buffer size diff --git a/AcessNative/ld-acess_src/Makefile b/AcessNative/ld-acess_src/Makefile index af7f8c86..419e47db 100644 --- a/AcessNative/ld-acess_src/Makefile +++ b/AcessNative/ld-acess_src/Makefile @@ -20,7 +20,7 @@ endif CFLAGS += -Wall CFLAGS += -Werror -CFLAGS += -g +CFLAGS += -g -O2 CPPFLAGS += -DARCHDIR_is_x86_64=1 LDFLAGS += -g -Wl,-T,obj-$(PLATFORM)/link.ld @@ -36,6 +36,7 @@ clean: $(BIN): obj-$(PLATFORM)/link.ld $(OBJ) $(CC) $(LDFLAGS) -o $@ $(OBJ) + objdump -S $@ > $@.dsm obj-$(PLATFORM)/%.o: %.c @mkdir -p $(dir $@) @@ -47,7 +48,7 @@ obj-$(PLATFORM)/%.o: %.c obj-lin/link.ld: @mkdir -p $(dir $@) @echo "Making Linker Script ($@)" - $(LD) --verbose | awk '{ if( substr($$0,0,5) == "====="){ bPrint = !bPrint; } else { if(bPrint){ print $$0;} } }' | sed 's/\b0x[048][0-9]*\b/$(LINKADDR)/g' | sed 's/CONSTANT (MAXPAGESIZE)/0x1000/g' > $@ + $(LD) -g --verbose | awk '{ if( substr($$1,0,5) == "====="){ bPrint = !bPrint; } else { if(bPrint){ print $$0;} } }' | sed 's/\b0x[048][0-9]*\b/$(LINKADDR)/g' | sed 's/CONSTANT (MAXPAGESIZE)/0x1000/g' > $@ -include $(DEPFILES) diff --git a/AcessNative/ld-acess_src/request.c b/AcessNative/ld-acess_src/request.c index 12a26d1a..7a9b3b39 100644 --- a/AcessNative/ld-acess_src/request.c +++ b/AcessNative/ld-acess_src/request.c @@ -122,6 +122,7 @@ int _InitSyscalls(void) { tRequestAuthHdr auth; auth.pid = giSyscall_ClientID; + auth.key = 0; SendData(&auth, sizeof(auth)); int len = ReadData(&auth, sizeof(auth), 5); if( len == 0 ) { -- 2.20.1