Cthulhu  0.2.10
Cthulhu compiler collection
common.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 
3 #ifndef _CRT_SECURE_NO_WARNINGS
4 # define _CRT_SECURE_NO_WARNINGS
5 #endif
6 
7 #include "common.h"
8 
9 #include <string.h>
10 
12 
15 {
16  // inside this function we cant assert
17  // because we might be called from inside an assert
18  if (symbol == NULL)
19  return eResolveNothing;
20 
21  text_t name = symbol->name;
22  text_t path = symbol->path;
23 
24  if (name.text == NULL || path.text == NULL)
25  return eResolveNothing;
26 
27  symbol->line = CT_LINE_UNKNOWN;
28  strncpy(name.text, "<unknown>", name.length);
29  strncpy(path.text, "<unknown>", path.length);
30 
31  return bt_resolve_inner(frame, symbol);
32 }
33 
35 void bt_read(bt_trace_t callback, void *user)
36 {
37  if (callback == NULL) return;
38 
39  bt_read_inner(callback, user);
40 }
bt_resolve_t bt_resolve_inner(bt_address_t frame, bt_symbol_t *symbol)
Definition: dbghelp.c:75
void bt_read_inner(bt_trace_t callback, void *user)
Definition: dbghelp.c:67
#define STA_DECL
sal2 annotation on function implementations to copy annotations from the declaration
uint_least64_t bt_address_t
an address of a symbol
Definition: backtrace.h:26
void(* bt_trace_t)(bt_address_t frame, void *user)
user callback for bt_read
Definition: backtrace.h:74
STA_DECL bt_resolve_t bt_resolve_symbol(bt_address_t frame, bt_symbol_t *symbol)
resolve a frame to a symbol
Definition: common.c:14
bt_resolve_t
how much of a frame was reconstructed
Definition: backtrace.h:47
STA_DECL void bt_read(bt_trace_t callback, void *user)
get a backtrace from the current location using a callback
Definition: common.c:35
bt_error_t gSystemError
the global system error handler
Definition: common.c:11
@ eResolveNothing
nothing was resolved
Definition: backtrace.h:49
#define CT_LINE_UNKNOWN
a line number that is unknown
Definition: source_info.h:22
system error handling callbacks
Definition: backtrace.h:89
a symbol
Definition: backtrace.h:33
text_t name
a buffer to hold the name
Definition: backtrace.h:39
text_t path
a buffer to hold the path to the file
Definition: backtrace.h:42
source_line_t line
the line number
Definition: backtrace.h:36
a range of text
Definition: text.h:14
size_t length
the number of characters in the text
Definition: text.h:19