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
4c4d1e6d92
commit
ce4d744609
|
@ -88,6 +88,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);
|
||||
|
@ -172,6 +174,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