Fix repeated REPT nodes in backtraces

This commit is contained in:
Rangi
2025-10-06 16:36:55 -04:00
parent 0c9920d4a6
commit fba0562650
11 changed files with 145 additions and 55 deletions

View File

@@ -11,6 +11,10 @@
#include "style.hpp" #include "style.hpp"
#define TRACE_SEPARATOR "<-"
#define NODE_SEPARATOR "::"
#define REPT_NODE_PREFIX "REPT~"
struct Tracing { struct Tracing {
uint64_t depth = 0; uint64_t depth = 0;
bool collapse = false; bool collapse = false;
@@ -34,7 +38,7 @@ void trace_PrintBacktrace(std::vector<T> const &stack, M getName, N getLineNo) {
if (!tracing.collapse) { if (!tracing.collapse) {
fputs(" ", stderr); // Just three spaces; the fourth will be printed next fputs(" ", stderr); // Just three spaces; the fourth will be printed next
} }
fprintf(stderr, " %s ", i == 0 ? "at" : "<-"); fprintf(stderr, " %s ", i == 0 ? "at" : TRACE_SEPARATOR);
style_Set(stderr, STYLE_CYAN, true); style_Set(stderr, STYLE_CYAN, true);
fputs(getName(item), stderr); fputs(getName(item), stderr);
style_Set(stderr, STYLE_CYAN, false); style_Set(stderr, STYLE_CYAN, false);
@@ -62,7 +66,7 @@ void trace_PrintBacktrace(std::vector<T> const &stack, M getName, N getLineNo) {
style_Reset(stderr); style_Reset(stderr);
if (tracing.collapse) { if (tracing.collapse) {
fputs(" <-", stderr); fputs(" " TRACE_SEPARATOR, stderr);
} else { } else {
fputs(" ", stderr); // Just three spaces; the fourth will be printed next fputs(" ", stderr); // Just three spaces; the fourth will be printed next
} }

View File

@@ -56,16 +56,6 @@ static std::vector<std::string> includePaths = {""}; // -I
static std::deque<std::string> preIncludeNames; // -P static std::deque<std::string> preIncludeNames; // -P
static bool failedOnMissingInclude = false; static bool failedOnMissingInclude = false;
static std::string reptChain(FileStackNode const &node) {
std::string chain;
std::vector<uint32_t> const &nodeIters = node.iters();
for (uint32_t i = nodeIters.size(); i--;) {
chain.append("::REPT~");
chain.append(std::to_string(nodeIters[i]));
}
return chain;
}
using TraceNode = std::pair<std::string, uint32_t>; using TraceNode = std::pair<std::string, uint32_t>;
static std::vector<TraceNode> backtrace(FileStackNode const &node, uint32_t curLineNo) { static std::vector<TraceNode> backtrace(FileStackNode const &node, uint32_t curLineNo) {
@@ -89,7 +79,12 @@ static std::vector<TraceNode> backtrace(FileStackNode const &node, uint32_t curL
std::vector<TraceNode> traceNodes = backtrace(*node.parent, node.lineNo); std::vector<TraceNode> traceNodes = backtrace(*node.parent, node.lineNo);
if (std::holds_alternative<std::vector<uint32_t>>(node.data)) { if (std::holds_alternative<std::vector<uint32_t>>(node.data)) {
assume(!traceNodes.empty()); // REPT nodes use their parent's name assume(!traceNodes.empty()); // REPT nodes use their parent's name
traceNodes.emplace_back(traceNodes.back().first + reptChain(node), curLineNo); std::string reptName = traceNodes.back().first;
if (std::vector<uint32_t> const &nodeIters = node.iters(); !nodeIters.empty()) {
reptName.append(NODE_SEPARATOR REPT_NODE_PREFIX);
reptName.append(std::to_string(nodeIters.front()));
}
traceNodes.emplace_back(reptName, curLineNo);
} else { } else {
traceNodes.emplace_back(node.name(), curLineNo); traceNodes.emplace_back(node.name(), curLineNo);
} }
@@ -299,9 +294,13 @@ static void
} }
} }
if (macro.src->type == NODE_REPT) { if (macro.src->type == NODE_REPT) {
fileInfoName.append(reptChain(*macro.src)); std::vector<uint32_t> const &srcIters = macro.src->iters();
for (uint32_t i = srcIters.size(); i--;) {
fileInfoName.append(NODE_SEPARATOR REPT_NODE_PREFIX);
fileInfoName.append(std::to_string(srcIters[i]));
}
} }
fileInfoName.append("::"); fileInfoName.append(NODE_SEPARATOR);
fileInfoName.append(macro.name); fileInfoName.append(macro.name);
auto fileInfo = std::make_shared<FileStackNode>(NODE_MACRO, fileInfoName, isQuiet); auto fileInfo = std::make_shared<FileStackNode>(NODE_MACRO, fileInfoName, isQuiet);

View File

@@ -35,12 +35,12 @@ static std::vector<TraceNode> backtrace(FileStackNode const &node, uint32_t curL
std::vector<TraceNode> traceNodes = backtrace(*node.parent, node.lineNo); std::vector<TraceNode> traceNodes = backtrace(*node.parent, node.lineNo);
if (std::holds_alternative<std::vector<uint32_t>>(node.data)) { if (std::holds_alternative<std::vector<uint32_t>>(node.data)) {
assume(!traceNodes.empty()); // REPT nodes use their parent's name assume(!traceNodes.empty()); // REPT nodes use their parent's name
std::string reptChain = traceNodes.back().first; std::string reptName = traceNodes.back().first;
for (uint32_t iter : node.iters()) { if (std::vector<uint32_t> const &nodeIters = node.iters(); !nodeIters.empty()) {
reptChain.append("::REPT~"); reptName.append(NODE_SEPARATOR REPT_NODE_PREFIX);
reptChain.append(std::to_string(iter)); reptName.append(std::to_string(nodeIters.back()));
} }
traceNodes.emplace_back(reptChain, curLineNo); traceNodes.emplace_back(reptName, curLineNo);
} else { } else {
traceNodes.emplace_back(node.name(), curLineNo); traceNodes.emplace_back(node.name(), curLineNo);
} }

View File

@@ -9,10 +9,10 @@ warning: Line 5 [-Wuser]
warning: Line 8 [-Wuser] warning: Line 8 [-Wuser]
at rept-line-no.asm(8) at rept-line-no.asm(8)
warning: Line 12 [-Wuser] warning: Line 12 [-Wuser]
at rept-line-no.asm::REPT~1::REPT~1::REPT~1(12) <- rept-line-no.asm::REPT~1(11) <- rept-line-no.asm(10) at rept-line-no.asm::REPT~1::REPT~1(12) <- rept-line-no.asm::REPT~1(11) <- rept-line-no.asm(10)
warning: Line 12 [-Wuser] warning: Line 12 [-Wuser]
at rept-line-no.asm::REPT~1::REPT~1::REPT~2(12) <- rept-line-no.asm::REPT~1(11) <- rept-line-no.asm(10) at rept-line-no.asm::REPT~1::REPT~2(12) <- rept-line-no.asm::REPT~1(11) <- rept-line-no.asm(10)
warning: Line 12 [-Wuser] warning: Line 12 [-Wuser]
at rept-line-no.asm::REPT~2::REPT~2::REPT~1(12) <- rept-line-no.asm::REPT~2(11) <- rept-line-no.asm(10) at rept-line-no.asm::REPT~2::REPT~1(12) <- rept-line-no.asm::REPT~2(11) <- rept-line-no.asm(10)
warning: Line 12 [-Wuser] warning: Line 12 [-Wuser]
at rept-line-no.asm::REPT~2::REPT~2::REPT~2(12) <- rept-line-no.asm::REPT~2(11) <- rept-line-no.asm(10) at rept-line-no.asm::REPT~2::REPT~2(12) <- rept-line-no.asm::REPT~2(11) <- rept-line-no.asm(10)

View File

@@ -1,5 +1,5 @@
warning: round 1 [-Wuser] warning: round 1 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1::REPT~1::REPT~1(13) at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1::REPT~1(13)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1(12) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1(12)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~1(13) <- rept-macro-fstack-trace.asm::outer::REPT~1(13)
@@ -7,7 +7,7 @@ warning: round 1 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 2 [-Wuser] warning: round 2 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1::REPT~1::REPT~2(13) at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1::REPT~2(13)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1(12) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1(12)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~1(13) <- rept-macro-fstack-trace.asm::outer::REPT~1(13)
@@ -15,7 +15,7 @@ warning: round 2 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 3 [-Wuser] warning: round 3 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2::REPT~2::REPT~1(13) at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2::REPT~1(13)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2(12) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2(12)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~1(13) <- rept-macro-fstack-trace.asm::outer::REPT~1(13)
@@ -23,7 +23,7 @@ warning: round 3 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 4 [-Wuser] warning: round 4 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2::REPT~2::REPT~2(13) at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2::REPT~2(13)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2(12) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2(12)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~1(13) <- rept-macro-fstack-trace.asm::outer::REPT~1(13)
@@ -31,7 +31,7 @@ warning: round 4 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 5 [-Wuser] warning: round 5 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1::REPT~1::REPT~1(13) at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1::REPT~1(13)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1(12) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1(12)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~2(13) <- rept-macro-fstack-trace.asm::outer::REPT~2(13)
@@ -39,7 +39,7 @@ warning: round 5 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 6 [-Wuser] warning: round 6 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1::REPT~1::REPT~2(13) at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1::REPT~2(13)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1(12) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1(12)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~2(13) <- rept-macro-fstack-trace.asm::outer::REPT~2(13)
@@ -47,7 +47,7 @@ warning: round 6 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 7 [-Wuser] warning: round 7 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2::REPT~2::REPT~1(13) at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2::REPT~1(13)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2(12) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2(12)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~2(13) <- rept-macro-fstack-trace.asm::outer::REPT~2(13)
@@ -55,7 +55,7 @@ warning: round 7 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 8 [-Wuser] warning: round 8 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2::REPT~2::REPT~2(13) at rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2::REPT~2(13)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2(12) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2(12)
<- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~1::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~2(13) <- rept-macro-fstack-trace.asm::outer::REPT~2(13)
@@ -63,7 +63,7 @@ warning: round 8 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 9 [-Wuser] warning: round 9 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1::REPT~1::REPT~1(13) at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1::REPT~1(13)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1(12) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1(12)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~3(13) <- rept-macro-fstack-trace.asm::outer::REPT~3(13)
@@ -71,7 +71,7 @@ warning: round 9 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 10 [-Wuser] warning: round 10 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1::REPT~1::REPT~2(13) at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1::REPT~2(13)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1(12) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1(12)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~3(13) <- rept-macro-fstack-trace.asm::outer::REPT~3(13)
@@ -79,7 +79,7 @@ warning: round 10 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 11 [-Wuser] warning: round 11 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2::REPT~2::REPT~1(13) at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2::REPT~1(13)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2(12) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2(12)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~3(13) <- rept-macro-fstack-trace.asm::outer::REPT~3(13)
@@ -87,7 +87,7 @@ warning: round 11 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 12 [-Wuser] warning: round 12 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2::REPT~2::REPT~2(13) at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2::REPT~2(13)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2(12) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2(12)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~3(13) <- rept-macro-fstack-trace.asm::outer::REPT~3(13)
@@ -95,7 +95,7 @@ warning: round 12 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 13 [-Wuser] warning: round 13 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1::REPT~1::REPT~1(13) at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1::REPT~1(13)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1(12) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1(12)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~4(13) <- rept-macro-fstack-trace.asm::outer::REPT~4(13)
@@ -103,7 +103,7 @@ warning: round 13 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 14 [-Wuser] warning: round 14 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1::REPT~1::REPT~2(13) at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1::REPT~2(13)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1(12) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1(12)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~4(13) <- rept-macro-fstack-trace.asm::outer::REPT~4(13)
@@ -111,7 +111,7 @@ warning: round 14 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 15 [-Wuser] warning: round 15 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2::REPT~2::REPT~1(13) at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2::REPT~1(13)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2(12) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2(12)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~4(13) <- rept-macro-fstack-trace.asm::outer::REPT~4(13)
@@ -119,7 +119,7 @@ warning: round 15 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 16 [-Wuser] warning: round 16 [-Wuser]
at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2::REPT~2::REPT~2(13) at rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2::REPT~2(13)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2(12) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2(12)
<- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) <- rept-macro-fstack-trace.asm::outer::REPT~3::inner(11)
<- rept-macro-fstack-trace.asm::outer::REPT~4(13) <- rept-macro-fstack-trace.asm::outer::REPT~4(13)
@@ -127,42 +127,42 @@ warning: round 16 [-Wuser]
<- rept-macro-fstack-trace.asm::REPT~1(18) <- rept-macro-fstack-trace.asm::REPT~1(18)
<- rept-macro-fstack-trace.asm(17) <- rept-macro-fstack-trace.asm(17)
warning: round 17 [-Wuser] warning: round 17 [-Wuser]
at rept-macro-fstack-trace.asm::foo::REPT~1::REPT~1::REPT~1(24) at rept-macro-fstack-trace.asm::foo::REPT~1::REPT~1(24)
<- rept-macro-fstack-trace.asm::foo::REPT~1(23) <- rept-macro-fstack-trace.asm::foo::REPT~1(23)
<- rept-macro-fstack-trace.asm::foo(22) <- rept-macro-fstack-trace.asm::foo(22)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~1::REPT~1::REPT~1(34) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~1::REPT~1(34)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~1(33) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~1(33)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar(32) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar(32)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::REPT~1(38) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1(38)
<- rept-macro-fstack-trace.asm::REPT~1(30) <- rept-macro-fstack-trace.asm::REPT~1(30)
<- rept-macro-fstack-trace.asm(29) <- rept-macro-fstack-trace.asm(29)
warning: round 18 [-Wuser] warning: round 18 [-Wuser]
at rept-macro-fstack-trace.asm::foo::REPT~1::REPT~1::REPT~1(24) at rept-macro-fstack-trace.asm::foo::REPT~1::REPT~1(24)
<- rept-macro-fstack-trace.asm::foo::REPT~1(23) <- rept-macro-fstack-trace.asm::foo::REPT~1(23)
<- rept-macro-fstack-trace.asm::foo(22) <- rept-macro-fstack-trace.asm::foo(22)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~1::REPT~1::REPT~2(34) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~1::REPT~2(34)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~1(33) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~1(33)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar(32) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar(32)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::REPT~1(38) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1(38)
<- rept-macro-fstack-trace.asm::REPT~1(30) <- rept-macro-fstack-trace.asm::REPT~1(30)
<- rept-macro-fstack-trace.asm(29) <- rept-macro-fstack-trace.asm(29)
warning: round 19 [-Wuser] warning: round 19 [-Wuser]
at rept-macro-fstack-trace.asm::foo::REPT~1::REPT~1::REPT~1(24) at rept-macro-fstack-trace.asm::foo::REPT~1::REPT~1(24)
<- rept-macro-fstack-trace.asm::foo::REPT~1(23) <- rept-macro-fstack-trace.asm::foo::REPT~1(23)
<- rept-macro-fstack-trace.asm::foo(22) <- rept-macro-fstack-trace.asm::foo(22)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~2::REPT~2::REPT~1(34) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~2::REPT~1(34)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~2(33) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~2(33)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar(32) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar(32)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::REPT~1(38) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1(38)
<- rept-macro-fstack-trace.asm::REPT~1(30) <- rept-macro-fstack-trace.asm::REPT~1(30)
<- rept-macro-fstack-trace.asm(29) <- rept-macro-fstack-trace.asm(29)
warning: round 20 [-Wuser] warning: round 20 [-Wuser]
at rept-macro-fstack-trace.asm::foo::REPT~1::REPT~1::REPT~1(24) at rept-macro-fstack-trace.asm::foo::REPT~1::REPT~1(24)
<- rept-macro-fstack-trace.asm::foo::REPT~1(23) <- rept-macro-fstack-trace.asm::foo::REPT~1(23)
<- rept-macro-fstack-trace.asm::foo(22) <- rept-macro-fstack-trace.asm::foo(22)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~2::REPT~2::REPT~2(34) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~2::REPT~2(34)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~2(33) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~2(33)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar(32) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar(32)
<- rept-macro-fstack-trace.asm::REPT~1::REPT~1::REPT~1(38) <- rept-macro-fstack-trace.asm::REPT~1::REPT~1(38)
<- rept-macro-fstack-trace.asm::REPT~1(30) <- rept-macro-fstack-trace.asm::REPT~1(30)
<- rept-macro-fstack-trace.asm(29) <- rept-macro-fstack-trace.asm(29)

23
test/asm/rept-trace.asm Normal file
View File

@@ -0,0 +1,23 @@
section "test", rom0
for v1, 4
if v1 == 3
for v2, 3
if v2 == 2
for v3, 2
if v3 == 1
rept 1
macro m
static_assert \1
endm
endr
rept 1
rept 2
m 0
endr
endr
endc
endr
endc
endr
endc
endr

17
test/asm/rept-trace.err Normal file
View File

@@ -0,0 +1,17 @@
error: Assertion failed
at rept-trace.asm::REPT~4::REPT~3::REPT~2::REPT~1::m(10)
<- rept-trace.asm::REPT~4::REPT~3::REPT~2::REPT~1::REPT~1(15)
<- rept-trace.asm::REPT~4::REPT~3::REPT~2::REPT~1(14)
<- rept-trace.asm::REPT~4::REPT~3::REPT~2(13)
<- rept-trace.asm::REPT~4::REPT~3(6)
<- rept-trace.asm::REPT~4(4)
<- rept-trace.asm(2)
error: Assertion failed
at rept-trace.asm::REPT~4::REPT~3::REPT~2::REPT~1::m(10)
<- rept-trace.asm::REPT~4::REPT~3::REPT~2::REPT~1::REPT~2(15)
<- rept-trace.asm::REPT~4::REPT~3::REPT~2::REPT~1(14)
<- rept-trace.asm::REPT~4::REPT~3::REPT~2(13)
<- rept-trace.asm::REPT~4::REPT~3(6)
<- rept-trace.asm::REPT~4(4)
<- rept-trace.asm(2)
Assembly aborted with 2 errors!

View File

@@ -0,0 +1 @@
-Bno-collapse

View File

@@ -0,0 +1,23 @@
section "test", rom0
for v1, 4
if v1 == 3
for v2, 3
if v2 == 2
for v3, 2
if v3 == 1
rept 1
macro m
assert \1
endm
endr
rept 1
rept 2
m @
endr
endr
endc
endr
endc
endr
endc
endr

View File

@@ -0,0 +1,17 @@
error: assert failure
at rept-trace/a.asm::REPT~4::REPT~3::REPT~2::REPT~1::m(10)
<- rept-trace/a.asm::REPT~4::REPT~3::REPT~2::REPT~1::REPT~1(15)
<- rept-trace/a.asm::REPT~4::REPT~3::REPT~2::REPT~1(14)
<- rept-trace/a.asm::REPT~4::REPT~3::REPT~2(13)
<- rept-trace/a.asm::REPT~4::REPT~3(6)
<- rept-trace/a.asm::REPT~4(4)
<- rept-trace/a.asm(2)
error: assert failure
at rept-trace/a.asm::REPT~4::REPT~3::REPT~2::REPT~1::m(10)
<- rept-trace/a.asm::REPT~4::REPT~3::REPT~2::REPT~1::REPT~2(15)
<- rept-trace/a.asm::REPT~4::REPT~3::REPT~2::REPT~1(14)
<- rept-trace/a.asm::REPT~4::REPT~3::REPT~2(13)
<- rept-trace/a.asm::REPT~4::REPT~3(6)
<- rept-trace/a.asm::REPT~4(4)
<- rept-trace/a.asm(2)
Linking failed with 2 errors

View File

@@ -266,13 +266,19 @@ evaluateTest
test="pipeline" test="pipeline"
startTest startTest
continueTest continueTest
("$RGBASM" -Weverything -Bcollapse -o - - | \ ("$RGBASM" -o - - | "$RGBLINK" -o - - | "$RGBFIX" -v -p 0xff -) < "$test"/a.asm > "$gbtemp"
"$RGBLINK" -Weverything -Bcollapse -o - - | \
"$RGBFIX" -Weverything -v -p 0xff -) < "$test"/a.asm > "$gbtemp"
# This test does not trim its output with 'dd' because it needs to verify the correct output size # This test does not trim its output with 'dd' because it needs to verify the correct output size
tryCmp "$test"/out.gb "$gbtemp" tryCmp "$test"/out.gb "$gbtemp"
evaluateTest evaluateTest
test="rept-trace"
startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
continueTest
rgblinkQuiet -Bno-collapse -o "$gbtemp" "$otemp" 2>"$outtemp"
tryDiff "$test"/out.err "$outtemp"
evaluateTest
test="same-consts" test="same-consts"
startTest startTest
"$RGBASM" -o "$otemp" "$test"/a.asm "$RGBASM" -o "$otemp" "$test"/a.asm