[GDB] Connecting Insight makes the program crashes

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
shazz
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 25
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sun Mar 07, 2010 12:46 pm
Has thanked: 0
Been thanked: 0

[GDB] Connecting Insight makes the program crashes

Post by shazz »

Hello,

I tried to debug a very simple program using :
- latest svn KOS
- dcload serial 1.0.4
- sh-elf-gdb 6.8
- sh-elf_insight (compiled for sh-elf) 6.8.1

when I tried insight connects to the loaded application, it crashes everytime :

Code: Select all

opt/toolchains/dc/sh-elf/bin/sh-elf-gcc -O2 -fomit-frame-pointer -ml -m4-single-only -fno-crossjumping -I/opt/toolchains/dc/kos/../kos-ports/include -I/opt/toolchains/dc/kos/include -I/opt/toolchains/dc/kos/kernel/arch/dreamcast/include -I/opt/toolchains/dc/kos/addons/include -D_arch_dreamcast -D_arch_sub_pristine -Wall -g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only -Wl,-Ttext=0x8c010000 -nostartfiles -nostdlib -L/opt/toolchains/dc/kos/lib/dreamcast -L/opt/toolchains/dc/kos/addons/lib/dreamcast -o gdbtest.elf /opt/toolchains/dc/kos/kernel/arch/dreamcast/kernel/startup.o \
		gdbtest.o  -Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group

dc-tool -g -x gdbtest.elf

Starting a GDB server on port 2159
Console enabled
Upload <gdbtest.elf>
[...]
KallistiOS ##version##: Fri Feb 19 16:38:13 CET 2010
[...]
thd: pre-emption enabled, HZ=100
[...]
dc-load console support enabled
[...]
waiting for gdb client connection...
I run insight, connect to GDBserver/Serial / Baud Rate: same baudrate used for dc-tool / remote target: 2159
it tries to connect, says successful then... crash

Code: Select all

Unimplemented command (110) 
Assuming program has exited, or something...

Any idea ?

the code :

Code: Select all

#include <kos.h>
#include <arch/gdb.h>

int main(int argc, char **argv)
{
   gdb_init();
   
   int val = 12;
   printf("\nHello world from gdb ! %d\n\n", val);
   return 0;
} 
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7497
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: [GDB] Connecting Insight makes the program crashes

Post by Quzar »

I'll look into it more later if nobody else has given you a better answer, but I *think* you also have to recompile your libs (kos) as '-g' in order for it to work right... I might be way off base though
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: [GDB] Connecting Insight makes the program crashes

Post by emptythought »

Try KOS' debug "logging" method.

Add this to your includes:

Code: Select all

#include "kos/dbglog.h"
Use this instead of printf:

Code: Select all

dbglog(DBG_DEBUG, "");
So try running this in GDB\Insight:

Code: Select all

/* #include <string.h> */

#include "arch/gdb.h"
#include "kos/dbglog.h"

int main(int argc, char **argv)
{
   gdb_init();
   
   printf("Hello world from gdb!\n");
   return 0;
}
shazz
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 25
Joined: Sun Mar 07, 2010 12:46 pm
Has thanked: 0
Been thanked: 0

Re: [GDB] Connecting Insight makes the program crashes

Post by shazz »

emptythought, I tried.. not really better. (or a little, dc-tool still exits but without the 'Unimplemented command (110)
Assuming program has exited, or something..." message)

insight says "successfully connected", the dc-tool shell exit, but when I click on the Run button, nothing happens and if I open the gdb shell I can see :

Code: Select all

0x8c0120c4 in gdb_init () at gdb_stub.c:988
Remote communication error: Connection reset by peer.

(gdb) 
Error: putpkt: write failed: Broken pipe.
gdb_stub.c:988 :

Code: Select all

#define BREAKPOINT()   asm("trapa	#0xff"::);
BREAKPOINT()
Which version of gdb+insight are you using ? as all versions prior to 6.8 are broken due to a tcl/tk bug with ubuntu (or any debian distrib it seems) I cannot try another one...
shazz
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 25
Joined: Sun Mar 07, 2010 12:46 pm
Has thanked: 0
Been thanked: 0

Re: [GDB] Connecting Insight makes the program crashes

Post by shazz »

I tried a second time with my new 4.4.0 gcc toolchain.... exactly the same behavior.
So or the feature is broken, or there is a dedicated gdb version to use... or I'm not lucky !
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7497
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: [GDB] Connecting Insight makes the program crashes

Post by Quzar »

Have you checked that you have the newest version of dcload/tool? Support for gdb was only (relatively) recently made stable.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
shazz
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 25
Joined: Sun Mar 07, 2010 12:46 pm
Has thanked: 0
Been thanked: 0

Re: [GDB] Connecting Insight makes the program crashes

Post by shazz »

Unless the "latest" dcload version is not in the svn... yes I have checked. To be sure I have burnt a new CD.... same result.
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7497
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: [GDB] Connecting Insight makes the program crashes

Post by Quzar »

Hrm. Have you tried connecting without insight? Using plain cli gdb? That would at least eliminate one component.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
shazz
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 25
Joined: Sun Mar 07, 2010 12:46 pm
Has thanked: 0
Been thanked: 0

Re: [GDB] Connecting Insight makes the program crashes

Post by shazz »

I'll try (I tried thru the insight gdb shell but not directly)
Do you know the exact commands to pass ? (for serial /dev/ttyS0, 115200 bps)
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: [GDB] Connecting Insight makes the program crashes

Post by emptythought »

Do you have Newlib 1.15? If you do try Newlib 1.12, 1.15 has some issues with printf that need to be fixed.
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: [GDB] Connecting Insight makes the program crashes

Post by BlueCrab »

emptythought wrote:Do you have Newlib 1.15? If you do try Newlib 1.12, 1.15 has some issues with printf that need to be fixed.
I've never had a single issue with Newlib 1.15.0 myself. Also, as of r657 of KOS in the Subversion, Newlib 1.15.0 is required.
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Has thanked: 0
Been thanked: 0
Contact:

Re: [GDB] Connecting Insight makes the program crashes

Post by emptythought »

There's an old post on the mailing list about it, it basically says that Newlib 1.15 and printf on DC does not work. That's why I suggested the debugger log.
shazz
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 25
Joined: Sun Mar 07, 2010 12:46 pm
Has thanked: 0
Been thanked: 0

Re: [GDB] Connecting Insight makes the program crashes

Post by shazz »

Yes I'm using Newlib 1.15.. I'll try 1.12 in case of.

Nevertheless, as I've got a BBA now, I tried the ip version... even worse ! Using the same test application (see code above), dc-tool 1.0.4 doesn't display anymore the "waiting for gdb client connection", it starts to execute the code as without the -g arg then freezes...

damn... is there anybody here who really uses gdb/insight ????
Post Reply