This repository has been archived by the owner on Jun 27, 2018. It is now read-only.
/
ddata.h
98 lines (77 loc) · 2.28 KB
/
ddata.h
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
File: ddata.h
Project: DCPU-16 Toolchain
Component: LibDCPU-CI-DbgFmt
Authors: James Rhodes
José Manuel Díez
Description: Defines the API for reading and writing to debugging
symbol formats.
**/
#ifndef __DCPU_DBG_DDATA_H
#define __DCPU_DBG_DDATA_H
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <bstring.h>
#include <simclist.h>
#define DBGFMT_MAGIC 0xC0DEBEAF
#define DBGFMT_UNDETERMINED 0xFFFF
#define DBGFMT_SYMBOL_LINE 0x1
#define DBGFMT_SYMBOL_STRING 0x2
#define DBGFMT_SYMBOL_LABEL 0x3
#define DBGFMT_SYMBOL_CFUNC 0x4
#define DBGFMT_SYMBOL_CVAR 0x5
struct dbg_sym_file
{
uint32_t magic;
uint32_t num_symbols;
struct dbg_sym* symbols;
};
struct dbg_sym
{
uint16_t length;
uint8_t type;
void* payload;
};
struct dbg_sym_payload_line
{
bstring path;
uint16_t lineno;
uint16_t address;
};
struct dbg_sym_payload_string
{
bstring data;
uint16_t address;
};
struct dbg_sym_payload_label
{
bstring label;
uint16_t address;
};
struct dbgfmt_serialization_result
{
uint8_t* bytestream;
uint16_t length;
};
list_t* dbgfmt_create_list();
int dbgfmt_write(bstring path, list_t* symbols);
list_t* dbgfmt_read(bstring path, uint8_t null_on_read_failure);
void dbgfmt_free(list_t* symbols);
size_t dbgsym_meter(const void* el);
int dbgsym_comparator(const void* a, const void* b);
uint16_t dbgfmt_get_symbol_address(struct dbg_sym* symbol);
void dbgfmt_update_symbol(struct dbg_sym* symbol, uint16_t address);
void dbgfmt_update_symbol_list(list_t* symbols, uint16_t address);
void dbgfmt_finalize_symbol(struct dbg_sym* symbol, uint16_t address);
struct dbg_sym* dbgfmt_create_symbol(uint8_t type, void* payload);
struct dbg_sym* dbgfmt_copy_symbol(struct dbg_sym* other);
void dbgfmt_free_symbol(struct dbg_sym* symbol);
struct dbg_sym_payload_line* dbgfmt_create_symbol_line(bstring path, uint16_t lineno, uint16_t address);
struct dbg_sym_payload_string* dbgfmt_create_symbol_string(bstring data, uint16_t address);
struct dbg_sym_payload_label* dbgfmt_create_symbol_label(bstring data, uint16_t address);
struct dbg_sym_payload_line* dbgfmt_get_symbol_line(struct dbg_sym* bytes);
struct dbg_sym_payload_string* dbgfmt_get_symbol_string(struct dbg_sym* bytes);
struct dbg_sym_payload_label* dbgfmt_get_symbol_label(struct dbg_sym* bytes);
#endif