2020-05-15 23:13:02 +01:00
|
|
|
// Copyright (c) Facebook, Inc. and its affiliates.
|
2019-04-28 20:13:29 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0+
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
*
|
|
|
|
* Debugging information cache.
|
|
|
|
*
|
|
|
|
* See @ref DWARFInfoCache.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DRGN_DWARF_INFO_CACHE_H
|
|
|
|
#define DRGN_DWARF_INFO_CACHE_H
|
|
|
|
|
|
|
|
#include "drgn.h"
|
|
|
|
#include "hash_table.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup Internals
|
|
|
|
*
|
|
|
|
* @defgroup DWARFInfoCache Debugging information cache
|
|
|
|
*
|
|
|
|
* Caching of DWARF debugging information.
|
|
|
|
*
|
|
|
|
* @ref drgn_dwarf_info_cache bridges the raw DWARF information indexed by @ref
|
|
|
|
* drgn_dwarf_index to the higher-level @ref drgn_type_index and @ref
|
2019-07-24 00:26:29 +01:00
|
|
|
* drgn_object_index.
|
2019-04-28 20:13:29 +01:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Cached type in a @ref drgn_dwarf_info_cache. */
|
|
|
|
struct drgn_dwarf_type {
|
|
|
|
struct drgn_type *type;
|
|
|
|
enum drgn_qualifiers qualifiers;
|
|
|
|
/**
|
|
|
|
* Whether this is an incomplete array type or a typedef of one.
|
|
|
|
*
|
|
|
|
* This is used to work around a GCC bug; see @ref
|
|
|
|
* drgn_type_from_dwarf_internal().
|
|
|
|
*/
|
|
|
|
bool is_incomplete_array;
|
|
|
|
/** Whether we need to free @c type. */
|
|
|
|
bool should_free;
|
|
|
|
};
|
|
|
|
|
2019-05-16 09:25:43 +01:00
|
|
|
DEFINE_HASH_MAP_TYPE(dwarf_type_map, const void *, struct drgn_dwarf_type);
|
2019-04-28 20:13:29 +01:00
|
|
|
|
|
|
|
struct drgn_dwarf_index;
|
|
|
|
|
|
|
|
/**
|
2019-07-24 00:26:29 +01:00
|
|
|
* Cache of types and objects from DWARF debugging information.
|
2019-04-28 20:13:29 +01:00
|
|
|
*
|
|
|
|
* This is the argument for @ref drgn_dwarf_type_find() and @ref
|
2019-07-24 00:26:29 +01:00
|
|
|
* drgn_dwarf_object_find().
|
2019-04-28 20:13:29 +01:00
|
|
|
*/
|
|
|
|
struct drgn_dwarf_info_cache {
|
|
|
|
/** Index of DWARF debugging information. */
|
2019-05-01 15:29:02 +01:00
|
|
|
struct drgn_dwarf_index dindex;
|
2019-04-28 20:13:29 +01:00
|
|
|
/**
|
|
|
|
* Cache of parsed types.
|
|
|
|
*
|
|
|
|
* The key is the address of the DIE (@c Dwarf_Die::addr). The value is
|
|
|
|
* a @ref drgn_dwarf_type.
|
|
|
|
*/
|
|
|
|
struct dwarf_type_map map;
|
|
|
|
/**
|
|
|
|
* Cache of parsed types which appear to be incomplete array types but
|
|
|
|
* can't be.
|
|
|
|
*
|
|
|
|
* See @ref drgn_type_from_dwarf_internal().
|
|
|
|
*/
|
|
|
|
struct dwarf_type_map cant_be_incomplete_array_map;
|
|
|
|
/** Current parsing recursion depth. */
|
|
|
|
int depth;
|
2019-05-01 15:29:02 +01:00
|
|
|
/** Type index. */
|
|
|
|
struct drgn_type_index *tindex;
|
2019-04-28 20:13:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Create a @ref drgn_dwarf_info_cache. */
|
|
|
|
struct drgn_error *
|
|
|
|
drgn_dwarf_info_cache_create(struct drgn_type_index *tindex,
|
2019-09-25 01:13:53 +01:00
|
|
|
const Dwfl_Callbacks *dwfl_callbacks,
|
2019-04-28 20:13:29 +01:00
|
|
|
struct drgn_dwarf_info_cache **ret);
|
|
|
|
|
|
|
|
/** Destroy a @ref drgn_dwarf_info_cache. */
|
|
|
|
void drgn_dwarf_info_cache_destroy(struct drgn_dwarf_info_cache *dicache);
|
|
|
|
|
|
|
|
/** @ref drgn_type_find_fn() that uses DWARF debugging information. */
|
|
|
|
struct drgn_error *drgn_dwarf_type_find(enum drgn_type_kind kind,
|
|
|
|
const char *name, size_t name_len,
|
|
|
|
const char *filename, void *arg,
|
|
|
|
struct drgn_qualified_type *ret);
|
|
|
|
|
2019-07-24 00:26:29 +01:00
|
|
|
/** @ref drgn_object_find_fn() that uses DWARF debugging information. */
|
2019-04-28 20:13:29 +01:00
|
|
|
struct drgn_error *
|
2019-07-24 00:26:29 +01:00
|
|
|
drgn_dwarf_object_find(const char *name, size_t name_len, const char *filename,
|
2019-04-30 20:38:41 +01:00
|
|
|
enum drgn_find_object_flags flags, void *arg,
|
2019-07-24 00:26:29 +01:00
|
|
|
struct drgn_object *ret);
|
2019-04-28 20:13:29 +01:00
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
#endif /* DRGN_DWARF_INFO_CACHE_H */
|