#ifndef DEBUG_MAP_H #define DEBUG_MAP_H #include #include "types.h" /* Native PC mapped to one source location. */ struct debug_entry { u32 pc; /* Byte offset from the first instruction. */ u32 offset; /* Byte offset from the start of the source file. */ const char *file; /* Source path. */ }; /* Storage for a native source map. */ struct debug_map { struct debug_entry *entries; /* Entries in PC order. */ size_t count; /* Number of entries. */ char **paths; /* Owned paths from the path table. */ size_t path_count; /* Number of owned paths. */ u8 *data; /* Sidecar bytes, including legacy paths. */ }; /* Read a whole sidecar. Return NULL for an absent or unreadable file. */ u8 *debug_read_sidecar(const char *program, const char *suffix, size_t *size); /* Load .debug if present. Return false for an invalid map. */ bool debug_map_load(struct debug_map *map, const char *program, u32 code_bytes); /* Return the source entry at or before the given code offset, or NULL. */ const struct debug_entry *debug_map_lookup(const struct debug_map *map, u32 pc); /* Free all memory held by the map. */ void debug_map_free(struct debug_map *map); #endif