[RFC v5 0/9] Add support for Linux kernel debugging

Philipp Rudo
2018-03-12T15:31:27Z

Hi everybody,

after a long time here is a sign of life from kernel awareness.

Originally i planed to bring the patches upstream one by one. However i'm
currently stuck on an other project. But I should find time soon to
continue here.

The main change between v4 and v5 is the C++ification of lk_low, which
required big parts of the file to be rewritten. Along with that smaller
improvements and bug fixes where made.

Changes v4 -> v5:
* Rebase to current master.

* C++-ify lk-low, i.e. replace:
- struct lk_private -> class linux_kernel_ops,
- hooks -> virtual member functions in linux_kernel_ops,
- macros -> member function of linux_kernel_ops,
- htab_t -> std::unordered_map for cached symbols,
- gdbarch_lk_init_private -> gdbarch_get_new_lk_ops,
- lk_list & lk_bitmap -> iterator class,
- const char * -> const std::string & (where possible),
- whatever I forgot, lk-low was basically rewritten.

* Add class s390_linux_kernel_ops inherited from linux_kernel_ops.

* Add GDB_OSABI_LINUX_KERNEL (patch #4). Architectures must use a
sniffer to distinguish between user- and kernel-space as in ELF both
have type Linux.

* Introduce ENUM_FLAG lk_kconfig to track config options used in
kernel and turn off features not supported by the kernel (e.g.
module support).

* Fix handling of fields defined in anonymous structs.

* Fix call to target beneath->to_fetch_registers. Adjust that
to_fetch_registers uses regcache->ptid() instead of inferior_ptid
nowadays (bcc0c096d5b et al.). Requires new patch #3.

* Fix typo in size of (s390) topdpreg.

* Fix bug in S390_LK_ROUNDUP and rename to LK_ALIGN.

* Move s390 split up to separate patch set (already pushed) and
adjust s390 code accordingly.

Thanks
Philipp

Philipp Rudo (9):
Convert substitute_path_component to C++
Add libiberty/concat styled concat_path function
Add scoped_restore_regcache_ptid
Add basic Linux kernel support
Add kernel module support for linux-kernel target
Add commands for linux-kernel target
Add privileged registers for s390x
Link frame_info to thread_info
Add S390 support for linux-kernel target

gdb/Makefile.in | 12 +
gdb/auto-load.c | 19 +-
gdb/common/common-utils.h | 11 +
gdb/configure.tgt | 9 +-
gdb/defs.h | 1 +
gdb/features/Makefile | 11 +-
gdb/features/s390-cr.xml | 26 +
gdb/features/s390x-cr-linux64.c | 99 ++++
gdb/features/s390x-cr-linux64.xml | 24 +
gdb/features/s390x-vxcr-linux64.c | 170 ++++++
gdb/features/s390x-vxcr-linux64.xml | 25 +
gdb/frame.c | 12 +
gdb/frame.h | 2 +
gdb/gdbarch.c | 32 ++
gdb/gdbarch.h | 9 +
gdb/gdbarch.sh | 4 +
gdb/lk-bitmap.h | 226 ++++++++
gdb/lk-cmds.c | 254 +++++++++
gdb/lk-cmds.h | 25 +
gdb/lk-list.h | 201 +++++++
gdb/lk-low.c | 953 +++++++++++++++++++++++++++++++
gdb/lk-low.h | 362 ++++++++++++
gdb/lk-modules.c | 501 ++++++++++++++++
gdb/lk-modules.h | 148 +++++
gdb/osabi.c | 1 +
gdb/regcache.h | 21 +
gdb/regformats/s390x-cr-linux64.dat | 76 +++
gdb/regformats/s390x-vxcr-linux64.dat | 108 ++++
gdb/s390-lk-tdep.c | 1015 +++++++++++++++++++++++++++++++++
gdb/s390-lk-tdep.h | 39 ++
gdb/s390-tdep.c | 44 +-
gdb/s390-tdep.h | 90 ++-
gdb/solib.c | 8 +
gdb/solib.h | 5 +
gdb/typeprint.c | 2 +-
gdb/typeprint.h | 2 +
gdb/utils.c | 85 +--
gdb/utils.h | 26 +-
38 files changed, 4599 insertions(+), 59 deletions(-)
create mode 100644 gdb/features/s390-cr.xml
create mode 100644 gdb/features/s390x-cr-linux64.c
create mode 100644 gdb/features/s390x-cr-linux64.xml
create mode 100644 gdb/features/s390x-vxcr-linux64.c
create mode 100644 gdb/features/s390x-vxcr-linux64.xml
create mode 100644 gdb/lk-bitmap.h
create mode 100644 gdb/lk-cmds.c
create mode 100644 gdb/lk-cmds.h
create mode 100644 gdb/lk-list.h
create mode 100644 gdb/lk-low.c
create mode 100644 gdb/lk-low.h
create mode 100644 gdb/lk-modules.c
create mode 100644 gdb/lk-modules.h
create mode 100644 gdb/regformats/s390x-cr-linux64.dat
create mode 100644 gdb/regformats/s390x-vxcr-linux64.dat
create mode 100644 gdb/s390-lk-tdep.c
create mode 100644 gdb/s390-lk-tdep.h

--
2.13.5