replace "assert" with "return" if FILE pointer is NULL in memlogging.c

main
xiaosuGW 3 years ago
parent 6198ce284e
commit b648b62bfe

@ -203,6 +203,9 @@ sandbox_mem_print_perf(struct sandbox *sandbox)
#ifndef LOG_RUNTIME_MEM_LOG #ifndef LOG_RUNTIME_MEM_LOG
return; return;
#endif #endif
/* If the log was not defined by an environment variable, early out */
if (runtime_sandbox_perf_log == NULL) return;
uint32_t total_time_us = sandbox->total_time / runtime_processor_speed_MHz; uint32_t total_time_us = sandbox->total_time / runtime_processor_speed_MHz;
uint32_t queued_us = (sandbox->allocation_timestamp - sandbox->enqueue_timestamp) uint32_t queued_us = (sandbox->allocation_timestamp - sandbox->enqueue_timestamp)
/ runtime_processor_speed_MHz; / runtime_processor_speed_MHz;

@ -26,10 +26,6 @@ mem_log_init2(uint32_t log_size, FILE* file)
log_obj.offset = 0; log_obj.offset = 0;
log_obj.fout = file; log_obj.fout = file;
if (!log_obj.fout) {
panic("failed to open log file:%s\n", strerror(errno));
}
} }
/** /**
@ -51,11 +47,7 @@ mem_log_init(uint32_t log_size, char const* file)
} }
log_obj.offset = 0; log_obj.offset = 0;
log_obj.fout = fopen(file, "a+"); log_obj.fout = fopen(file, "w");
if (!log_obj.fout) {
panic("failed to open log file:%s\n", strerror(errno));
}
} }
/** /**
@ -68,7 +60,9 @@ mem_log(char const * fmt, ...)
return; return;
#endif #endif
assert(log_obj.logger); assert(log_obj.logger);
assert(log_obj.fout); if (!log_obj.fout) {
return;
}
va_list va; va_list va;
va_start(va, fmt); va_start(va, fmt);
@ -112,8 +106,11 @@ dump_log_to_file()
#ifndef LOG_RUNTIME_MEM_LOG #ifndef LOG_RUNTIME_MEM_LOG
return; return;
#endif #endif
if (!log_obj.fout) {
return;
}
assert(log_obj.logger); assert(log_obj.logger);
assert(log_obj.fout);
uint32_t write_bytes = 0; uint32_t write_bytes = 0;
while(write_bytes != log_obj.offset) { while(write_bytes != log_obj.offset) {

@ -8,11 +8,13 @@ declare project_path="$(
cd "$(dirname "$1")/../.." cd "$(dirname "$1")/../.."
pwd pwd
)" )"
path=`pwd`
echo $project_path echo $project_path
cd $project_path/runtime/bin cd $project_path/runtime/bin
export SLEDGE_DISABLE_PREEMPTION=true
export LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" export LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH"
gdb --eval-command="handle SIGUSR1 nostop" \ gdb --eval-command="handle SIGUSR1 nostop" \
--eval-command="set pagination off" \ --eval-command="set pagination off" \
--eval-command="set substitute-path /sledge/runtime $project_path/runtime" \ --eval-command="set substitute-path /sledge/runtime $project_path/runtime" \
--eval-command="run ../tests/my_fibonacci.json" \ # --eval-command="run ../tests/test_armcifar10.json" \
./sledgert ./sledgert

Loading…
Cancel
Save