public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 00/20] Add gdb python scripts as kernel debugging helpers
@ 2013-01-29 12:37 Jan Kiszka
  2013-01-29 12:37 ` [PATCH v5 14/20] scripts/gdb: Add internal helper and convenience function to retrieve thread_info Jan Kiszka
  2013-01-29 14:15 ` [PATCH v5 00/20] Add gdb python scripts as kernel debugging helpers Borislav Petkov
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Kiszka @ 2013-01-29 12:37 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel
  Cc: Jason Wessel, kgdb-bugreport, Andi Kleen, Tom Tromey,
	Ben Widawsky, Borislav Petkov, David S. Miller, Fenghua Yu,
	Kay Sievers, linux-doc, linux-ia64, linux-kbuild, Michal Marek,
	Rob Landley, sparclinux, Tony Luck

Version 5 comes with the following changes:
 - moved tutorial into Documentation/gdb-kernel-debugging.txt
 - improved caching of gdb.Type objects, ensure they are in sync with
   currently loaded symbols
 - added new functions and commands
    - lx_module -- Find module by name and return the module variable
    - lx_modvar -- Return global variable of a module
    - lx-lsmod -- List currently loaded modules

See http://lkml.indiana.edu/hypermail/linux/kernel/1210.0/01598.html for
the original description and

    git://git.kiszka.org/linux.git queues/gdb-scripts

for the latest version.

Jan

CC: "David S. Miller" <davem@davemloft.net>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: Kay Sievers <kay@vrfy.org>
CC: linux-doc@vger.kernel.org
CC: linux-ia64@vger.kernel.org
CC: linux-kbuild@vger.kernel.org
CC: Michal Marek <mmarek@suse.cz>
CC: Rob Landley <rob@landley.net>
CC: sparclinux@vger.kernel.org
CC: Tony Luck <tony.luck@intel.com>

Jan Kiszka (20):
  scripts/gdb: Add infrastructure
  scripts/gdb: Add cache for type objects
  scripts/gdb: Add container_of helper and convenience function
  scripts/gdb: Add module iteration helper
  scripts/gdb: Add lx-symbols command
  scripts/gdb: Add internal helper and convenience function to look up
    a module
  scripts/gdb: Add lx_modvar convenience function
  scripts/gdb: Add get_target_endianness helper
  scripts/gdb: Add read_u16/32/64 helpers
  scripts/gdb: Add lx-dmesg command
  scripts/gdb: Add task iteration helper
  scripts/gdb: Add helper and convenience function to look up tasks
  scripts/gdb: Add is_target_arch helper
  scripts/gdb: Add internal helper and convenience function to retrieve
    thread_info
  scripts/gdb: Add get_gdbserver_type helper
  scripts/gdb: Add internal helper and convenience function for per-cpu
    lookup
  scripts/gdb: Add lx_current convenience function
  scripts/gdb: Add helper to iterate over CPU masks
  scripts/gdb: Add lx-lsmod command
  scripts/gdb: Add basic documentation

 Documentation/gdb-kernel-debugging.txt |  155 +++++++++++++++++++++++++++++++
 Makefile                               |    5 +-
 scripts/Makefile                       |    3 +-
 scripts/gdb/Makefile                   |    9 ++
 scripts/gdb/dmesg.py                   |   63 +++++++++++++
 scripts/gdb/module.py                  |  149 ++++++++++++++++++++++++++++++
 scripts/gdb/percpu.py                  |  110 ++++++++++++++++++++++
 scripts/gdb/symbols.py                 |  147 +++++++++++++++++++++++++++++
 scripts/gdb/task.py                    |   99 ++++++++++++++++++++
 scripts/gdb/utils.py                   |  158 ++++++++++++++++++++++++++++++++
 scripts/gdb/vmlinux-gdb.py             |   29 ++++++
 11 files changed, 925 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/gdb-kernel-debugging.txt
 create mode 100644 scripts/gdb/Makefile
 create mode 100644 scripts/gdb/dmesg.py
 create mode 100644 scripts/gdb/module.py
 create mode 100644 scripts/gdb/percpu.py
 create mode 100644 scripts/gdb/symbols.py
 create mode 100644 scripts/gdb/task.py
 create mode 100644 scripts/gdb/utils.py
 create mode 100644 scripts/gdb/vmlinux-gdb.py

-- 
1.7.3.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v5 14/20] scripts/gdb: Add internal helper and convenience function to retrieve thread_info
  2013-01-29 12:37 [PATCH v5 00/20] Add gdb python scripts as kernel debugging helpers Jan Kiszka
@ 2013-01-29 12:37 ` Jan Kiszka
  2013-01-29 13:59   ` [PATCH v5 14/20] scripts/gdb: Add internal helper and convenience function to retrieve thread_in Borislav Petkov
  2013-01-29 14:15 ` [PATCH v5 00/20] Add gdb python scripts as kernel debugging helpers Borislav Petkov
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Kiszka @ 2013-01-29 12:37 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel
  Cc: Jason Wessel, kgdb-bugreport, Andi Kleen, Tom Tromey,
	Ben Widawsky, Borislav Petkov, Tony Luck, Fenghua Yu, linux-ia64

Add the internal helper get_thread_info that calculated the thread_info
from a given task variable. Also export this service as a convenience
function.

Note: ia64 version is untested.

CC: Tony Luck <tony.luck@intel.com>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: linux-ia64@vger.kernel.org
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 scripts/gdb/task.py |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/scripts/gdb/task.py b/scripts/gdb/task.py
index fe42eb0..8e96238 100644
--- a/scripts/gdb/task.py
+++ b/scripts/gdb/task.py
@@ -62,3 +62,38 @@ class LxTaskByPidFunc(gdb.Function):
 			raise gdb.GdbError("No task of PID " + str(pid))
 
 LxTaskByPidFunc()
+
+
+thread_info_type = CachedType("struct thread_info")
+
+ia64_task_size = None
+
+def get_thread_info(task):
+	global thread_info_type
+	thread_info_ptr_type = thread_info_type.get_type().pointer()
+	if is_target_arch("ia64"):
+		global ia64_task_size
+		if ia64_task_size = None:
+			ia64_task_size = gdb.parse_and_eval(
+						"sizeof(struct task_struct)")
+		thread_info_addr = task.address + ia64_task_size
+		thread_info = thread_info_addr.cast(thread_info_ptr_type)
+	else:
+		thread_info = task['stack'].cast(thread_info_ptr_type)
+	return thread_info.dereference()
+
+
+class LxThreadInfoFunc (gdb.Function):
+	# Calculate Linux thread_info from task variable.
+	__doc__ = "Calculate Linux thread_info from task variable.\n" \
+		  "\n" \
+		  "$lx_thread_info(TASK): Given TASK, return the corresponding thread_info\n" \
+		  "variable."
+
+	def __init__(self):
+		super(LxThreadInfoFunc, self).__init__("lx_thread_info")
+
+	def invoke(self, task):
+		return get_thread_info(task)
+
+LxThreadInfoFunc()
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v5 14/20] scripts/gdb: Add internal helper and convenience function to retrieve thread_in
  2013-01-29 12:37 ` [PATCH v5 14/20] scripts/gdb: Add internal helper and convenience function to retrieve thread_info Jan Kiszka
@ 2013-01-29 13:59   ` Borislav Petkov
  0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2013-01-29 13:59 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: Andrew Morton, linux-kernel, Jason Wessel, kgdb-bugreport,
	Andi Kleen, Tom Tromey, Ben Widawsky, Tony Luck, Fenghua Yu,
	linux-ia64

On Tue, Jan 29, 2013 at 01:37:57PM +0100, Jan Kiszka wrote:
> Add the internal helper get_thread_info that calculated the thread_info
> from a given task variable. Also export this service as a convenience
> function.
> 
> Note: ia64 version is untested.
> 
> CC: Tony Luck <tony.luck@intel.com>
> CC: Fenghua Yu <fenghua.yu@intel.com>
> CC: linux-ia64@vger.kernel.org
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---

[ … ]

> +class LxThreadInfoFunc (gdb.Function):
> +	# Calculate Linux thread_info from task variable.
> +	__doc__ = "Calculate Linux thread_info from task variable.\n" \
> +		  "\n" \
> +		  "$lx_thread_info(TASK): Given TASK, return the corresponding thread_info\n" \
> +		  "variable."
> +
> +	def __init__(self):
> +		super(LxThreadInfoFunc, self).__init__("lx_thread_info")
> +
> +	def invoke(self, task):
> +		return get_thread_info(task)
> +
> +LxThreadInfoFunc()

Nice, you can plug commands into one-another:

(gdb) p $lx_thread_info($lx_current())
$12 = {task = 0xffffffff81a14440, exec_domain = 0xffffffff81a21e00, flags = 0, status = 0, cpu = 0, 
  preempt_count = 1, addr_limit = {seg = 18446744073709551615}, restart_block = {
    fn = 0xffffffff81054cd0 <do_no_restart_syscall>, {futex = {uaddr = 0x0, val = 0, flags = 0, bitset = 0, 
        time = 0, uaddr2 = 0x0}, nanosleep = {clockid = 0, rmtp = 0x0, compat_rmtp = 0x0, expires = 0}, 
      poll = {ufds = 0x0, nfds = 0, has_timeout = 0, tv_sec = 0, tv_nsec = 0}}}, sysenter_return = 0x0, 
  sig_on_uaccess_error = 0, uaccess_err = 0}

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v5 00/20] Add gdb python scripts as kernel debugging helpers
  2013-01-29 12:37 [PATCH v5 00/20] Add gdb python scripts as kernel debugging helpers Jan Kiszka
  2013-01-29 12:37 ` [PATCH v5 14/20] scripts/gdb: Add internal helper and convenience function to retrieve thread_info Jan Kiszka
@ 2013-01-29 14:15 ` Borislav Petkov
  1 sibling, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2013-01-29 14:15 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: Andrew Morton, linux-kernel, Jason Wessel, kgdb-bugreport,
	Andi Kleen, Tom Tromey, Ben Widawsky, David S. Miller, Fenghua Yu,
	Kay Sievers, linux-doc, linux-ia64, linux-kbuild, Michal Marek,
	Rob Landley, sparclinux, Tony Luck

On Tue, Jan 29, 2013 at 01:37:43PM +0100, Jan Kiszka wrote:
> Version 5 comes with the following changes:
>  - moved tutorial into Documentation/gdb-kernel-debugging.txt
>  - improved caching of gdb.Type objects, ensure they are in sync with
>    currently loaded symbols
>  - added new functions and commands
>     - lx_module -- Find module by name and return the module variable
>     - lx_modvar -- Return global variable of a module
>     - lx-lsmod -- List currently loaded modules
> 
> See http://lkml.indiana.edu/hypermail/linux/kernel/1210.0/01598.html for
> the original description and
> 
>     git://git.kiszka.org/linux.git queues/gdb-scripts
> 
> for the latest version.

Ok, I've seldomly shown any feelings when acking a patch{,set} besides
maybe "hm, ok, fine" but this patchset is very very cool and it is an
enormous fun playing with it.

So maybe this is the most enthusiasm I've shown sofar:

Emphatically-acked-by: Borislav Petkov <bp@suse.de>

Thanks Jan, very good work!

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-01-29 14:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-29 12:37 [PATCH v5 00/20] Add gdb python scripts as kernel debugging helpers Jan Kiszka
2013-01-29 12:37 ` [PATCH v5 14/20] scripts/gdb: Add internal helper and convenience function to retrieve thread_info Jan Kiszka
2013-01-29 13:59   ` [PATCH v5 14/20] scripts/gdb: Add internal helper and convenience function to retrieve thread_in Borislav Petkov
2013-01-29 14:15 ` [PATCH v5 00/20] Add gdb python scripts as kernel debugging helpers Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox