This is a gdbserver helper for nios2 user space application debug. It
traps to kernel to flag current process for debugging. It is imported
from Microtronix Nios II Linux v1.4 release.
Signed-off-by: Thomas Chou <[EMAIL PROTECTED]>
diff --git a/user/Kconfig b/user/Kconfig
index 2e1c81e..213ea23 100644
--- a/user/Kconfig
+++ b/user/Kconfig
@@ -2831,6 +2831,11 @@ config USER_GDBSERVER_GDBSERVER
server. (old version - mk68k targets only)
Approx. binary size: 14k
+config USER_DEBUG_DEBUG
+ bool "debug"
+ help
+ Nios2 debug application stub
+
config USER_GREP_GREP
bool "grep"
help
diff --git a/user/Makefile b/user/Makefile
index 1b3150a..c73168e 100644
--- a/user/Makefile
+++ b/user/Makefile
@@ -78,6 +78,7 @@ dir_$(CONFIG_USER_CRYPTO_TOOLS_CRYPTOKEYTEST) += crypto-tools
dir_$(CONFIG_USER_CXXTEST_CXXTEST) += cxxtest
dir_$(CONFIG_USER_DDNS3_CLIENT_DDNS3) += ddns3-client
dir_$(CONFIG_USER_DE2TSCAL_DE2TSCAL) += de2ts-cal
+dir_$(CONFIG_USER_DEBUG_DEBUG) += debug
dir_$(CONFIG_USER_DEMO_BUTTON) += demo
dir_$(CONFIG_USER_DEMO_MORSE) += demo
dir_$(CONFIG_USER_DHRYSTONE_DHRYSTONE) += dhrystone
diff --git a/user/debug/Makefile b/user/debug/Makefile
new file mode 100644
index 0000000..7fddf7d
--- /dev/null
+++ b/user/debug/Makefile
@@ -0,0 +1,11 @@
+EXEC = debug
+
+OBJS = debug.o
+
+$(EXEC): $(OBJS)
+
+romfs:
+ $(ROMFSINST) /bin/$(EXEC)
+
+clean:
+ -rm -f $(EXEC) *.elf *.gdb *.o
diff --git a/user/debug/debug.c b/user/debug/debug.c
new file mode 100644
index 0000000..7e0aab0
--- /dev/null
+++ b/user/debug/debug.c
@@ -0,0 +1,38 @@
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <asm/traps.h>
+
+void usage( void )
+{
+ fprintf( stderr, "Usage: debug <application> <args..>\n" );
+}
+
+
+
+int main( int argc, char *argv[] )
+{
+ int i;
+ if ( argc < 2 || !strcmp( argv[1], "--help" ) ) {
+ usage();
+ return 1;
+ }
+
+// printf("DEBUG: trapping to kernel to flag current process for debugging
...\n");
+ __asm__ __volatile__ ("movi r2, %0\n\t"
+ "trap"
+ :
+ :"i" (TRAP_ID_APPDEBUG)
+ :"r2");
+
+ printf( "DEBUG: running \"%s", argv[1] );
+ for(i = 2; i < argc; i++) printf( " %s", argv[i] );
+ printf( "\" ...\n" );
+
+ execvp( argv[1], &(argv[1]) );
+ printf("%s: %s\n", argv[1], (errno == ENOENT) ? "Bad command or file
name" : strerror(errno));
+ _exit(0);
+}
+
--
1.5.3.3
_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev