2022-11-02 00:14:02 +00:00
|
|
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
|
2022-02-08 09:32:28 +00: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)
|
|
|
|
{
|
|
|
|
struct drgn_program *prog = arg;
|
2023-02-22 18:30:58 +00:00
|
|
|
if (!filename) {
|
2022-02-08 09:32:28 +00:00
|
|
|
@memswitch (name, name_len)@
|
|
|
|
@case "PAGE_SHIFT"@
|
2023-02-22 18:30:58 +00:00
|
|
|
if (flags & DRGN_FIND_OBJECT_CONSTANT)
|
|
|
|
return linux_kernel_get_page_shift(prog, ret);
|
|
|
|
break;
|
2022-02-08 09:32:28 +00:00
|
|
|
@case "PAGE_SIZE"@
|
2023-02-22 18:30:58 +00:00
|
|
|
if (flags & DRGN_FIND_OBJECT_CONSTANT)
|
|
|
|
return linux_kernel_get_page_size(prog, ret);
|
|
|
|
break;
|
2022-02-08 09:32:28 +00:00
|
|
|
@case "PAGE_MASK"@
|
2023-02-22 18:30:58 +00:00
|
|
|
if (flags & DRGN_FIND_OBJECT_CONSTANT)
|
|
|
|
return linux_kernel_get_page_mask(prog, ret);
|
|
|
|
break;
|
2022-02-08 09:32:28 +00:00
|
|
|
@case "UTS_RELEASE"@
|
2023-02-22 18:30:58 +00:00
|
|
|
if (flags & DRGN_FIND_OBJECT_CONSTANT)
|
|
|
|
return linux_kernel_get_uts_release(prog, ret);
|
|
|
|
break;
|
|
|
|
@case "jiffies"@
|
|
|
|
if (flags & DRGN_FIND_OBJECT_VARIABLE)
|
|
|
|
return linux_kernel_get_jiffies(prog, ret);
|
|
|
|
break;
|
2022-02-08 09:32:28 +00:00
|
|
|
@case "vmemmap"@
|
2023-02-22 18:30:58 +00:00
|
|
|
if (flags & DRGN_FIND_OBJECT_CONSTANT)
|
|
|
|
return linux_kernel_get_vmemmap(prog, ret);
|
|
|
|
break;
|
2022-02-08 09:32:28 +00:00
|
|
|
@endswitch@
|
|
|
|
}
|
|
|
|
return &drgn_not_found;
|
|
|
|
}
|