Skip to content

Commit c90cb9b

Browse files
profiler and symbol lookup improvements
1 parent 1bbff2e commit c90cb9b

11 files changed

Lines changed: 328 additions & 154 deletions

File tree

cmake/custom_targets.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function(symbols TARGETFILE SOURCEFILE)
220220
set(FILENAME "${CMAKE_BINARY_DIR}/iso/kernel.bin")
221221
set(OUTNAME "${CMAKE_BINARY_DIR}/iso/${TARGETFILE}")
222222
add_custom_command(OUTPUT ${OUTNAME}
223-
COMMAND /bin/nm -a "${CMAKE_BINARY_DIR}/iso/kernel.bin" | sort -d | gzip -c > "${CMAKE_BINARY_DIR}/iso/kernel.sym"
223+
COMMAND /bin/nm -a -n "${CMAKE_BINARY_DIR}/iso/kernel.bin" | grep -E "^[0-9a-fA-F]+ T [^[:space:]]+$" | gzip -c > "${CMAKE_BINARY_DIR}/iso/kernel.sym"
224224
DEPENDS ${FILENAME})
225225
add_custom_target(SYMBOLS ALL DEPENDS ${OUTNAME})
226226
add_dependencies(SYMBOLS "kernel.bin")

include/basic/unified_expression.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ const char* up_str_expr_strict(struct basic_ctx *ctx);
118118
*
119119
* @note No allocation is performed.
120120
*/
121-
up_value up_make_int(int64_t x);
122-
121+
#define up_make_int(x) ((up_value){ .kind = UP_INT, .v.i = (x) })
123122
/**
124123
* @brief Construct a typed value holding a real (double).
125124
*
@@ -128,19 +127,22 @@ up_value up_make_int(int64_t x);
128127
*
129128
* @note No allocation is performed.
130129
*/
131-
up_value up_make_real(double x);
130+
#define up_make_real(x) ((up_value){ .kind = UP_REAL, .v.r = (x) })
132131

133132
/**
134133
* @brief Construct a typed value holding a string pointer.
135134
*
136-
* @param s Pointer to NUL-terminated string to store (may be NULL).
135+
* @param x Pointer to NUL-terminated string to store (may be NULL).
137136
* @return up_value tagged as UP_STR with @p s in the string field.
138137
*
139138
* @note The pointer is stored as-is; lifetime/ownership of @p s must be
140139
* managed by the caller (typically GC-allocated in this interpreter).
141140
* No copy is made here.
142141
*/
143-
up_value up_make_str(const char *s);
142+
#define up_make_str(x) ({ \
143+
const char *up_make_str_s = (x); \
144+
(up_value){ .kind = UP_STR, .v.s = up_make_str_s ? up_make_str_s : "" }; \
145+
})
144146

145147
/**
146148
* @brief Evaluate a single value expression and return its typed result.

include/debugger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
typedef struct symbol
1111
{
12-
char* name;
1312
uint64_t address;
1413
uint8_t type;
1514
struct symbol* next;
15+
char name[];
1616
} symbol_t;
1717

1818
typedef struct stack_frame {

include/memcpy.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ static inline __attribute__((always_inline)) void memzero(void* dest, size_t len
9494
memset(dest, 0, len);
9595
}
9696

97-
/* ------------------------------------------------------------------------- */
98-
/* Additional helpers */
99-
/* ------------------------------------------------------------------------- */
100-
10197
/**
10298
* @brief Reverse a block of memory in place.
10399
*
@@ -108,3 +104,5 @@ static inline __attribute__((always_inline)) void memzero(void* dest, size_t len
108104
* @return Number of bytes reversed (same as @p n).
109105
*/
110106
size_t memrev(char* buf, size_t n);
107+
108+
void* memchr(const void *ptr, int c, uint64_t len);

modules/ogg/stb_vorbis.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,7 @@ static uint8 get8(vorb *z)
13491349
return c;
13501350
}
13511351
#endif
1352+
return 0;
13521353
}
13531354

13541355
static uint32 get32(vorb *f)
@@ -1378,6 +1379,7 @@ static int getn(vorb *z, uint8 *data, int n)
13781379
return 0;
13791380
}
13801381
#endif
1382+
return 0;
13811383
}
13821384

13831385
static void skip(vorb *z, int n)
@@ -1424,6 +1426,7 @@ static int set_file_offset(stb_vorbis *f, unsigned int loc)
14241426
fseek(f->f, f->f_start, SEEK_END);
14251427
return 0;
14261428
#endif
1429+
return 0;
14271430
}
14281431

14291432

@@ -4552,6 +4555,7 @@ unsigned int stb_vorbis_get_file_offset(stb_vorbis *f)
45524555
#ifndef STB_VORBIS_NO_STDIO
45534556
return (unsigned int) (ftell(f->f) - f->f_start);
45544557
#endif
4558+
return 0;
45554559
}
45564560

45574561
#ifndef STB_VORBIS_NO_PULLDATA_API

src/basic/unified_expression.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,6 @@
1212

1313
/* ---------- Typed value ---------- */
1414

15-
/* Constructors */
16-
up_value up_make_int(int64_t x) {
17-
up_value v;
18-
v.kind = UP_INT;
19-
v.v.i = x;
20-
return v;
21-
}
22-
23-
up_value up_make_real(double x) {
24-
up_value v;
25-
v.kind = UP_REAL;
26-
v.v.r = x;
27-
return v;
28-
}
29-
30-
up_value up_make_str(const char *s) {
31-
up_value v;
32-
v.kind = UP_STR;
33-
v.v.s = s ? s : "";
34-
return v;
35-
}
36-
3715
/* Promote INT -> REAL when needed */
3816
static inline void up_promote_pair(up_value *a, up_value *b) {
3917
if (a->kind == UP_REAL || b->kind == UP_REAL) {

0 commit comments

Comments
 (0)