printf(" -m module_file\n");
printf(" load the specified module (aka plugin)\n");
printf("\n");
+ printf(" -X\n");
+ printf(" enable tracing of core data structure changes. for debugging\n");
+ printf("\n");
printf(" -M\n");
printf(" will slightly randomize allocated pointer addresses. for debugging\n");
printf("\n");
}
int opt;
- while ((opt = getopt(argc, argv, "MAQTVSm:f:Hh:b:o:p:l:qv:tds:c:")) != -1)
+ while ((opt = getopt(argc, argv, "MXAQTVSm:f:Hh:b:o:p:l:qv:tds:c:")) != -1)
{
switch (opt)
{
case 'M':
memhasher_on();
break;
+ case 'X':
+ yosys_xtrace++;
+ break;
case 'A':
call_abort = true;
break;
# include <sys/time.h>
#endif
+#ifdef __linux__
+# include <dlfcn.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
log_flush();
}
+void log_backtrace(const char *prefix, int levels)
+{
+#ifdef __linux__
+ if (levels <= 0) return;
+
+ Dl_info dli;
+ void *p;
+
+ if ((p = __builtin_extract_return_addr(__builtin_return_address(0))) && dladdr(p, &dli)) {
+ log("%sframe #1: %p %s(%p) %s(%p)\n", prefix, p, dli.dli_fname, dli.dli_fbase, dli.dli_sname, dli.dli_saddr);
+ } else {
+ log("%sframe #1: ---\n", prefix);
+ return;
+ }
+
+ if (levels <= 1) return;
+
+ if ((p = __builtin_extract_return_addr(__builtin_return_address(1))) && dladdr(p, &dli)) {
+ log("%sframe #2: %p %s(%p) %s(%p)\n", prefix, p, dli.dli_fname, dli.dli_fbase, dli.dli_sname, dli.dli_saddr);
+ } else {
+ log("%sframe #2: ---\n", prefix);
+ return;
+ }
+
+ if (levels <= 2) return;
+
+ if ((p = __builtin_extract_return_addr(__builtin_return_address(2))) && dladdr(p, &dli)) {
+ log("%sframe #3: %p %s(%p) %s(%p)\n", prefix, p, dli.dli_fname, dli.dli_fbase, dli.dli_sname, dli.dli_saddr);
+ } else {
+ log("%sframe #3: ---\n", prefix);
+ return;
+ }
+
+ if (levels <= 3) return;
+
+ if ((p = __builtin_extract_return_addr(__builtin_return_address(3))) && dladdr(p, &dli)) {
+ log("%sframe #4: %p %s(%p) %s(%p)\n", prefix, p, dli.dli_fname, dli.dli_fbase, dli.dli_sname, dli.dli_saddr);
+ } else {
+ log("%sframe #4: ---\n", prefix);
+ return;
+ }
+
+ if (levels <= 4) return;
+
+ if ((p = __builtin_extract_return_addr(__builtin_return_address(4))) && dladdr(p, &dli)) {
+ log("%sframe #5: %p %s(%p) %s(%p)\n", prefix, p, dli.dli_fname, dli.dli_fbase, dli.dli_sname, dli.dli_saddr);
+ } else {
+ log("%sframe #5: ---\n", prefix);
+ return;
+ }
+
+ if (levels <= 5) return;
+
+ if ((p = __builtin_extract_return_addr(__builtin_return_address(5))) && dladdr(p, &dli)) {
+ log("%sframe #6: %p %s(%p) %s(%p)\n", prefix, p, dli.dli_fname, dli.dli_fbase, dli.dli_sname, dli.dli_saddr);
+ } else {
+ log("%sframe #6: ---\n", prefix);
+ return;
+ }
+
+ if (levels <= 6) return;
+
+ if ((p = __builtin_extract_return_addr(__builtin_return_address(6))) && dladdr(p, &dli)) {
+ log("%sframe #7: %p %s(%p) %s(%p)\n", prefix, p, dli.dli_fname, dli.dli_fbase, dli.dli_sname, dli.dli_saddr);
+ } else {
+ log("%sframe #7: ---\n", prefix);
+ return;
+ }
+
+ if (levels <= 7) return;
+
+ if ((p = __builtin_extract_return_addr(__builtin_return_address(7))) && dladdr(p, &dli)) {
+ log("%sframe #8: %p %s(%p) %s(%p)\n", prefix, p, dli.dli_fname, dli.dli_fbase, dli.dli_sname, dli.dli_saddr);
+ } else {
+ log("%sframe #8: ---\n", prefix);
+ return;
+ }
+
+ if (levels <= 8) return;
+
+ if ((p = __builtin_extract_return_addr(__builtin_return_address(8))) && dladdr(p, &dli)) {
+ log("%sframe #9: %p %s(%p) %s(%p)\n", prefix, p, dli.dli_fname, dli.dli_fbase, dli.dli_sname, dli.dli_saddr);
+ } else {
+ log("%sframe #9: ---\n", prefix);
+ return;
+ }
+
+ if (levels <= 9) return;
+#endif
+}
+
void log_reset_stack()
{
while (header_count.size() > 1)
void log_push();
void log_pop();
+void log_backtrace(const char *prefix, int levels);
void log_reset_stack();
void log_flush();
for (auto mon : monitors)
mon->notify_module_add(module);
+
+ if (yosys_xtrace) {
+ log("#X# New Module: %s\n", log_id(module));
+ log_backtrace("-X- ", yosys_xtrace-1);
+ }
}
RTLIL::Module *RTLIL::Design::addModule(RTLIL::IdString name)
for (auto mon : monitors)
mon->notify_module_add(module);
+ if (yosys_xtrace) {
+ log("#X# New Module: %s\n", log_id(module));
+ log_backtrace("-X- ", yosys_xtrace-1);
+ }
+
return module;
}
for (auto mon : monitors)
mon->notify_module_del(module);
+ if (yosys_xtrace) {
+ log("#X# Remove Module: %s\n", log_id(module));
+ log_backtrace("-X- ", yosys_xtrace-1);
+ }
+
log_assert(modules_.at(module->name) == module);
modules_.erase(module->name);
delete module;
for (auto mon : design->monitors)
mon->notify_connect(this, conn);
+ if (yosys_xtrace) {
+ log("#X# Connect (SigSig) in %s: %s = %s (%d bits)\n", log_id(this), log_signal(conn.first), log_signal(conn.second), GetSize(conn.first));
+ log_backtrace("-X- ", yosys_xtrace-1);
+ }
+
connections_.push_back(conn);
}
for (auto mon : design->monitors)
mon->notify_connect(this, new_conn);
+ if (yosys_xtrace) {
+ log("#X# New connections vector in %s:\n", log_id(this));
+ for (auto &conn: new_conn)
+ log("#X# %s = %s (%d bits)\n", log_signal(conn.first), log_signal(conn.second), GetSize(conn.first));
+ log_backtrace("-X- ", yosys_xtrace-1);
+ }
+
connections_ = new_conn;
}
for (auto mon : module->design->monitors)
mon->notify_connect(this, conn_it->first, conn_it->second, signal);
+ if (yosys_xtrace) {
+ log("#X# Unconnect %s.%s.%s\n", log_id(this->module), log_id(this), log_id(portname));
+ log_backtrace("-X- ", yosys_xtrace-1);
+ }
+
connections_.erase(conn_it);
}
}
for (auto mon : module->design->monitors)
mon->notify_connect(this, conn_it->first, conn_it->second, signal);
+ if (yosys_xtrace) {
+ log("#X# Connect %s.%s.%s = %s (%d)\n", log_id(this->module), log_id(this), log_id(portname), log_signal(signal), GetSize(signal));
+ log_backtrace("-X- ", yosys_xtrace-1);
+ }
+
conn_it->second = signal;
}
global_id_storage_.at(idx) = strdup(p);
global_id_index_[global_id_storage_.at(idx)] = idx;
global_refcount_storage_.at(idx)++;
+
+ if (yosys_xtrace) {
+ log("#X# New IdString '%s' with index %d.\n", p, idx);
+ log_backtrace("-X- ", yosys_xtrace-1);
+ }
+
return idx;
}
if (--global_refcount_storage_.at(idx) != 0)
return;
+ if (yosys_xtrace) {
+ log("#X# Removed IdString '%s' with index %d.\n", global_id_storage_.at(idx), idx);
+ log_backtrace("-X- ", yosys_xtrace-1);
+ }
+
global_id_index_.erase(global_id_storage_.at(idx));
free(global_id_storage_.at(idx));
global_id_storage_.at(idx) = nullptr;
YOSYS_NAMESPACE_BEGIN
int autoidx = 1;
+int yosys_xtrace = 0;
RTLIL::Design *yosys_design = NULL;
#ifdef YOSYS_ENABLE_TCL
int GetSize(RTLIL::Wire *wire);
extern int autoidx;
+extern int yosys_xtrace;
YOSYS_NAMESPACE_END