mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-24 10:03:05 +00:00
87b7292aa5
drgn is currently licensed as GPLv3+. Part of the long term vision for drgn is that other projects can use it as a library providing programmatic interfaces for debugger functionality. A more permissive license is better suited to this goal. We decided on LGPLv2.1+ as a good balance between software freedom and permissiveness. All contributors not employed by Meta were contacted via email and consented to the license change. The only exception was the author of commitc4fbf7e589
("libdrgn: fix for compilation error"), who did not respond. That commit reverted a single line of code to one originally written by me in commit640b1c011d
("libdrgn: embed DWARF index in DWARF info cache"). Signed-off-by: Omar Sandoval <osandov@osandov.com>
87 lines
2.3 KiB
C
87 lines
2.3 KiB
C
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
/**
|
|
* @file
|
|
*
|
|
* Object lookup.
|
|
*
|
|
* See @ref ObjectIndex.
|
|
*/
|
|
|
|
#ifndef DRGN_OBJECT_INDEX_H
|
|
#define DRGN_OBJECT_INDEX_H
|
|
|
|
#include "drgn.h"
|
|
|
|
/**
|
|
* @ingroup Internals
|
|
*
|
|
* @defgroup ObjectIndex Object index
|
|
*
|
|
* Object lookup.
|
|
*
|
|
* @ref drgn_object_index provides a common interface for finding objects (e.g.,
|
|
* variables, constants, and functions) in a program.
|
|
*
|
|
* @{
|
|
*/
|
|
|
|
/** Registered callback in a @ref drgn_object_index. */
|
|
struct drgn_object_finder {
|
|
/** The callback. */
|
|
drgn_object_find_fn fn;
|
|
/** Argument to pass to @ref drgn_object_finder::fn. */
|
|
void *arg;
|
|
/** Next callback to try. */
|
|
struct drgn_object_finder *next;
|
|
};
|
|
|
|
/**
|
|
* Object index.
|
|
*
|
|
* A object index is used to find objects (variables, constants, and functions)
|
|
* by name. The objects are found using callbacks which are registered with @ref
|
|
* drgn_object_index_add_finder(). @ref drgn_object_index_find() searches for an
|
|
* object.
|
|
*/
|
|
struct drgn_object_index {
|
|
/** Callbacks for finding objects. */
|
|
struct drgn_object_finder *finders;
|
|
};
|
|
|
|
/** Initialize a @ref drgn_object_index. */
|
|
void drgn_object_index_init(struct drgn_object_index *oindex);
|
|
|
|
/** Deinitialize a @ref drgn_object_index. */
|
|
void drgn_object_index_deinit(struct drgn_object_index *oindex);
|
|
|
|
/** @sa drgn_program_add_object_finder() */
|
|
struct drgn_error *
|
|
drgn_object_index_add_finder(struct drgn_object_index *oindex,
|
|
drgn_object_find_fn fn, void *arg);
|
|
|
|
/** Remove the most recently added object finding callback. */
|
|
void drgn_object_index_remove_finder(struct drgn_object_index *oindex);
|
|
|
|
/**
|
|
* Find an object in a @ref drgn_object_index.
|
|
*
|
|
* @param[in] oindex Object index.
|
|
* @param[in] name Name of the object.
|
|
* @param[in] filename Exact filename containing the object definition, or @c
|
|
* NULL for any definition.
|
|
* @param[in] flags Bitmask of @ref drgn_find_object_flags.
|
|
* @param[out] ret Returned object.
|
|
* @return @c NULL on success, non-@c NULL on error.
|
|
*/
|
|
struct drgn_error *drgn_object_index_find(struct drgn_object_index *oindex,
|
|
const char *name,
|
|
const char *filename,
|
|
enum drgn_find_object_flags flags,
|
|
struct drgn_object *ret);
|
|
|
|
/** @} */
|
|
|
|
#endif /* DRGN_OBJECT_INDEX_H */
|