mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-25 18:23:07 +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>
113 lines
2.9 KiB
C
113 lines
2.9 KiB
C
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
/**
|
|
* @file
|
|
*
|
|
* Error helpers.
|
|
*
|
|
* See @ref Errors.
|
|
*/
|
|
|
|
#ifndef DRGN_ERROR_H
|
|
#define DRGN_ERROR_H
|
|
|
|
#include "drgn.h"
|
|
|
|
/**
|
|
* @ingroup Internals
|
|
*
|
|
* @defgroup Errors Errors
|
|
*
|
|
* Common errors.
|
|
*
|
|
* @{
|
|
*/
|
|
|
|
struct drgn_operand_type;
|
|
|
|
/** Global stop iteration error. */
|
|
extern struct drgn_error drgn_stop;
|
|
|
|
/** Global @ref DRGN_ERROR_OBJECT_ABSENT error. */
|
|
extern struct drgn_error drgn_error_object_absent;
|
|
|
|
struct string_builder;
|
|
|
|
/**
|
|
* Create a @ref drgn_error with a message from a @ref string_builder.
|
|
*
|
|
* This finalizes the string builder.
|
|
*/
|
|
struct drgn_error *drgn_error_from_string_builder(enum drgn_error_code code,
|
|
struct string_builder *sb);
|
|
|
|
/**
|
|
* Append a formatted @ref drgn_error to a @ref string_builder.
|
|
*
|
|
* @return @c true on success, @c false on error (if we couldn't allocate
|
|
* memory).
|
|
*/
|
|
bool string_builder_append_error(struct string_builder *sb,
|
|
struct drgn_error *err);
|
|
|
|
/** Create a @ref drgn_error from the libelf error indicator. */
|
|
struct drgn_error *drgn_error_libelf(void)
|
|
__attribute__((__returns_nonnull__));
|
|
|
|
/** Create a @ref drgn_error from the libdw error indicator. */
|
|
struct drgn_error *drgn_error_libdw(void)
|
|
__attribute__((__returns_nonnull__));
|
|
|
|
/** Create a @ref drgn_error from the libdwfl error indicator. */
|
|
struct drgn_error *drgn_error_libdwfl(void)
|
|
__attribute__((__returns_nonnull__));
|
|
|
|
/**
|
|
* Create a @ref drgn_error with a type name.
|
|
*
|
|
* The error code will be @ref DRGN_ERROR_TYPE.
|
|
*
|
|
* @param[in] format Format string for the type error. Must contain %s, which
|
|
* will be replaced with the type name, and no other conversion specifications.
|
|
*/
|
|
struct drgn_error *drgn_type_error(const char *format, struct drgn_type *type)
|
|
__attribute__((__returns_nonnull__));
|
|
|
|
/**
|
|
* Create a @ref drgn_error with a qualified type name.
|
|
*
|
|
* @sa drgn_type_error().
|
|
*/
|
|
struct drgn_error *
|
|
drgn_qualified_type_error(const char *format,
|
|
struct drgn_qualified_type qualified_type)
|
|
__attribute__((__returns_nonnull__));
|
|
|
|
/**
|
|
* Create a @ref drgn_error for an incomplete type.
|
|
*
|
|
* @sa drgn_type_error().
|
|
*/
|
|
struct drgn_error *drgn_error_incomplete_type(const char *format,
|
|
struct drgn_type *type);
|
|
|
|
/** Create a @ref drgn_error for invalid types to a binary operator. */
|
|
struct drgn_error *drgn_error_binary_op(const char *op_name,
|
|
struct drgn_operand_type *type1,
|
|
struct drgn_operand_type *type2)
|
|
__attribute__((__returns_nonnull__));
|
|
|
|
/** Create a @ref drgn_error for an invalid type to a unary operator. */
|
|
struct drgn_error *drgn_error_unary_op(const char *op_name,
|
|
struct drgn_operand_type *type)
|
|
__attribute__((__returns_nonnull__));
|
|
|
|
/** Create a @ref drgn_error for a failed symbol lookup. */
|
|
struct drgn_error *drgn_error_symbol_not_found(uint64_t address)
|
|
__attribute__((__returns_nonnull__));
|
|
|
|
/** @} */
|
|
|
|
#endif /* DRGN_ERROR_H */
|