Skip to content

Commit 359ab5a

Browse files
author
icex2
committed
refactor(inject): Use new core thread and log modules
Keep this a separate commit because this also removes inject's own logging engine and replaces it with the streamlined core API. The core API provides all the features of inject's own logging engine which also performed horribly. The entire logging operation was locked which included expensive operations that formatted the log messages and required memory allocations and copying around data. The core API's implementation at least only synchronizes the actual IO operations (though this can be improved further with an actual async logging sink, TBD)
1 parent 7e49fad commit 359ab5a

5 files changed

Lines changed: 72 additions & 257 deletions

File tree

src/main/inject/Module.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ ldflags_inject := \
55
-lpsapi \
66

77
libs_inject := \
8+
core \
89
util \
910

1011
src_inject := \
1112
main.c \
1213
debugger.c \
13-
logger.c \
1414
options.c \
1515
version.c \
1616

src/main/inject/debugger.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
#include <stdio.h>
99
#include <stdlib.h>
1010

11+
#include "core/log-bt.h"
12+
#include "core/log.h"
13+
1114
#include "inject/debugger.h"
12-
#include "inject/logger.h"
1315

14-
#include "util/log.h"
1516
#include "util/mem.h"
1617
#include "util/proc.h"
1718
#include "util/signal.h"
@@ -178,6 +179,7 @@ static bool log_debug_str(HANDLE process, const OUTPUT_DEBUG_STRING_INFO *odsi)
178179
log_assert(odsi);
179180

180181
char *debug_str;
182+
size_t debug_str_len;
181183

182184
if (odsi->fUnicode) {
183185
debug_str = read_debug_wstr(process, odsi);
@@ -186,7 +188,9 @@ static bool log_debug_str(HANDLE process, const OUTPUT_DEBUG_STRING_INFO *odsi)
186188
}
187189

188190
if (debug_str) {
189-
logger_log(debug_str);
191+
debug_str_len = strlen(debug_str);
192+
193+
core_log_bt_direct_sink_write(debug_str, debug_str_len);
190194

191195
free(debug_str);
192196
return true;

src/main/inject/logger.c

Lines changed: 0 additions & 217 deletions
This file was deleted.

src/main/inject/logger.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)