tinygo
tinygo copied to clipboard
gdb can't print local variables, they're always "optimized out"?
On linux on amd64, gdb can do info variables
to see globals, but info locals
usually lists all the variables as optimized out.
This is the case even with
tinygo -opt 1
I can't go lower; opt 0 fails with
panic: unexpected getFuncPtrCall
goroutine 12 [running]:
github.com/tinygo-org/tinygo/transform.LowerFuncValues(0x7ff9b0002ac0)
/home/dank/src/tinygo/transform/func-lowering.go:191 +0x11d4
github.com/tinygo-org/tinygo/transform.Optimize(0x7ff9b0002ac0, 0xc0002be0f0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/dank/src/tinygo/transform/optimizer.go:110 +0x1258
github.com/tinygo-org/tinygo/builder.optimizeProgram(0x7ff9b0002ac0, 0xc0002be0f0, 0xc00114f1d0, 0x2)
/home/dank/src/tinygo/builder/build.go:603 +0x122
github.com/tinygo-org/tinygo/builder.Build.func2(0x0, 0x0)
/home/dank/src/tinygo/builder/build.go:304 +0x812
github.com/tinygo-org/tinygo/builder.jobWorker(0xc00065b260, 0xc00065b200)
/home/dank/src/tinygo/builder/jobs.go:153 +0xe2
(This is with dev from mar 29, 35bf0746a178c, to work around the crash https://github.com/tinygo-org/tinygo/issues/1805 .)
I'm running into the same while debugging Raspberry Pi Pico on an Ubuntu 22.04 host. Combining this with not being able to figure out how to redirect stdout to UART (instead of USB) when using a picoprobe, I'm finding debugging to be more difficult.
@MikeJansen you possibly want the -serial
flag:
-serial string
which serial output to use (none, uart, usb)
Beware that this can have side effects like making it required to use debugger to reflash the board if you replace USB serial output support.
Beware that this can have side effects like making it required to use debugger to reflash the board if you replace USB serial output support.
You may need to enter the bootloader manually using double tapping or by holding the boot button while resetting, but I don't think you'd need a hardware debugger? The rp2040 chips have the bootloader in hardware.