2021-11-21 23:59:44 +00:00
|
|
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
2022-11-02 00:05:16 +00:00
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
2019-10-25 23:23:02 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
*
|
|
|
|
* Helpers implemented in C.
|
|
|
|
*
|
|
|
|
* Most drgn helpers are implemented in Python. However, there are a few that we
|
|
|
|
* need internally in libdrgn, so they are implemented in C, instead.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DRGN_HELPERS_H
|
|
|
|
#define DRGN_HELPERS_H
|
|
|
|
|
2020-09-24 00:02:02 +01:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2021-12-18 00:56:00 +00:00
|
|
|
#include "drgn.h"
|
|
|
|
|
2020-09-24 00:02:02 +01:00
|
|
|
struct drgn_object;
|
|
|
|
struct drgn_program;
|
|
|
|
|
2022-07-02 21:14:18 +01:00
|
|
|
struct drgn_error *linux_helper_direct_mapping_offset(struct drgn_program *prog,
|
|
|
|
uint64_t *ret);
|
|
|
|
|
2020-05-06 02:21:36 +01:00
|
|
|
struct drgn_error *linux_helper_read_vm(struct drgn_program *prog,
|
|
|
|
uint64_t pgtable, uint64_t virt_addr,
|
|
|
|
void *buf, size_t count);
|
|
|
|
|
2023-06-03 07:40:38 +01:00
|
|
|
struct drgn_error *linux_helper_follow_phys(struct drgn_program *prog,
|
|
|
|
uint64_t pgtable,
|
|
|
|
uint64_t virt_addr, uint64_t *ret);
|
|
|
|
|
2021-12-21 22:39:50 +00:00
|
|
|
struct drgn_error *linux_helper_per_cpu_ptr(struct drgn_object *res,
|
|
|
|
const struct drgn_object *ptr,
|
|
|
|
uint64_t cpu);
|
|
|
|
|
2023-06-29 23:58:52 +01:00
|
|
|
struct drgn_error *linux_helper_cpu_curr(struct drgn_object *res, uint64_t cpu);
|
|
|
|
|
2021-12-22 00:03:25 +00:00
|
|
|
struct drgn_error *linux_helper_idle_task(struct drgn_object *res,
|
|
|
|
uint64_t cpu);
|
2021-12-21 22:40:57 +00:00
|
|
|
|
2022-10-04 00:08:53 +01:00
|
|
|
struct drgn_error *linux_helper_task_cpu(const struct drgn_object *task,
|
|
|
|
uint64_t *ret);
|
|
|
|
|
2019-10-25 23:23:02 +01:00
|
|
|
struct drgn_error *
|
2022-12-14 01:10:22 +00:00
|
|
|
linux_helper_xa_load(struct drgn_object *res, const struct drgn_object *xa,
|
|
|
|
uint64_t index);
|
2019-10-25 23:23:02 +01:00
|
|
|
|
|
|
|
struct drgn_error *linux_helper_idr_find(struct drgn_object *res,
|
|
|
|
const struct drgn_object *idr,
|
|
|
|
uint64_t id);
|
|
|
|
|
|
|
|
struct drgn_error *linux_helper_find_pid(struct drgn_object *res,
|
|
|
|
const struct drgn_object *ns,
|
|
|
|
uint64_t pid);
|
|
|
|
|
|
|
|
struct drgn_error *linux_helper_pid_task(struct drgn_object *res,
|
|
|
|
const struct drgn_object *pid,
|
|
|
|
uint64_t pid_type);
|
|
|
|
|
|
|
|
struct drgn_error *linux_helper_find_task(struct drgn_object *res,
|
|
|
|
const struct drgn_object *ns,
|
|
|
|
uint64_t pid);
|
|
|
|
|
2021-12-18 00:56:00 +00:00
|
|
|
struct linux_helper_task_iterator {
|
2023-11-18 07:12:31 +00:00
|
|
|
struct drgn_object tasks_node;
|
|
|
|
struct drgn_object thread_node;
|
|
|
|
uint64_t tasks_head;
|
|
|
|
uint64_t thread_head;
|
2021-12-18 00:56:00 +00:00
|
|
|
struct drgn_qualified_type task_struct_type;
|
|
|
|
bool done;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct drgn_error *
|
|
|
|
linux_helper_task_iterator_init(struct linux_helper_task_iterator *it,
|
|
|
|
struct drgn_program *prog);
|
|
|
|
|
|
|
|
void linux_helper_task_iterator_deinit(struct linux_helper_task_iterator *it);
|
|
|
|
|
2023-11-18 07:12:31 +00:00
|
|
|
/** Get the next task from a @ref linux_helper_task_iterator. */
|
2021-12-18 00:56:00 +00:00
|
|
|
struct drgn_error *
|
|
|
|
linux_helper_task_iterator_next(struct linux_helper_task_iterator *it,
|
2023-11-18 07:12:31 +00:00
|
|
|
struct drgn_object *ret);
|
2021-12-18 00:56:00 +00:00
|
|
|
|
2019-10-25 23:23:02 +01:00
|
|
|
#endif /* DRGN_HELPERS_H */
|