]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - kernel/debug/kdb/kdb_main.c
Merge branch 'master' into tk71
[mv-sheeva.git] / kernel / debug / kdb / kdb_main.c
index caf057a3de0e8457cb35e92a4b371f4f4597df3a..bd3e8e29caa37e3861a6832fd0614a0bd6d5dab4 100644 (file)
@@ -82,7 +82,7 @@ static kdbtab_t kdb_base_commands[50];
 #define for_each_kdbcmd(cmd, num)                                      \
        for ((cmd) = kdb_base_commands, (num) = 0;                      \
             num < kdb_max_commands;                                    \
-            num == KDB_BASE_CMD_MAX ? cmd = kdb_commands : cmd++, num++)
+            num++, num == KDB_BASE_CMD_MAX ? cmd = kdb_commands : cmd++)
 
 typedef struct _kdbmsg {
        int     km_diag;        /* kdb diagnostic */
@@ -646,7 +646,7 @@ static int kdb_defcmd2(const char *cmdstr, const char *argv0)
        }
        if (!s->usable)
                return KDB_NOTIMP;
-       s->command = kmalloc((s->count + 1) * sizeof(*(s->command)), GFP_KDB);
+       s->command = kzalloc((s->count + 1) * sizeof(*(s->command)), GFP_KDB);
        if (!s->command) {
                kdb_printf("Could not allocate new kdb_defcmd table for %s\n",
                           cmdstr);
@@ -1127,7 +1127,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
                /* special case below */
        } else {
                kdb_printf("\nEntering kdb (current=0x%p, pid %d) ",
-                          kdb_current, kdb_current->pid);
+                          kdb_current, kdb_current ? kdb_current->pid : 0);
 #if defined(CONFIG_SMP)
                kdb_printf("on processor %d ", raw_smp_processor_id());
 #endif
@@ -1749,13 +1749,13 @@ static int kdb_go(int argc, const char **argv)
        int nextarg;
        long offset;
 
+       if (raw_smp_processor_id() != kdb_initial_cpu) {
+               kdb_printf("go must execute on the entry cpu, "
+                          "please use \"cpu %d\" and then execute go\n",
+                          kdb_initial_cpu);
+               return KDB_BADCPUNUM;
+       }
        if (argc == 1) {
-               if (raw_smp_processor_id() != kdb_initial_cpu) {
-                       kdb_printf("go <address> must be issued from the "
-                                  "initial cpu, do cpu %d first\n",
-                                  kdb_initial_cpu);
-                       return KDB_ARGCOUNT;
-               }
                nextarg = 1;
                diag = kdbgetaddrarg(argc, argv, &nextarg,
                                     &addr, &offset, NULL);
@@ -2361,7 +2361,7 @@ static int kdb_pid(int argc, const char **argv)
  */
 static int kdb_ll(int argc, const char **argv)
 {
-       int diag;
+       int diag = 0;
        unsigned long addr;
        long offset = 0;
        unsigned long va;
@@ -2400,20 +2400,21 @@ static int kdb_ll(int argc, const char **argv)
                char buf[80];
 
                if (KDB_FLAG(CMD_INTERRUPT))
-                       return 0;
+                       goto out;
 
                sprintf(buf, "%s " kdb_machreg_fmt "\n", command, va);
                diag = kdb_parse(buf);
                if (diag)
-                       return diag;
+                       goto out;
 
                addr = va + linkoffset;
                if (kdb_getword(&va, addr, sizeof(va)))
-                       return 0;
+                       goto out;
        }
-       kfree(command);
 
-       return 0;
+out:
+       kfree(command);
+       return diag;
 }
 
 static int kdb_kgdb(int argc, const char **argv)
@@ -2603,20 +2604,17 @@ static int kdb_summary(int argc, const char **argv)
  */
 static int kdb_per_cpu(int argc, const char **argv)
 {
-       char buf[256], fmtstr[64];
-       kdb_symtab_t symtab;
-       cpumask_t suppress = CPU_MASK_NONE;
-       int cpu, diag;
-       unsigned long addr, val, bytesperword = 0, whichcpu = ~0UL;
+       char fmtstr[64];
+       int cpu, diag, nextarg = 1;
+       unsigned long addr, symaddr, val, bytesperword = 0, whichcpu = ~0UL;
 
        if (argc < 1 || argc > 3)
                return KDB_ARGCOUNT;
 
-       snprintf(buf, sizeof(buf), "per_cpu__%s", argv[1]);
-       if (!kdbgetsymval(buf, &symtab)) {
-               kdb_printf("%s is not a per_cpu variable\n", argv[1]);
-               return KDB_BADADDR;
-       }
+       diag = kdbgetaddrarg(argc, argv, &nextarg, &symaddr, NULL, NULL);
+       if (diag)
+               return diag;
+
        if (argc >= 2) {
                diag = kdbgetularg(argv[2], &bytesperword);
                if (diag)
@@ -2649,46 +2647,25 @@ static int kdb_per_cpu(int argc, const char **argv)
 #define KDB_PCU(cpu) 0
 #endif
 #endif
-
        for_each_online_cpu(cpu) {
+               if (KDB_FLAG(CMD_INTERRUPT))
+                       return 0;
+
                if (whichcpu != ~0UL && whichcpu != cpu)
                        continue;
-               addr = symtab.sym_start + KDB_PCU(cpu);
+               addr = symaddr + KDB_PCU(cpu);
                diag = kdb_getword(&val, addr, bytesperword);
                if (diag) {
                        kdb_printf("%5d " kdb_bfd_vma_fmt0 " - unable to "
                                   "read, diag=%d\n", cpu, addr, diag);
                        continue;
                }
-#ifdef CONFIG_SMP
-               if (!val) {
-                       cpu_set(cpu, suppress);
-                       continue;
-               }
-#endif /* CONFIG_SMP */
                kdb_printf("%5d ", cpu);
                kdb_md_line(fmtstr, addr,
                        bytesperword == KDB_WORD_SIZE,
                        1, bytesperword, 1, 1, 0);
        }
-       if (cpus_weight(suppress) == 0)
-               return 0;
-       kdb_printf("Zero suppressed cpu(s):");
-       for (cpu = first_cpu(suppress); cpu < num_possible_cpus();
-            cpu = next_cpu(cpu, suppress)) {
-               kdb_printf(" %d", cpu);
-               if (cpu == num_possible_cpus() - 1 ||
-                   next_cpu(cpu, suppress) != cpu + 1)
-                       continue;
-               while (cpu < num_possible_cpus() &&
-                      next_cpu(cpu, suppress) == cpu + 1)
-                       ++cpu;
-               kdb_printf("-%d", cpu);
-       }
-       kdb_printf("\n");
-
 #undef KDB_PCU
-
        return 0;
 }
 
@@ -2763,13 +2740,13 @@ int kdb_register_repeat(char *cmd,
                }
                if (kdb_commands) {
                        memcpy(new, kdb_commands,
-                              kdb_max_commands * sizeof(*new));
+                         (kdb_max_commands - KDB_BASE_CMD_MAX) * sizeof(*new));
                        kfree(kdb_commands);
                }
                memset(new + kdb_max_commands, 0,
                       kdb_command_extend * sizeof(*new));
                kdb_commands = new;
-               kp = kdb_commands + kdb_max_commands;
+               kp = kdb_commands + kdb_max_commands - KDB_BASE_CMD_MAX;
                kdb_max_commands += kdb_command_extend;
        }
 
@@ -2783,6 +2760,8 @@ int kdb_register_repeat(char *cmd,
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(kdb_register_repeat);
+
 
 /*
  * kdb_register - Compatibility register function for commands that do
@@ -2805,6 +2784,7 @@ int kdb_register(char *cmd,
        return kdb_register_repeat(cmd, func, usage, help, minlen,
                                   KDB_REPEAT_NONE);
 }
+EXPORT_SYMBOL_GPL(kdb_register);
 
 /*
  * kdb_unregister - This function is used to unregister a kernel
@@ -2823,7 +2803,7 @@ int kdb_unregister(char *cmd)
        /*
         *  find the command.
         */
-       for (i = 0, kp = kdb_commands; i < kdb_max_commands; i++, kp++) {
+       for_each_kdbcmd(kp, i) {
                if (kp->cmd_name && (strcmp(kp->cmd_name, cmd) == 0)) {
                        kp->cmd_name = NULL;
                        return 0;
@@ -2833,6 +2813,7 @@ int kdb_unregister(char *cmd)
        /* Couldn't find it.  */
        return 1;
 }
+EXPORT_SYMBOL_GPL(kdb_unregister);
 
 /* Initialize the kdb command table. */
 static void __init kdb_inittab(void)
@@ -2933,7 +2914,7 @@ static void __init kdb_cmd_init(void)
        }
 }
 
-/* Intialize kdb_printf, breakpoint tables and kdb state */
+/* Initialize kdb_printf, breakpoint tables and kdb state */
 void __init kdb_init(int lvl)
 {
        static int kdb_init_lvl = KDB_NOT_INITIALIZED;