aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-19 09:26:36 +0200
committerlemon <lsof@mailbox.org>2023-06-19 09:26:36 +0200
commit8608070c077b067611b06dba72a4115a2094e124 (patch)
tree2182f418a25665f3604604182f04ba9a134165ef
parent8940a40329819ad616d68ba902cf957803faf5c4 (diff)
don't try to compile when debugging IR
-rw-r--r--io.c7
-rw-r--r--irdump.c5
-rw-r--r--main.c9
3 files changed, 13 insertions, 8 deletions
diff --git a/io.c b/io.c
index 02252ac..5c15600 100644
--- a/io.c
+++ b/io.c
@@ -356,8 +356,11 @@ vbfmt(struct wbuf *out, const char *fmt, va_list ap)
break;
case 's': /* nullterminated string */
s = va_arg(ap, const char *);
- assert(s && "%s null!");
if (quote) {
+ if (!s) {
+ n += bwriteS(buf, "(null)");
+ break;
+ }
n += bputc(buf, '"');
if (lmod) /* lower */
for (; *s; ++s) n += putquoted(buf, aisalpha(*s) ? *s|32 : *s, '"', s[1]);
@@ -365,6 +368,7 @@ vbfmt(struct wbuf *out, const char *fmt, va_list ap)
for (; *s; ++s) n += putquoted(buf, *s, '"', s[1]);
n += bputc(buf, '"');
} else {
+ assert(s && "%s null!");
if (lmod) /* lower */
for (; *s; ++s) n += bputc(buf, aisalpha(*s) ? *s|32 : *s);
else
@@ -374,6 +378,7 @@ vbfmt(struct wbuf *out, const char *fmt, va_list ap)
case 'S': /* string ptr + len */
s = va_arg(ap, const char *);
i = va_arg(ap, uint);
+ assert(s && "%S null");
if (quote) {
n += bputc(buf, '"');
for (; i--; ++s) n += putquoted(buf, *s, '"', i ? s[1] : -1);
diff --git a/irdump.c b/irdump.c
index 3736826..2d0dbf4 100644
--- a/irdump.c
+++ b/irdump.c
@@ -90,9 +90,8 @@ dumpref(enum op o, union ref ref)
break;
case RXCON:
con = &conht[ref.i];
- if (con->deref) efmt("[");
- if (con->issym) efmt("$%s", con->sym);
- else if (con->isdat) efmt("$.%d", con->dat);
+ if (con->deref) efmt("*[");
+ if (con->issym || con->isdat) efmt("$%s", xcon2sym(ref.i));
else switch (con->cls) {
case KI4: efmt("%d", (int)con->i); break;
case KI8: efmt("%ld", con->i); break;
diff --git a/main.c b/main.c
index 940fd1a..36deb57 100644
--- a/main.c
+++ b/main.c
@@ -202,7 +202,7 @@ compileobjs(void)
int wstat;
pid_t p;
- mktemps();
+ if (!ccopt.dbg.any) mktemps();
for (int i = 0; i < task.ninf; ++i) {
flushstd();
if ((p = fork()) < 0) {
@@ -218,7 +218,7 @@ compileobjs(void)
exit(WEXITSTATUS(wstat));
}
}
- atexit(cleantemps);
+ if (!ccopt.dbg.any) atexit(cleantemps);
}
static int
@@ -276,6 +276,7 @@ driver(void)
return cc1(task.out, *task.inf);
} else if (task.outft == OFTexe || task.outft == OFTdll) {
compileobjs();
+ if (ccopt.dbg.any) return 0;
return dolink();
}
assert(0);
@@ -287,10 +288,10 @@ cc1(const char *out, const char *in)
struct parser pr;
if (task.verbose) efmt("cc1(/*out*/ %'s, /*in*/ %'s)\n", out, in);
- objini(out);
+ if (!ccopt.dbg.any) objini(out);
initparser(&pr, in);
parse(&pr);
- if (!nerror) objfini();
+ if (!ccopt.dbg.any && !nerror) objfini();
return !!nerror;
}