tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] #line 0 in tcc


From: Levo D
Subject: [Tinycc-devel] #line 0 in tcc
Date: Tue, 21 Feb 2023 05:37:21 +0000 (UTC)

I get reasonable results with the current tcc but I wanted to report this 
anyway. This isn't a bug, it's something I noticed.

With gcc and clang I can write `#line 0` which means skip the next line. In tcc 
writing #line 0 seems to cause gdb to leave main. As a fix I emit the line 
number as the last line seen. This works completely fine. I do notice that if I 
do this, stepping from a = 1 to the next line will go to line 7 of the fake 
file (else closing curly brace). If I use #line 0 in clang or gcc it will go 
from line 4 to line 8, no else curly brace.

This is completely fine but I wanted to report in case the fix is dead simple 
and someone happens to be working on that part of code

A related change on my wishlist is to be able to hide variables. As you can see 
I assign values to a hidden variable. With clang I can write "int64_t 
_unnamed123 __attribute__((nodebug)) = 987;". GDB won't show _unnamed123. 
However this only works in clang, gcc ignores the attribute and I'll see 
_unnamed123 in the debugger. If there's a variable prefix I can use to hide 
variables or an attribute I can use that'd help my debugging experience by a lot

Fake C file /tmp/test.c

        my main() {
                a init 0
                if a is 10 {
                        a = 1
                } else {
                        a = 2
                }
                a = 4
                a = 50
        }

Compile with -g

        #line 1 "/tmp/test.c"
        int main() {
                #line 1
                int hidden = 1;
                #line 2
                int a = 0;
                #line 3
                if (a == 0) {
                        #line 4
                        a = 1;
                        #line   4
                        hidden = 10;
                        #line 5
                } else {
                        #line 6
                        a = 2;
                        #line    6
                        hidden = 20;
                        #line 7
                }
                #line   7
                hidden = 100;
                #line   7
                hidden = 101;
                #line   7
                hidden = 102;
                #line   7
                hidden = 103;
                #line 8
                a = 4;
                #line 9
                a = 50;
                return 0;
        }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]