-
Notifications
You must be signed in to change notification settings - Fork 0
/
loc.c
39 lines (36 loc) · 1.09 KB
/
loc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* ****************************************************************************
* loc.c: Definitions
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) 2024 Aditya P. Gurajada
*
* History:
* 3/2024 - Original version provided by Charles Baylis
* ****************************************************************************
*/
#include <stdio.h>
/*
* Define the -I<path> to pick-up include/loc.h ; You cannot include the
* loc.h generated by the Python script, that provides another technique
* to generate the LOC-encoding.
*/
#include "loc.h"
/**
* A dummy location ID used as reference point within the loc_ids section.
* All location ids are stored as an offset from this variable.
*/
#if __APPLE__
LOC Loc_id_ref __attribute__((section("__DATA, loc_ids")));
#else
LOC Loc_id_ref __attribute__((section("loc_ids")));
#endif // __APPLE__
/**
* Decode the LOC-ID and print code-location details.
*/
void
loc_print(loc_t id)
{
LOC *loc = (struct location *)(((intptr_t)&Loc_id_ref) + id);
printf("Location is in function '%s', %s:%d\n",
loc->func, loc->file, loc->line);
}