[PATCH] libdebugger: Fixes to debugging, ARM support, locking, and gcc-7.1 warnings.

2017-08-13 Thread Chris Johns
- Add `printk` support to aid multi-core debugging.
- Add lock trace to aid lock debugging.
- Fixes to gcc-7.1 warnings.
- Fixes from ticket #2879.
- Add verbose command controls.
- Change using the RTEMS sys/lock.h API to manage exception threads.
- ARM hardware breakpoint fixes. Support for SMP stepping
  is not implemented, this requires use of the context id
  register.

Closes #2879.
---
 cpukit/libdebugger/rtems-debugger-arm.c| 245 -
 cpukit/libdebugger/rtems-debugger-block.c  |   3 +-
 cpukit/libdebugger/rtems-debugger-block.h  |   3 +-
 cpukit/libdebugger/rtems-debugger-cmd.c|  21 ++-
 cpukit/libdebugger/rtems-debugger-i386.c   |   3 +-
 cpukit/libdebugger/rtems-debugger-remote-tcp.c |   3 +-
 cpukit/libdebugger/rtems-debugger-remote-tcp.h |   3 +-
 cpukit/libdebugger/rtems-debugger-remote.c |   3 +-
 cpukit/libdebugger/rtems-debugger-remote.h |   3 +-
 cpukit/libdebugger/rtems-debugger-server.c | 232 +++
 cpukit/libdebugger/rtems-debugger-server.h |  35 ++--
 cpukit/libdebugger/rtems-debugger-target.c | 126 -
 cpukit/libdebugger/rtems-debugger-target.h |  22 ++-
 cpukit/libdebugger/rtems-debugger-threads.c|  61 +++---
 cpukit/libdebugger/rtems-debugger-threads.h|  16 +-
 15 files changed, 466 insertions(+), 313 deletions(-)

diff --git a/cpukit/libdebugger/rtems-debugger-arm.c 
b/cpukit/libdebugger/rtems-debugger-arm.c
index 200d758a6b..6e5c9dc5ae 100644
--- a/cpukit/libdebugger/rtems-debugger-arm.c
+++ b/cpukit/libdebugger/rtems-debugger-arm.c
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2016 Chris Johns .  All rights reserved.
+ * Copyright (c) 2016-2017 Chris Johns .
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -221,13 +222,19 @@ static arm_debug_hwbreak hw_breaks[ARM_HW_BREAKPOINT_MAX];
 //static arm_debug_hwbreak hw_watches[ARM_HW_WATCHPOINT_MAX];
 
 #if TARGET_DEBUG
+void rtems_debugger_printk_lock(rtems_interrupt_lock_context* lock_context);
+void rtems_debugger_printk_unlock(rtems_interrupt_lock_context* lock_context);
+
 static void target_printk(const char* format, ...) RTEMS_PRINTFLIKE(1, 2);
 static void
 target_printk(const char* format, ...)
 {
+  rtems_interrupt_lock_context lock_context;
   va_list ap;
   va_start(ap, format);
+  rtems_debugger_printk_lock(&lock_context);
   vprintk(format, ap);
+  rtems_debugger_printk_unlock(&lock_context);
   va_end(ap);
 }
 static const char*
@@ -261,45 +268,66 @@ mode_label(int mode)
 #endif
 
 /*
- * Read and write a CP14 register.
- *
- * The software debug event registers are not easy to program because there are
- * up to 32 registers and the instructions have to assembler for each of the 32
- * registers, you cannot program it. This means there is a switch table to do
- * this.
+ * CP register access.
  */
-#define ARM_CP14_INSTR(_opc, _val, _CRn, _CRm, _opc2)   \
-  #_opc " p14, 0, %[" #_val "], c" #_CRn ", c" #_CRm ", " #_opc2 "\n"
+#define ARM_CP_INSTR(_opc, _cp, _op1, _val, _CRn, _CRm, _op2)   \
+  #_opc " p" #_cp ", " #_op1 ", %[" #_val "], c" #_CRn ", c" #_CRm ", " #_op2 
"\n"
 
-#define ARM_CP14_WRITE(_val, _CRn, _CRm, _opc2)\
+#define ARM_CP_WRITE(_cp, _op1, _val, _CRn, _CRm, _op2)\
   do { \
 ARM_SWITCH_REG;\
 asm volatile(  \
   ASM_ARM_MODE \
-  ARM_CP14_INSTR(mcr, val, _CRn, _CRm, _opc2)  \
+  ARM_CP_INSTR(mcr, _cp, _op1, val, _CRn, _CRm, _op2)  \
   ASM_THUMB_MODE   \
   : ARM_SWITCH_REG_ASM \
   : [val] "r" (_val)); \
   } while (0)
 
-#define ARM_CP14_READ(_val, _CRn, _CRm, _opc2) \
+#define ARM_CP_READ(_cp, _op1, _val, _CRn, _CRm, _op2) \
   do { \
 ARM_SWITCH_REG;\
 asm volatile(  \
   ASM_ARM_MODE \
-  ARM_CP14_INSTR(mrc, val, _CRn, _CRm, _opc2)  \
+  ARM_CP_INSTR(mrc, _cp, _op1, val, _CRn, _CRm, _op2)  \
   ASM_THUMB_MODE   \
   : ARM_SWITCH_REG_ASM,\
 [val] "=&r" (_val));   \
   } while (0)
 
+/*
+ * Read and write a CP14 register.
+ *
+ * The software debug event registers are not easy to program because there are
+ * up to 32 registers and the instructions have to assembler for each of the 32
+ * registers, you cannot program it. This means there is a switch table to do
+ * this.
+ */
+#define ARM_CP14_WRITE(_val, _C

[PATCH] libmisc/shell: Make some internal shell functions public.

2017-08-13 Thread Chris Johns
- Add 'rtems_shell_init_environment()' so a user can create the
  shell environment without needing to run a shell.
- Move 'rtems_shell_lookup_topic', 'rtems_shell_can_see_cmd',
  and 'rtems_shell_execute_cmd' from the internal interface to
  the public interface.

Closes #3096.
---
 cpukit/libmisc/shell/internal.h | 15 ---
 cpukit/libmisc/shell/shell.c| 11 +++
 cpukit/libmisc/shell/shell.h| 28 
 3 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/cpukit/libmisc/shell/internal.h b/cpukit/libmisc/shell/internal.h
index 56b1bb6077..31df89da05 100644
--- a/cpukit/libmisc/shell/internal.h
+++ b/cpukit/libmisc/shell/internal.h
@@ -11,24 +11,9 @@
 
 #include "shell.h"
 
-struct rtems_shell_topic_tt;
-typedef struct rtems_shell_topic_tt rtems_shell_topic_t;
-
-struct rtems_shell_topic_tt {
-  const char  *topic;
-  rtems_shell_topic_t *next;
-};
-
-
 extern rtems_shell_cmd_t   * rtems_shell_first_cmd;
 extern rtems_shell_topic_t * rtems_shell_first_topic;
 
-rtems_shell_topic_t * rtems_shell_lookup_topic(const char *topic);
-
-bool rtems_shell_can_see_cmd(const rtems_shell_cmd_t *shell_cmd);
-
-int rtems_shell_execute_cmd(const char *cmd, int argc, char *argv[]);
-
 extern void rtems_shell_register_monitor_commands(void);
 
 extern void rtems_shell_print_heap_info(
diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c
index e7e57933a0..5f042f5855 100644
--- a/cpukit/libmisc/shell/shell.c
+++ b/cpukit/libmisc/shell/shell.c
@@ -147,6 +147,12 @@ static void rtems_shell_init_once(void)
   "running on %m\n");
 
   rtems_shell_init_commands();
+  rtems_shell_register_monitor_commands();
+}
+
+void rtems_shell_init_environment(void)
+{
+  assert(pthread_once(&rtems_shell_once, rtems_shell_init_once) == 0);
 }
 
 /*
@@ -721,10 +727,7 @@ bool rtems_shell_main_loop(
   FILE  *stdinToClose = NULL;
   FILE  *stdoutToClose = NULL;
 
-  eno = pthread_once(&rtems_shell_once, rtems_shell_init_once);
-  assert(eno == 0);
-
-  rtems_shell_register_monitor_commands();
+  rtems_shell_init_environment();
 
   shell_env = rtems_shell_init_env(shell_env_arg);
   if (shell_env == NULL) {
diff --git a/cpukit/libmisc/shell/shell.h b/cpukit/libmisc/shell/shell.h
index 4d545d6a41..98ddf0a958 100644
--- a/cpukit/libmisc/shell/shell.h
+++ b/cpukit/libmisc/shell/shell.h
@@ -94,6 +94,14 @@ typedef struct {
   const char *alias;
 } rtems_shell_alias_t;
 
+struct rtems_shell_topic_tt;
+typedef struct rtems_shell_topic_tt rtems_shell_topic_t;
+
+struct rtems_shell_topic_tt {
+  const char  *topic;
+  rtems_shell_topic_t *next;
+};
+
 /*
  * The return value has RTEMS_SHELL_KEYS_EXTENDED set if the key
  * is extended, ie a special key.
@@ -125,6 +133,26 @@ extern int rtems_shell_make_args(
   intmax_args
 );
 
+extern rtems_shell_topic_t * rtems_shell_lookup_topic(
+  const char *topic
+);
+
+extern bool rtems_shell_can_see_cmd(
+  const rtems_shell_cmd_t *shell_cmd
+);
+
+extern int rtems_shell_execute_cmd(
+  const char *cmd, int argc, char *argv[]
+);
+
+/*
+ * Call to set up the shell environment if you need to execute commands before
+ * running a shell.
+ */
+extern void rtems_shell_init_environment(
+  void
+);
+
 extern int rtems_shell_cat_file(
   FILE *out,
   const char *name
-- 
2.13.2

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel