File: helpers.h

package info (click to toggle)
drgn 0.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 7,852 kB
  • sloc: python: 74,992; ansic: 54,589; awk: 423; makefile: 351; sh: 99
file content (94 lines) | stat: -rw-r--r-- 2,730 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (c) Meta Platforms, Inc. and affiliates.
// SPDX-License-Identifier: LGPL-2.1-or-later

/**
 * @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

#include <stddef.h>
#include <stdint.h>

#include "drgn_internal.h"

struct drgn_object;
struct drgn_program;

struct drgn_error *linux_helper_direct_mapping_offset(struct drgn_program *prog,
						      uint64_t *ret);

struct drgn_error *linux_helper_read_vm(struct drgn_program *prog,
					uint64_t pgtable, uint64_t virt_addr,
					void *buf, size_t count);

struct drgn_error *linux_helper_follow_phys(struct drgn_program *prog,
					    uint64_t pgtable,
					    uint64_t virt_addr, uint64_t *ret);

struct drgn_error *linux_helper_per_cpu_ptr(struct drgn_object *res,
					    const struct drgn_object *ptr,
					    uint64_t cpu);

struct drgn_error *linux_helper_cpu_curr(struct drgn_object *res, uint64_t cpu);

struct drgn_error *linux_helper_idle_task(struct drgn_object *res,
					  uint64_t cpu);

struct drgn_error *
linux_helper_task_thread_info(struct drgn_object *res,
			      const struct drgn_object *task);

struct drgn_error *linux_helper_task_cpu(const struct drgn_object *task,
					 uint64_t *ret);

struct drgn_error *linux_helper_task_on_cpu(const struct drgn_object *task,
					    bool *ret);

struct drgn_error *
linux_helper_xa_load(struct drgn_object *res, const struct drgn_object *xa,
		     uint64_t index);

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);

struct linux_helper_task_iterator {
	struct drgn_object tasks_node;
	struct drgn_object thread_node;
	uint64_t tasks_head;
	uint64_t thread_head;
	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);

/** Get the next task from a @ref linux_helper_task_iterator. */
struct drgn_error *
linux_helper_task_iterator_next(struct linux_helper_task_iterator *it,
				struct drgn_object *ret);

#endif /* DRGN_HELPERS_H */