AVR GDB (Uzem/cUzebox)

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
Post Reply
User avatar
nicksen782
Posts: 714
Joined: Wed Feb 01, 2012 8:23 pm
Location: Detroit, United States
Contact:

AVR GDB (Uzem/cUzebox)

Post by nicksen782 »

Hi! GDB appears to be a a debugger for AVR and I know that Uzem has GDB support. Does it work? Does it work like the nodejs debugger in Vscode or the JavaScript debugger in the Chrome Dev Tools? Can I place breakpoints? I've never used gdb but I have used debuggers.

Ideally I would be able to load the code in Vscode and create breakpoints where I can look at the values of variables and pause execution. I would like to do it within the emulator so that I am not constantly reflashing my Uzebox during debugging.

How can I use avr-gbd and use it with Uzem? Also, could that support be added to cUzebox?
User avatar
D3thAdd3r
Posts: 3221
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: AVR GDB (Uzem/cUzebox)

Post by D3thAdd3r »

I tried it a long time ago in Uzem and it worked. Back then I used AVRStudio...almost positive breakpoints did work. Not sure what that means for other integrations. I'd guess a debug build for cUzebox would be possible and achieve at least that.
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: AVR GDB (Uzem/cUzebox)

Post by uze6666 »

I can say that it certainly worked and that you could put breakpoints and inspect registers, but not sure about variables. Though it was always finicky and not always working. It may be due to the fact that I used it with Eclipse but I don't know. There's info about it on the wiki.

It could be added to CUzebox but I recall Jubatian was not fond of it for some reasons. Perhaps it was too intrusive and would slowdown things or complexify the code?

Another very cool option that I tried a couple years ago was using the '644 JTAG interface. I had to remove some resistors on the video DAC to plugin the JTAG pins but, coupled with a JTAG programmer, you can debug straight on the hardware from Atmel Studio, just like it's the simulator. Pretty awesome really. I used an Atmel ICE which is quite expensive though. Since the JTAG uses some of the video port pins, screen can look weird. I started a JTAG version of the Uzebox PCB with a switch to get back to normal when debugging is finished. If there is real interest I can finish and publish it.
Attachments
uzebox_jtag.png
uzebox_jtag.png (52.76 KiB) Viewed 4468 times
User avatar
D3thAdd3r
Posts: 3221
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: AVR GDB (Uzem/cUzebox)

Post by D3thAdd3r »

I think you nailed Jubatian's reasoning on it, it makes sense to me too as I just use hacky debug prints for such purposes, though that's why open source exists if someone wants to add functionality they can extend it to their needs.

@JTAG PCB whoa secret PCB, that is really cool stuff! I could see it as very practical for new hardware development especially.

For collection/historical reasons I'd probably build one if you do end up publishing it. I'd risk an attempt at one of the knockoff JTAGs. I see one claiming JTAG ICE on ebay for $24USD free shipping...I question the authenticity of the Atmel logo though.
CunningFellow
Posts: 1445
Joined: Mon Feb 11, 2013 8:08 am
Location: Brisbane, Australia

Re: AVR GDB (Uzem/cUzebox)

Post by CunningFellow »

Artcfox is a champion at doing GDB things. He keeps trying to teach me but I am not smart enough.

WRT to the hardware - it is a shame that JTAG makes the video output not being to show all the blue or any of the green. Still limited colours is better than nothing.

I'd love to have GDB working in cuzebox as well as a few extra debug features I have thought of.

BTW - My computer has died and I have very limited access at present till I can work something out.
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: AVR GDB (Uzem/cUzebox)

Post by uze6666 »

CunningFellow wrote: Sun Mar 26, 2023 11:00 am WRT to the hardware - it is a shame that JTAG makes the video output not being to show all the blue or any of the green. Still limited colours is better than nothing.
Yeah I know. Back then it wasn't really a choice to choose the video port. Port A, was my first choice since I wanted to keep the JTAG pins free. Alas, I was getting some ghosting on the pins that were not present on other ports. I guess it had to do with the ADC circuitry somehow. Limited color is a tad annoying, but what is gained in debugging power far outweighs that.
User avatar
Artcfox
Posts: 1382
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: AVR GDB (Uzem/cUzebox)

Post by Artcfox »

Yes, it works in uzem. I typically look at this youtube video to refresh my memory on how to use it:

I've only really used it with the command line gdb, but it might work with an IDE, though not every gdb feature is supported, so I guess it would depend on which features the GUI tries to use.

Back in the days before cuzebox, we were trying to get uzem fast enough to run at full speed in the web browser, and it turned out that all of the conditionals in the code for GDB were slowing it way down, so I went through and added #defines so those only got compiled in if you turned GDB support on when you built it. It should be easy to go through the uzem code searching for those #defines to see all of the places where the emulator needs to do something different to support GDB. I've thought about adding it to cuzebox, but it would have to be ported to C, and then changed to match the architecture of cuzebox.
Post Reply