linux-debuggers.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amal Raj T <tjarlama@gmail.com>
To: danielt@kernel.org, dianders@chromium.org,
	jason.wessel@windriver.com, stephen.s.brennan@oracle.com
Cc: tjarlama@gmail.com, amalrajt@meta.com, osandov@osandov.com,
	linux-debuggers@vger.kernel.org, linux-serial@vger.kernel.org,
	kgdb-bugreport@lists.sourceforge.net
Subject: [PATCH v2 3/3] kgdb: Add command linux.vmcoreinfo to kgdb
Date: Wed, 11 Dec 2024 07:39:55 -0800	[thread overview]
Message-ID: <20241211153955.33518-4-tjarlama@gmail.com> (raw)
In-Reply-To: <20241211153955.33518-1-tjarlama@gmail.com>

From: Amal Raj T <amalrajt@meta.com>

Add a new query `linux.vmcoreinfo` to kgdb that returns
vmcoreinfo to the client using the mem2ebin encoding.
Maximum size of output buffer is set to 3X the maximum
size of VMCOREINFO_BYTES (kgdb_mem2ebin() requires 1x
for the temporary copy plus up to 2x for the escaped
data).

Signed-off-by: Amal Raj T <amalrajt@meta.com>
---
 kernel/debug/gdbstub.c | 10 +++++++++-
 lib/Kconfig.kgdb       |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
index 6198d2eb49c4..5bec444fc6d3 100644
--- a/kernel/debug/gdbstub.c
+++ b/kernel/debug/gdbstub.c
@@ -34,13 +34,14 @@
 #include <linux/uaccess.h>
 #include <asm/cacheflush.h>
 #include <linux/unaligned.h>
+#include <linux/vmcore_info.h>
 #include "debug_core.h"
 
 #define KGDB_MAX_THREAD_QUERY 17
 
 /* Our I/O buffers. */
 static char			remcom_in_buffer[BUFMAX];
-static char			remcom_out_buffer[BUFMAX];
+static char			remcom_out_buffer[MAX(VMCOREINFO_BYTES*3, BUFMAX)];
 static int			gdbstub_use_prev_in_buf;
 static int			gdbstub_prev_in_buf_pos;
 
@@ -768,6 +769,13 @@ static void gdb_cmd_query(struct kgdb_state *ks)
 		*(--ptr) = '\0';
 		break;
 
+	case 'l':
+		if (memcmp(remcom_in_buffer + 1, "linux.vmcoreinfo", 16) == 0) {
+			remcom_out_buffer[0] = 'Q';
+			kgdb_mem2ebin(vmcoreinfo_data, remcom_out_buffer + 1, vmcoreinfo_size);
+		}
+		break;
+
 	case 'C':
 		/* Current thread id */
 		strcpy(remcom_out_buffer, "QC");
diff --git a/lib/Kconfig.kgdb b/lib/Kconfig.kgdb
index 537e1b3f5734..012529eee79e 100644
--- a/lib/Kconfig.kgdb
+++ b/lib/Kconfig.kgdb
@@ -12,6 +12,7 @@ menuconfig KGDB
 	bool "KGDB: kernel debugger"
 	depends on HAVE_ARCH_KGDB
 	depends on DEBUG_KERNEL
+	select VMCORE_INFO
 	help
 	  If you say Y here, it will be possible to remotely debug the
 	  kernel using gdb.  It is recommended but not required, that
-- 
2.43.5


  parent reply	other threads:[~2024-12-11 15:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <gmail>
2024-12-10 13:34 ` [PATCH 0/3] Add a new command in kgdb for vmcoreinfo Amal Raj T
2024-12-10 13:34   ` [PATCH 1/3] kgdb: Add kgdb_mem2ebin function for converting memory to binary format Amal Raj T
2024-12-10 13:34   ` [PATCH 2/3] serial: Move LF -> CRLF replacement from serial console to kdb Amal Raj T
2024-12-10 15:16     ` Daniel Thompson
2024-12-11 15:40       ` Amal
2024-12-10 13:34   ` [PATCH 3/3] kgdb: Add command linux.vmcoreinfo to kgdb Amal Raj T
2024-12-11 15:39 ` [PATCH v2 0/3] Add a new command in kgdb for vmcoreinfo Amal Raj T
2024-12-11 15:39   ` [PATCH v2 1/3] kgdb: Add kgdb_mem2ebin function for converting memory to binary format Amal Raj T
2024-12-13  0:55     ` Doug Anderson
     [not found]       ` <CAOfKSRMBYp6dSbhRqQXm09QUoJTaLjQr0XFqzqGVGeJ-KKoMuQ@mail.gmail.com>
2025-01-24 23:17         ` Doug Anderson
2025-01-08 11:40     ` Daniel Thompson
2024-12-11 15:39   ` [PATCH v2 2/3] serial: Move LF -> CRLF replacement from serial console to kdb Amal Raj T
2024-12-13  0:55     ` Doug Anderson
2024-12-11 15:39   ` Amal Raj T [this message]
2024-12-13  0:56     ` [PATCH v2 3/3] kgdb: Add command linux.vmcoreinfo to kgdb Doug Anderson
2025-01-13 17:29 ` [PATCH v3 0/3] Add a new command in kgdb for vmcoreinfo Amal Raj T
2025-01-13 17:29   ` [PATCH v3 1/3] kgdb: Add kgdb_mem2ebin function for converting memory to binary format Amal Raj T
2025-01-13 20:38     ` Stephen Brennan
2025-01-13 17:29   ` [PATCH v3 2/3] kgdb: Add command linux.vmcoreinfo to kgdb Amal Raj T
2025-01-13 23:24     ` Stephen Brennan
2025-01-13 17:29   ` [PATCH v3 2/3] serial: Move LF -> CRLF replacement from serial console to kdb Amal Raj T
2025-01-13 21:29     ` Stephen Brennan
2025-01-24 22:55     ` Doug Anderson
2025-01-13 17:29   ` [PATCH v3 3/3] kgdb: Add command linux.vmcoreinfo to kgdb Amal Raj T
2025-01-13 23:22     ` Stephen Brennan
2025-01-14 21:18       ` Stephen Brennan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241211153955.33518-4-tjarlama@gmail.com \
    --to=tjarlama@gmail.com \
    --cc=amalrajt@meta.com \
    --cc=danielt@kernel.org \
    --cc=dianders@chromium.org \
    --cc=jason.wessel@windriver.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-debuggers@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=osandov@osandov.com \
    --cc=stephen.s.brennan@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).