Add debug information.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Add debug information.

tinycc-devel mailing list
I created a path to add debug type information (see attachment).

The patch only supports basic types and array/ptr types of them.

So:
int main(int argc, char *argv[])

is supported.

Other things like structs/unions/enums/bitfields are all translated to void.
This should probably change in the future.

I also generate a new type whenever I see a pointer or array.
This creates a lot of types but gdb seems happy with it.
If I compile tcc with bounds-checking I see 1473 types.
In the future types should be optimized.

Can I apply this patch?

Regards,

     Herman

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

patch (10K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Add debug information.

tinycc-devel mailing list
Oops. Sent the wrong patch. See correct one in attachment.

Herman

On 2020-01-18 18:24, Herman ten Brugge wrote:

> I created a path to add debug type information (see attachment).
>
> The patch only supports basic types and array/ptr types of them.
>
> So:
> int main(int argc, char *argv[])
>
> is supported.
>
> Other things like structs/unions/enums/bitfields are all translated to
> void.
> This should probably change in the future.
>
> I also generate a new type whenever I see a pointer or array.
> This creates a lot of types but gdb seems happy with it.
> If I compile tcc with bounds-checking I see 1473 types.
> In the future types should be optimized.
>
> Can I apply this patch?
>
> Regards,
>
>     Herman

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

patch (10K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Add debug information.

Michael Matz-4
Hello,

On Sat, 18 Jan 2020, Herman ten Brugge via Tinycc-devel wrote:

> Oops. Sent the wrong patch. See correct one in attachment.
>
>>  I created a path to add debug type information (see attachment).
>>
>>  The patch only supports basic types and array/ptr types of them.

It also doesn't deal with scopes, i.e. represents this incorrectly:

int foo (void) {
   int i = 1;
   float f;
   if (i) {
     float i = 1.0;
     f = i;
   }
   return i + f;
}

It's still useful, of course, also with the limitation.  Some time ago I
approached the debug problem from that angle first before dealing with
types, see attached patch (which makes all variable be int).  But I didn't
like the outcome in that it uses a new data structure for the scopes and
the associated book keeping.  The difficulty with stabs is that the
variables for a scope need to be emitted directly _before_ the scope-open
stab, which really goes against the structure of TCCs parser, as the
open/close stabs still need to form a correct nesting, so there's no
natural place to emit the variable stabs :-/


Ciao,
Michael.

>>
>>  So:
>>  int main(int argc, char *argv[])
>>
>>  is supported.
>>
>>  Other things like structs/unions/enums/bitfields are all translated to
>>  void.
>>  This should probably change in the future.
>>
>>  I also generate a new type whenever I see a pointer or array.
>>  This creates a lot of types but gdb seems happy with it.
>>  If I compile tcc with bounds-checking I see 1473 types.
>>  In the future types should be optimized.
>>
>>  Can I apply this patch?
_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

tcc-add-dbg.diff (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Add debug information.

Christian Jullien-3
In reply to this post by tinycc-devel mailing list
Hi Michael,

On Windows I get this error for 113_btdll new test:

Test: 113_btdll...
a1:1: error: unrecognized character \x00
--- 113_btdll.expect    2020-01-19 14:19:07.618126600 +0100
+++ 113_btdll.output    1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +0,0 @@
-113_btdll.c:12: at f_1: hello from f_1() / 113_btdll.c:12
-113_btdll.c:37: by main
-113_btdll.c:20: at f_2: hello from f_2() / 113_btdll.c:20
-113_btdll.c:38: by main
-113_btdll.c:31: at f_main: hello from f_main() / 113_btdll.c:31
-113_btdll.c:39: by main
make[2]: *** [Makefile:93: 113_btdll.test] Error 1
make[2]: Target 'all' not remade because of errors.
make[1]: *** [Makefile:99: tests2-dir] Error 2

-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]]
On Behalf Of Michael Matz
Sent: Monday, January 20, 2020 01:38
To: Herman ten Brugge via Tinycc-devel
Cc: Herman ten Brugge
Subject: *** SPAM *** Re: [Tinycc-devel] Add debug information.

Hello,

On Sat, 18 Jan 2020, Herman ten Brugge via Tinycc-devel wrote:

> Oops. Sent the wrong patch. See correct one in attachment.
>
>>  I created a path to add debug type information (see attachment).
>>
>>  The patch only supports basic types and array/ptr types of them.

It also doesn't deal with scopes, i.e. represents this incorrectly:

int foo (void) {
   int i = 1;
   float f;
   if (i) {
     float i = 1.0;
     f = i;
   }
   return i + f;
}

It's still useful, of course, also with the limitation.  Some time ago I
approached the debug problem from that angle first before dealing with
types, see attached patch (which makes all variable be int).  But I didn't
like the outcome in that it uses a new data structure for the scopes and the
associated book keeping.  The difficulty with stabs is that the variables
for a scope need to be emitted directly _before_ the scope-open stab, which
really goes against the structure of TCCs parser, as the open/close stabs
still need to form a correct nesting, so there's no natural place to emit
the variable stabs :-/


Ciao,
Michael.

>>
>>  So:
>>  int main(int argc, char *argv[])
>>
>>  is supported.
>>
>>  Other things like structs/unions/enums/bitfields are all translated
>> to  void.
>>  This should probably change in the future.
>>
>>  I also generate a new type whenever I see a pointer or array.
>>  This creates a lot of types but gdb seems happy with it.
>>  If I compile tcc with bounds-checking I see 1473 types.
>>  In the future types should be optimized.
>>
>>  Can I apply this patch?


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Add debug information.

tinycc-devel mailing list
In reply to this post by Michael Matz-4
On 2020-01-20 01:37, Michael Matz wrote:

> Hello,
>
> On Sat, 18 Jan 2020, Herman ten Brugge via Tinycc-devel wrote:
>
>> Oops. Sent the wrong patch. See correct one in attachment.
>>
>>>  I created a path to add debug type information (see attachment).
>>>
>>>  The patch only supports basic types and array/ptr types of them.
>
> It also doesn't deal with scopes, i.e. represents this incorrectly:
>
> int foo (void) {
>   int i = 1;
>   float f;
>   if (i) {
>     float i = 1.0;
>     f = i;
>   }
>   return i + f;
> }
>
> It's still useful, of course, also with the limitation.  Some time ago
> I approached the debug problem from that angle first before dealing
> with types, see attached patch (which makes all variable be int).  But
> I didn't like the outcome in that it uses a new data structure for the
> scopes and the associated book keeping.  The difficulty with stabs is
> that the variables for a scope need to be emitted directly _before_
> the scope-open stab, which really goes against the structure of TCCs
> parser, as the open/close stabs still need to form a correct nesting,
> so there's no natural place to emit the variable stabs :-/
>
I updated the patch. It now uses LBRAC/RBRAC. I also fixed some other
minor problems.
I also had to use a new struct to save debugging info. With stabs you
also cannot mix LINE info and SYM info.

With the current patch debugging is a lot easier.
In a followed up patch I will probably add support for
structs/unions/enums/bitfields.
This will take some time. Stabs format is a bit difficult to implement
correctly.

This also has to wait until the end of next month.

Regards,

     Herman


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

patch (11K) Download Attachment