MCPcopy Index your code
hub / github.com/GJDuck/e9patch / log

Function log

test/regtest/patch.cpp:524–562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

522};
523
524void log(const void *addr, intptr_t val)
525{
526 static struct LOG_ENTRY **log = nullptr;
527 static size_t log_size = 0;
528 static size_t log_ptr = 0;
529
530 struct LOG_ENTRY *entry =
531 (struct LOG_ENTRY *)malloc(sizeof(struct LOG_ENTRY));
532 if (entry == nullptr)
533 {
534 fprintf(stderr, "malloc() failed (%s)\n", strerror(errno));
535 abort();
536 }
537 entry->addr = addr;
538 entry->val = val;
539 if (log_ptr >= log_size)
540 {
541 log_size = (log_size == 0? 1: 2 * log_size);
542 log = (struct LOG_ENTRY **)realloc(log,
543 log_size * sizeof(struct LOG_ENTRY *));
544 if (log == nullptr)
545 {
546 fprintf(stderr, "realloc() failed (%s)\n", strerror(errno));
547 abort();
548 }
549 }
550 log[log_ptr++] = entry;
551 if (addr != (const void *)0xa0002ac)
552 return;
553 fputc('{', stderr);
554 for (size_t i = 0; i < log_ptr; i++)
555 {
556 fprintf(stderr, "<%p:0x%lx>%s", log[i]->addr, log[i]->val,
557 (i == log_ptr-1? "": ", "));
558 free(log[i]);
559 }
560 fputs("}\n", stderr);
561 free(log);
562}
563
564void print_ptr(const void *ptr, const char *_asm)
565{

Callers 7

realMainFunction · 0.85
mergeFunction · 0.85
collectMappingsFunction · 0.85
optimizeMappingsFunction · 0.85
patchFunction · 0.85
queueFlushFunction · 0.85
parseEmitFunction · 0.85

Calls 8

mallocFunction · 0.85
strerrorFunction · 0.85
abortFunction · 0.85
reallocFunction · 0.85
fputcFunction · 0.85
freeFunction · 0.85
fputsFunction · 0.85
fprintfFunction · 0.50

Tested by

no test coverage detected