On 27.08.2025 10:18, Nikita Smirnov wrote:
Assembly mapping works correctly now. However, it seems that now I can't
access the local variable information:

```bash
tcc -gdwarf -o main.exe main.c
gdb main
(gdb) b main
Breakpoint 1 at 0x40100b: file main.c, line 3.
(gdb) r
Thread 1 hit Breakpoint 1, main () at main.c:3
3               int test = 255;
(gdb) info locals
test = <error reading variable test (Cannot access memory at address
0x10014fefc)>
(gdb) p test
Cannot access memory at address 0x10014fefc

You could try the patch below (cast to long in two
lines, tccdbg.c).

-- gr

@@ -2208,11 +2208,11 @@ static void tcc_debug_finish (TCCState *s1, struct 
_debug_info *cur)
 #endif
                }
                else {
                    /* param/local */
-                    dwarf_data1(dwarf_info_section, 
dwarf_sleb128_size(s->value) + 1);
+                    dwarf_data1(dwarf_info_section, 
dwarf_sleb128_size((long)s->value) + 1);
                     dwarf_data1(dwarf_info_section, DW_OP_fbreg);
-                    dwarf_sleb128(dwarf_info_section, s->value);
+                    dwarf_sleb128(dwarf_info_section, (long)s->value);
                }
                tcc_free (s->str);
             }
             tcc_free (cur->sym);


_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to