gcov: Fixes APP CPU syscall table

This commit is contained in:
Alexey Gerenkov 2020-04-14 22:36:29 +03:00
parent d7fb9d54ba
commit 16726e9980

View file

@ -68,8 +68,12 @@ static int esp_dbg_stub_gcov_dump_do(void)
int ret = ESP_OK;
FILE* old_stderr = stderr;
FILE* old_stdout = stdout;
struct syscall_stub_table* old_table = syscall_table_ptr_pro;
static struct syscall_stub_table *old_tables[portNUM_PROCESSORS];
old_tables[0] = syscall_table_ptr_pro;
#if portNUM_PROCESSORS > 1
old_tables[1] = syscall_table_ptr_app;
#endif
ESP_EARLY_LOGV(TAG, "Alloc apptrace down buf %d bytes", ESP_GCOV_DOWN_BUF_SIZE);
void *down_buf = malloc(ESP_GCOV_DOWN_BUF_SIZE);
if (down_buf == NULL) {
@ -80,12 +84,14 @@ static int esp_dbg_stub_gcov_dump_do(void)
esp_apptrace_down_buffer_config(down_buf, ESP_GCOV_DOWN_BUF_SIZE);
ESP_EARLY_LOGV(TAG, "Dump data...");
// incase of dual-core chip APP and PRO CPUs share the same table, so it is safe to save only PRO's table
memcpy(&s_gcov_stub_table, old_table, sizeof(s_gcov_stub_table));
memcpy(&s_gcov_stub_table, syscall_table_ptr_pro, sizeof(s_gcov_stub_table));
s_gcov_stub_table._lock_acquire_recursive = &gcov_stub_lock_acquire_recursive;
s_gcov_stub_table._lock_release_recursive = &gcov_stub_lock_release_recursive;
s_gcov_stub_table._lock_try_acquire_recursive = &gcov_stub_lock_try_acquire_recursive,
syscall_table_ptr_pro = &s_gcov_stub_table;
#if portNUM_PROCESSORS > 1
syscall_table_ptr_app = &s_gcov_stub_table;
#endif
stderr = (FILE*) &__sf_fake_stderr;
stdout = (FILE*) &__sf_fake_stdout;
__gcov_dump();
@ -93,8 +99,10 @@ static int esp_dbg_stub_gcov_dump_do(void)
__gcov_reset();
stdout = old_stdout;
stderr = old_stderr;
syscall_table_ptr_pro = old_table;
syscall_table_ptr_pro = old_tables[0];
#if portNUM_PROCESSORS > 1
syscall_table_ptr_app = old_tables[1];
#endif
ESP_EARLY_LOGV(TAG, "Free apptrace down buf");
free(down_buf);
ESP_EARLY_LOGV(TAG, "Finish file transfer session");
@ -102,6 +110,7 @@ static int esp_dbg_stub_gcov_dump_do(void)
if (ret != ESP_OK) {
ESP_EARLY_LOGE(TAG, "Failed to send files transfer stop cmd (%d)!", ret);
}
ESP_EARLY_LOGV(TAG, "exit %d", ret);
return ret;
}
@ -155,7 +164,9 @@ void esp_gcov_dump(void)
void *gcov_rtio_fopen(const char *path, const char *mode)
{
ESP_EARLY_LOGV(TAG, "%s '%s' '%s'", __FUNCTION__, path, mode);
return esp_apptrace_fopen(ESP_APPTRACE_DEST_TRAX, path, mode);
void *f = esp_apptrace_fopen(ESP_APPTRACE_DEST_TRAX, path, mode);
ESP_EARLY_LOGV(TAG, "%s ret %p", __FUNCTION__, f);
return f;
}
int gcov_rtio_fclose(void *stream)