mirror of https://github.com/rui314/chibicc
Emit .file and .loc assembler directives
With these directives, gdb can print out an error location when a compiled program crashes.
This commit is contained in:
parent
6647ad9b84
commit
1c91d1943a
|
@ -89,6 +89,8 @@ static void store(Type *ty) {
|
|||
|
||||
// Generate code for a given node.
|
||||
static void gen_expr(Node *node) {
|
||||
println(" .loc 1 %d", node->tok->line_no);
|
||||
|
||||
switch (node->kind) {
|
||||
case ND_NUM:
|
||||
println(" mov $%d, %%rax", node->val);
|
||||
|
@ -177,6 +179,8 @@ static void gen_expr(Node *node) {
|
|||
}
|
||||
|
||||
static void gen_stmt(Node *node) {
|
||||
println(" .loc 1 %d", node->tok->line_no);
|
||||
|
||||
switch (node->kind) {
|
||||
case ND_IF: {
|
||||
int c = count();
|
||||
|
|
Loading…
Reference in New Issue