Skip to contentSkip to conversation

kdb: Simplify kdb commands registration

PATCH Daniel Thompson 2 participants 4 messages Feb 8, 2021 – Feb 9, 2021 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 19 lines · Sumit Garg
(quoted diff) +0 -15
@@ -1011,25 +1005,17 @@ int kdb_parse(const char *cmdstr)
 		++argv[0];
 	}
 
-	for_each_kdbcmd(tp, i) {
-		if (tp->cmd_name) {
-			/*
-			 * If this command is allowed to be abbreviated,
-			 * check to see if this is it.
-			 */
-
-			if (tp->cmd_minlen
-			 && (strlen(argv[0]) <= tp->cmd_minlen)) {
-				if (strncmp(argv[0],
-					    tp->cmd_name,
-					    tp->cmd_minlen) == 0) {
-					break;
-				}
-			}

Review int kdb_parse(const char *cmdstr) · line 1015

Quoted 10 lines
(quoted diff) +7 -2
-
-			if (strcmp(argv[0], tp->cmd_name) == 0)
+	list_for_each_entry(tp, &kdb_cmds_head, list_node) {
+		/*
+		 * If this command is allowed to be abbreviated,
+		 * check to see if this is it.
+		 */
+		if (tp->cmd_minlen && (strlen(argv[0]) <= tp->cmd_minlen) &&
+		    (strncmp(argv[0], tp->cmd_name, tp->cmd_minlen) == 0))
 				break;

Looks like you forgot to unindent this line.

I will fix it up but... checkpatch would have found this.

Daniel.

#2 lore raw
Quoted 34 lines · Daniel Thompson
Quoted 19 lines · Sumit Garg
(quoted diff) +0 -15
@@ -1011,25 +1005,17 @@ int kdb_parse(const char *cmdstr)
              ++argv[0];
      }
 
-     for_each_kdbcmd(tp, i) {
-             if (tp->cmd_name) {
-                     /*
-                      * If this command is allowed to be abbreviated,
-                      * check to see if this is it.
-                      */
-
-                     if (tp->cmd_minlen
-                      && (strlen(argv[0]) <= tp->cmd_minlen)) {
-                             if (strncmp(argv[0],
-                                         tp->cmd_name,
-                                         tp->cmd_minlen) == 0) {
-                                     break;
-                             }
-                     }

Review int kdb_parse(const char *cmdstr) · line 1015

Quoted 10 lines
(quoted diff) +7 -2
-
-                     if (strcmp(argv[0], tp->cmd_name) == 0)
+     list_for_each_entry(tp, &kdb_cmds_head, list_node) {
+             /*
+              * If this command is allowed to be abbreviated,
+              * check to see if this is it.
+              */
+             if (tp->cmd_minlen && (strlen(argv[0]) <= tp->cmd_minlen) &&
+                 (strncmp(argv[0], tp->cmd_name, tp->cmd_minlen) == 0))
                              break;

Looks like you forgot to unindent this line.

Quoted 2 lines

I will fix it up but... checkpatch would have found this.

Ah, I missed to run checkpatch on v3. Thanks for fixing this up.

-Sumit

Quoted 2 lines

Daniel.

#3 lore raw
Quoted 35 lines · Sumit Garg
Quoted 34 lines · Daniel Thompson
Quoted 19 lines · Sumit Garg
(quoted diff) +0 -15
@@ -1011,25 +1005,17 @@ int kdb_parse(const char *cmdstr)
              ++argv[0];
      }
 
-     for_each_kdbcmd(tp, i) {
-             if (tp->cmd_name) {
-                     /*
-                      * If this command is allowed to be abbreviated,
-                      * check to see if this is it.
-                      */
-
-                     if (tp->cmd_minlen
-                      && (strlen(argv[0]) <= tp->cmd_minlen)) {
-                             if (strncmp(argv[0],
-                                         tp->cmd_name,
-                                         tp->cmd_minlen) == 0) {
-                                     break;
-                             }
-                     }

Review int kdb_parse(const char *cmdstr) · line 1015

Quoted 10 lines
(quoted diff) +7 -2
-
-                     if (strcmp(argv[0], tp->cmd_name) == 0)
+     list_for_each_entry(tp, &kdb_cmds_head, list_node) {
+             /*
+              * If this command is allowed to be abbreviated,
+              * check to see if this is it.
+              */
+             if (tp->cmd_minlen && (strlen(argv[0]) <= tp->cmd_minlen) &&
+                 (strncmp(argv[0], tp->cmd_name, tp->cmd_minlen) == 0))
                              break;

Looks like you forgot to unindent this line.

Quoted 4 lines
Quoted 2 lines

I will fix it up but... checkpatch would have found this.

Ah, I missed to run checkpatch on v3. Thanks for fixing this up.

Unfortunately, it's not just checkpatch. This patch also causes a large number of test suite regressions. In particular it looks like kgdbwait does not work with this patch applied.

The problem occurs on multiple architectures all with close-to-defconfig kernels. However to share one specific failure, x86_64_defconfig plus the following is not bootable:

    ../scripts/config --enable DEBUG_INFO --enable DEBUG_FS \
      --enable KALLSYMS_ALL --enable MAGIC_SYSRQ --enable KGDB \
      --enable KGDB_TESTS --enable KGDB_KDB --enable KDB_KEYBOARD \
      --enable LKDTM

Try:

    qemu-system-x86_64 \
      -enable-kvm -m 1G -smp 2 -nographic
      -kernel arch/x86/boot/bzImage \
      -append "console=ttyS0,115200 kgdboc=ttyS0 kgdbwait"

Daniel.

#4 lore raw
Quoted 55 lines · Daniel Thompson
Quoted 35 lines · Sumit Garg
Quoted 34 lines · Daniel Thompson
Quoted 19 lines · Sumit Garg
(quoted diff) +0 -15
@@ -1011,25 +1005,17 @@ int kdb_parse(const char *cmdstr)
              ++argv[0];
      }
 
-     for_each_kdbcmd(tp, i) {
-             if (tp->cmd_name) {
-                     /*
-                      * If this command is allowed to be abbreviated,
-                      * check to see if this is it.
-                      */
-
-                     if (tp->cmd_minlen
-                      && (strlen(argv[0]) <= tp->cmd_minlen)) {
-                             if (strncmp(argv[0],
-                                         tp->cmd_name,
-                                         tp->cmd_minlen) == 0) {
-                                     break;
-                             }
-                     }

Review int kdb_parse(const char *cmdstr) · line 1015

Quoted 10 lines
(quoted diff) +7 -2
-
-                     if (strcmp(argv[0], tp->cmd_name) == 0)
+     list_for_each_entry(tp, &kdb_cmds_head, list_node) {
+             /*
+              * If this command is allowed to be abbreviated,
+              * check to see if this is it.
+              */
+             if (tp->cmd_minlen && (strlen(argv[0]) <= tp->cmd_minlen) &&
+                 (strncmp(argv[0], tp->cmd_name, tp->cmd_minlen) == 0))
                              break;

Looks like you forgot to unindent this line.

Quoted 4 lines
Quoted 2 lines

I will fix it up but... checkpatch would have found this.

Ah, I missed to run checkpatch on v3. Thanks for fixing this up.

Unfortunately, it's not just checkpatch. This patch also causes a large number of test suite regressions. In particular it looks like kgdbwait does not work with this patch applied.

The problem occurs on multiple architectures all with close-to-defconfig kernels. However to share one specific failure, x86_64_defconfig plus the following is not bootable:

    ../scripts/config --enable DEBUG_INFO --enable DEBUG_FS \
      --enable KALLSYMS_ALL --enable MAGIC_SYSRQ --enable KGDB \
      --enable KGDB_TESTS --enable KGDB_KDB --enable KDB_KEYBOARD \
      --enable LKDTM
Quoted 7 lines

Try:

    qemu-system-x86_64 \
      -enable-kvm -m 1G -smp 2 -nographic
      -kernel arch/x86/boot/bzImage \
      -append "console=ttyS0,115200 kgdboc=ttyS0 kgdbwait"

Thanks Daniel for this report. I am able to reproduce it with "kgdbwait" and will investigate it.

-Sumit

Quoted 2 lines

Daniel.