drgn/libdrgn/linux_kernel_object_find.inc.strswitch
Stephen Brennan eb83d51175 Add VMCOREINFO to special Linux Kernel objects
For Python-based object, type, and symbol finders, the vmcoreinfo is a
critical source of information. It can contain addresses necessary for
loading certain information (such as kallsyms). Expose this information
as a special object.

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
2023-08-18 22:21:13 -07:00

44 lines
1.3 KiB
Plaintext

// Copyright (c) Meta Platforms, Inc. and affiliates.
// SPDX-License-Identifier: LGPL-2.1-or-later
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)
{
struct drgn_program *prog = arg;
if (!filename) {
@memswitch (name, name_len)@
@case "PAGE_SHIFT"@
if (flags & DRGN_FIND_OBJECT_CONSTANT)
return linux_kernel_get_page_shift(prog, ret);
break;
@case "PAGE_SIZE"@
if (flags & DRGN_FIND_OBJECT_CONSTANT)
return linux_kernel_get_page_size(prog, ret);
break;
@case "PAGE_MASK"@
if (flags & DRGN_FIND_OBJECT_CONSTANT)
return linux_kernel_get_page_mask(prog, ret);
break;
@case "UTS_RELEASE"@
if (flags & DRGN_FIND_OBJECT_CONSTANT)
return linux_kernel_get_uts_release(prog, ret);
break;
@case "VMCOREINFO"@
if (flags & DRGN_FIND_OBJECT_CONSTANT)
return linux_kernel_get_vmcoreinfo(prog, ret);
break;
@case "jiffies"@
if (flags & DRGN_FIND_OBJECT_VARIABLE)
return linux_kernel_get_jiffies(prog, ret);
break;
@case "vmemmap"@
if (flags & DRGN_FIND_OBJECT_CONSTANT)
return linux_kernel_get_vmemmap(prog, ret);
break;
@endswitch@
}
return &drgn_not_found;
}