programs hang on gdb_init()

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
User avatar
ThePerfectK
Insane DCEmu
Insane DCEmu
Posts: 147
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Thu Apr 27, 2006 10:15 am
Has thanked: 27 times
Been thanked: 35 times

programs hang on gdb_init()

Post by ThePerfectK »

couple of questions:

firstly -- I notice the gdb examples have been removed from KOS, when did this happen? IIRC there used to be a gdb_sample.c example in the examples folder? Is gdb support for KOS deprecated?

beyond that, I'm trying to get gdb working on a small program. I've built dc-tool-ip v 1.05 and can connect correctly with the BBA. I'm sending and executing my programs correctly. If I pass the -g flag to enable gdb debugging, I notice that dc-tool-ip sets up a gdb server, and I can connect to it using a version of sh-elf-gdb I found online (couldn't find a place to build it myself).

Everything seems to be going fine, but when my program comes to the gdb_init() command, it halts and stops running. I get no error messages, rather the output to my screen from my dreamcast freezes and my command line window on my PC stops updating. I never get a "waiting for gdb client connection..." on my console, regardless of whether or not I start and connect with sh-elf-gdb.

By moving gdb_init() around in my source code and using printf statements to measure output on my console, I've realized that the command itself is what is causing the program to halt. I'm including <arch/gdb.h> and <kosdbg.h> in my source, and even if gdb_init() is the very first thing called, my program halts.

Any ideas?
Still Thinking!~~
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5658
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: programs hang on gdb_init()

Post by BlueCrab »

I can't really help with the freezing issue, but I don't ever recall there being a GDB example in the mainline KOS repository at all. I know that I certainly haven't removed anything like that (or even touched the GDB support) during the whole time where I've been the one directing the project.

Honestly, in all the time I've done Dreamcast stuff, I've never even attempted to use GDB with it even once...
User avatar
ThePerfectK
Insane DCEmu
Insane DCEmu
Posts: 147
Joined: Thu Apr 27, 2006 10:15 am
Has thanked: 27 times
Been thanked: 35 times

Re: programs hang on gdb_init()

Post by ThePerfectK »

I'll be the first to admit my memory isn't too great, so perhaps I'm misremembering, but I can find old posts from others mentioning gdb sample files. Perhaps they didn't originate from KOS, I guess.

What I do remember, however, is speaking to you about a year and a half to maybe 2 years ago about gdb and you mentioning you never had a need for it back then as well, haha. So at least you're consistent, lol.

Anybody else have an idea as to why the hang up at gdb_init()?
Still Thinking!~~
User avatar
SiZiOUS
DC Developer
DC Developer
Posts: 404
Joined: Fri Mar 05, 2004 2:22 pm
Location: France
Has thanked: 27 times
Been thanked: 19 times
Contact:

Re: programs hang on gdb_init()

Post by SiZiOUS »

I'm using gdb_init() and everything works fine on my side.
Do you have passed the -g option to gcc when building your program?
What version of sh-elfg-gdb are you using?

I may suggest you the following:
  • If you are using Windows, check DreamSDK as everything is setup in that environment to use KOS, even debugging programs.
  • If you are not using Windows, check the documentation I've written to build a toolchain properly, including making GDB.
Here a screenshot of a debug session I made some month ago.
User avatar
ThePerfectK
Insane DCEmu
Insane DCEmu
Posts: 147
Joined: Thu Apr 27, 2006 10:15 am
Has thanked: 27 times
Been thanked: 35 times

Re: programs hang on gdb_init()

Post by ThePerfectK »

Hey Siz, friended you and sent you a PM on twitter, but in case you didn't see it, I followed your guide and still am having GDB hang on gdb_init(). I'm wondering now if I'm perhaps passing the -g flag to gcc incorrectly. I use environ.sh to add the g flag to the gcc compiler and compile using a makefile. I know when you use dc-load-ip you need to have the -g flag at the beginning of the argument list for it to work, so my assumption right now is that building my source with the -g flag is in the wrong spot or something.

Would you be willing to share your compile command, so I can see how you are sending the -g flag to gcc? Also, do you think you could post the source to the example you showed off on twitter so I could try compiling it as well?

side note: since last posting in this topic, I'd actually gone on and built my own preprocessor macro-driven debugger that spits out a lot of useful info without much mangling of an existing source code, mainly stuff like changing declarations for a variable from, say, "int foo" to "dbg_int foo." I'd still like to get GDB working, but if anyone is interested I could post my macros which I keep defined in a header file for easy distribution. Thanks to a very old post from BlueCrab which tipped me off to needing to rebuild KOS and KOS' utilities after making some changes needed for my macro to get KOS to spit out the info I was needing.
Still Thinking!~~
Post Reply