Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: Omair Javaid <omair.javaid@linaro.org>
Cc: GDB Patches <gdb-patches@sourceware.org>,
	Pedro Alves <palves@redhat.com>,
	Philipp Rudo <prudo@linux.ibm.com>,
	Andreas Arnez <arnez@linux.vnet.ibm.com>,
	Peter Griffin <peter.griffin@linaro.org>,
	Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
	Kieran Bingham <kieran@linuxembedded.co.uk>
Subject: Re: [RFC PATCH 0/6] Support for Linux kernel thread aware debug
Date: Mon, 04 Feb 2019 17:52:00 -0000	[thread overview]
Message-ID: <eee41c6e-1c5f-2929-d42a-9845351602ff@FreeBSD.org> (raw)
In-Reply-To: <CANW4E-3M0YwrNnaujP5DNDD50JR3YLZJTx8pHMOAgbw1DNuXPQ@mail.gmail.com>

On 2/4/19 1:12 AM, Omair Javaid wrote:
> On Tue, 29 Jan 2019 at 22:30, John Baldwin <jhb@freebsd.org> wrote:
>>
>> On 1/28/19 9:03 PM, Omair Javaid wrote:
>>> This patch series implements linux kernel target which allows linux kernel
>>> tasks to be viewed as GDB threads. We have had multiple set of patches
>>> submitted over last few years aiming to insert add-ons into GDB for debugging
>>> Linux kernel. This patch series builds on top of Linux kernel infrastructure
>>> submitted by Philipp Rudo in his various sets of patches aiming to debug
>>> Linux kernel dumps.
>>
>> I just have one minor suggestion / comment about file names.  I maintain
>> FreeBSD kernel patches for gdb out-of-tree (for various reasons), and those
>> patches use some similar things (e.g. a different OSABI).  My comment has
>> to do with the filenames.  Other osabi-specific files tend to use more
>> verbose names such as 'linux-arm-nat.c'.  I wonder if it makes sense to
>> spell out linux here as well.  I have been using 'arm-fbsd-kern.c' as a
>> complement to 'arm-fbsd-tdep.c' for the kernel gdbarch.  The architecture
>> independent files follow the patter 'fbsd-k*.c' (e.g. fbsd-kld.c for modules
>> and fbsd-kthr.c for thread enumeration), but I would be happy to move those
>> to something like 'fbsd-kern-ld.c' and 'fbsd-kern-thr.c'.  For your current
>> patchset that might mean something like 'linux-kern-tdep.c' instead of
>> 'lk-tdep.c'.  I would also be fine with 'arm-linux-kern-tdep.c' instead of
>> 'arm-linux-kern.c' perhaps if other folks feel like that is more consistent.
> 
> Hi John,
> 
> Andreas has aptly described the reason behind choosing the
> nomenclature of new linux kernel specific files as it is right now and
> i am open to any suggestion that my come up during reviews.

Ok.  I'm not firmly tied to a specific naming scheme, and I'll defer to
whatever the global maintainers prefer.

> Also I was wondering if you can share details of kernel debugging
> features which has implemented in your out of tree FreeBSD patches for
> GDB. Also share some insight on ways to test this patchset.

So I don't have any formalized testing. :-/  For testing cross-debug of
crash dumps I modified the libkvm library in FreeBSD's base system to
support reading the kernel crash dump format of other architectures and
can then generate a crash dump in a VM / qemu instance and copy it to a
64-bit x86 host to examine against a sysroot.  However, most of my testing
is just by using the kernel target as most of my work is FreeBSD kernel
and userland stuff, so I exercise it that way.  I do have various gdb scripts
(still written in the ancient gdb script language from gdb 6.x rather than
python) at github.com/bsdjhb/kdbg/tree/master/gdb  They aren't generally
useful on other kernels though and are specific to FreeBSD.

In terms of features, the current FreeBSD patches support most FreeBSD
architectures (sparc64 is untested and I haven't gotten stack traces on
ppc to work right, though I think I can reuse what I just did for risc-v
to fix ppc at some point).  A few years ago I reworked the libkvm library
in FreeBSD to support cross-debugging of crashdumps, so you can generally
cross-debug crashdumps on FreeBSD.  Currently this only works on a FreeBSD
host because I haven't pulled out a portable version of libkvm that could
be compiled on a non-FreeBSD host yet.  It does support kernel modules by
reusing the shared library interface.  This is implemented by having a
custom set of solib_ops that get attached to the kernel-specific gdbarch
during that OSABI's init handler.  It has some custom commands that are
wrappers around 'thread N' that let you switch to a thread by process ID
or kernel thread ID.  The main things it requires of each architecture are
a method for populating a regcache from a kernel thread register state
('struct pcb' on FreeBSD), and custom frame unwinders to walk across
exception frames on the stack.  Currently these are marked as signal frames
so that GDB will unwind across them ok when you have a page fault in the
kernel due to a NULL function pointer (other frame unwinders stop unwinding
when they see a NULL pc, but signal frames can keep unwinding past those).

I gave a talk a couple of years ago at a BSD conference about GDB that
includes some kgdb slides.  You can see the slides at
https://people.freebsd.org/~jhb/papers/bsdcan/2016/slides.pdf if that is
helpful.

-- 
John Baldwin

                                                                            


  reply	other threads:[~2019-02-04 17:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29  5:03 Omair Javaid
2019-01-29  5:03 ` [RFC PATCH 1/6] Convert substitute_path_component to C++ Omair Javaid
2019-01-29  5:03 ` [RFC PATCH 2/6] Add libiberty/concat styled concat_path function Omair Javaid
2019-01-29  5:03 ` [RFC PATCH 3/6] Add scoped_restore_regcache_ptid Omair Javaid
2019-01-29  5:04 ` [RFC PATCH 6/6] Linux kernel thread awareness AArch64 target support Omair Javaid
2019-01-29  5:04 ` [RFC PATCH 4/6] Linux kernel debug infrastructure and target Linux kernel Omair Javaid
2019-01-29 17:50   ` John Baldwin
2019-01-31 11:43     ` Philipp Rudo
2019-01-31 16:14   ` Philipp Rudo
2019-02-04  9:35     ` Omair Javaid
2019-02-05 14:15       ` Philipp Rudo
2019-02-08  8:53         ` Omair Javaid
2019-01-29  5:04 ` [RFC PATCH 5/6] Linux kernel thread awareness Arm target support Omair Javaid
     [not found] ` <6c29e316-f1cb-ee65-bc0b-844cba5d74ad@FreeBSD.org>
2019-01-30 15:02   ` [RFC PATCH 0/6] Support for Linux kernel thread aware debug Andreas Arnez
2019-02-04  9:13   ` Omair Javaid
2019-02-04 17:52     ` John Baldwin [this message]
2019-02-08  8:54       ` Omair Javaid
2019-03-07 11:50         ` Omair Javaid

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=eee41c6e-1c5f-2929-d42a-9845351602ff@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=arnez@linux.vnet.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=kieran@linuxembedded.co.uk \
    --cc=omair.javaid@linaro.org \
    --cc=palves@redhat.com \
    --cc=peter.griffin@linaro.org \
    --cc=prudo@linux.ibm.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