2021-11-21 23:59:44 +00:00
|
|
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
2021-04-03 09:10:35 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2019-06-04 23:20:03 +01:00
|
|
|
|
|
|
|
#ifndef DRGN_LINUX_KERNEL_H
|
|
|
|
#define DRGN_LINUX_KERNEL_H
|
|
|
|
|
|
|
|
#include "drgn.h"
|
|
|
|
|
2020-09-16 01:42:53 +01:00
|
|
|
struct drgn_debug_info_load_state;
|
2019-06-04 23:20:03 +01:00
|
|
|
struct vmcoreinfo;
|
|
|
|
|
2020-05-06 08:35:29 +01:00
|
|
|
struct drgn_error *read_memory_via_pgtable(void *buf, uint64_t address,
|
|
|
|
size_t count, uint64_t offset,
|
|
|
|
void *arg, bool physical);
|
|
|
|
|
2019-06-04 23:20:03 +01:00
|
|
|
struct drgn_error *parse_vmcoreinfo(const char *desc, size_t descsz,
|
|
|
|
struct vmcoreinfo *ret);
|
|
|
|
|
2020-05-04 08:44:44 +01:00
|
|
|
struct drgn_error *proc_kallsyms_symbol_addr(const char *name,
|
|
|
|
unsigned long *ret);
|
|
|
|
|
2021-06-04 01:43:27 +01:00
|
|
|
struct drgn_error *read_vmcoreinfo_fallback(struct drgn_program *prog);
|
2019-06-04 23:20:03 +01:00
|
|
|
|
2020-04-09 22:59:42 +01:00
|
|
|
struct drgn_error *linux_kernel_object_find(const char *name, size_t name_len,
|
|
|
|
const char *filename,
|
|
|
|
enum drgn_find_object_flags flags,
|
|
|
|
void *arg, struct drgn_object *ret);
|
2020-02-19 19:51:38 +00:00
|
|
|
|
libdrgn: use libdwfl
libdwfl is the elfutils "DWARF frontend library". It has high-level
functionality for looking up symbols, walking stack traces, etc. In
order to use this functionality, we need to report our debugging
information through libdwfl. For userspace programs, libdwfl has a much
better implementation than drgn for automatically finding debug
information from a core dump or PID. However, for the kernel, libdwfl
has a few issues:
- It only supports finding debug information for the running kernel, not
vmcores.
- It determines the vmlinux address range by reading /proc/kallsyms,
which is slow (~70ms on my machine).
- If separate debug information isn't available for a kernel module, it
finds it by walking /lib/modules/$(uname -r)/kernel; this is repeated
for every module.
- It doesn't find kernel modules with names containing both dashes and
underscores (e.g., aes-x86_64).
Luckily, drgn already solved all of these problems, and with some
effort, we can keep doing it ourselves and report it to libdwfl.
The conversion replaces a bunch of code for dealing with userspace core
dump notes, /proc/$pid/maps, and relocations.
2019-07-15 08:51:30 +01:00
|
|
|
struct drgn_error *
|
2020-09-16 01:42:53 +01:00
|
|
|
linux_kernel_report_debug_info(struct drgn_debug_info_load_state *load);
|
2019-06-04 23:20:03 +01:00
|
|
|
|
2019-08-02 08:00:59 +01:00
|
|
|
#define KDUMP_SIGNATURE "KDUMP "
|
|
|
|
#define KDUMP_SIG_LEN (sizeof(KDUMP_SIGNATURE) - 1)
|
|
|
|
|
|
|
|
#ifdef WITH_LIBKDUMPFILE
|
2020-02-11 22:54:09 +00:00
|
|
|
struct drgn_error *drgn_program_cache_prstatus_kdump(struct drgn_program *prog);
|
2019-08-02 08:00:59 +01:00
|
|
|
struct drgn_error *drgn_program_set_kdump(struct drgn_program *prog);
|
|
|
|
#else
|
|
|
|
static inline struct drgn_error *
|
|
|
|
drgn_program_set_kdump(struct drgn_program *prog)
|
|
|
|
{
|
|
|
|
return drgn_error_create(DRGN_ERROR_INVALID_ARGUMENT,
|
2020-02-11 22:54:09 +00:00
|
|
|
"drgn was built without libkdumpfile support");
|
2019-08-02 08:00:59 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-06-04 23:20:03 +01:00
|
|
|
#endif /* DRGN_LINUX_KERNEL_H */
|