public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] gdb 'next' problem with i386 HAL
@ 2001-08-15 15:08 John Gumb
  2001-08-16  6:44 ` Jonathan Larmour
  0 siblings, 1 reply; 16+ messages in thread
From: John Gumb @ 2001-08-15 15:08 UTC (permalink / raw)
  To: 'ecos-discuss@sources.redhat.com'

Hi,

I've managed to get the i386 HAL up and running without too much bother - the only oddity I have is with GDB. The 'step' command works fine but the 'next' command simply results in the program continuing without breaking at the next line.

I have seen some posts related to this in that the gdb front end translates 'next' into a setting of a temporary breakpoint and then issuing a 'continue' so I could imagine I might see this sort of behaviour.

After poking around a bit, I can't see anything obvious.

Any suggestions as to what's up would be appreciated.

Cheers,

John

^ permalink raw reply	[flat|nested] 16+ messages in thread
* RE: [ECOS] gdb 'next' problem with i386 HAL
@ 2001-08-22 12:20 Allan Young
  0 siblings, 0 replies; 16+ messages in thread
From: Allan Young @ 2001-08-22 12:20 UTC (permalink / raw)
  To: ecos-discuss

I've been playing around with a recent (via anonymous cvs, grabbed around
August 10th) version of eCos and I've also observed the i386 gdb "next that
continues" problem too.  This is repeatable with the redboot floppy I've
built from sources as well as one created with the pre-built redboot binary
available at the redhat/ecos site.

Like Boris I'm also using gdb version 5.0 but I'm running on RedHat 7.1.
Also, the problem is repeatable when gdb is connected by serial port or
ethernet.

For what it's worth I get proper 'gdb next' behavior with the same
gcc/gdb/binutil tool chain with an ancient, pre-redboot, 1.3.1 version of
eCos.

> Perhaps it might behave better if the debugged app was built with no
> optimization. Other than that, you'll need to investigate further
> (e.g. by using "set debug remote 1" and seeing where GDB sets its 
> "next" breakpoint and see if that's valid).

It will take me a while to decode the gdb packet information from my 'gdb
next' test with debug remote set to 1.  Unfortunately, I won't have time to
look at this for at least a few days...

^ permalink raw reply	[flat|nested] 16+ messages in thread
* RE: [ECOS] gdb 'next' problem with i386 HAL
@ 2001-08-23  2:54 John Gumb
  0 siblings, 0 replies; 16+ messages in thread
From: John Gumb @ 2001-08-23  2:54 UTC (permalink / raw)
  To: 'ecos-discuss@sourceware.cygnus.com'

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 6275 bytes --]

Folks,

>For what it's worth I get proper 'gdb next' behavior with the same
>gcc/gdb/binutil tool chain with an ancient, pre-redboot, 1.3.1 version of
>eCos.
many thanks - this is useful.

I originally saw this under RedHat 7.1 and a recent (around 10 Aug) cvs
tree.

To rule out Linux (and get a feel for how well the tools run under
NT/cygwin), 
I've managed to build the example images under NT using this morning's
ecos-latest.tar.gz snapshot from ftp://ftp.skynet.ie/cvs/ and I see exactly 
the same behaviour.

I built the i386-elf-xxx tools from source under NT successfully
(gcc-2.95.2, insight-5.0, binutils-2.10.1).

To see if I stuffed up building redboot, I've just downloaded the pre-built
redboot binary and I see exactly the same behaviour using that.

> Perhaps it might behave better if the debugged app was built with no
> optimization. Other than that, you'll need to investigate further
> (e.g. by using "set debug remote 1" and seeing where GDB sets its 
> "next" breakpoint and see if that's valid).

I tried 'set debug remote 1' but not being intimately familiar with the
innards of 
remote gdb the output didn't mean a lot. Here's a log of what I see when
'nexting'
at the initial printf in 'twothreads'. You can see I get bored and hit
CTRL-C and
we drop nicely back into gdb.

bash-2.05$ i386-elf-gdb -nw --command=~/.gdbinit
GNU gdb 5.0
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-cygwin --target=i386-elf".
0x97ac in ?? ()
(gdb) load twothreads.exe
Loading section .text, size 0xc1df lma 0x108000
Loading section .rodata, size 0x2ed lma 0x1141e0
Loading section .data, size 0x230 lma 0x1144d0
Start address 0x108000 , load size 50940
Transfer rate: 67920 bits/sec, 74 bytes/write.
(gdb) symbol twothreads.exe
Reading symbols from twothreads.exe...done.
(gdb) b cyg_user_start
Breakpoint 1 at 0x10860a: file twothreads.c, line 25.
(gdb) cont
Continuing.
[New thread 1]
[Switching to thread 1]

Breakpoint 1, cyg_user_start () at twothreads.c:25
25        printf("Entering twothreads' cyg_user_start() function\n");
Current language:  auto; currently c
(gdb) info registers
eax            0x118320 1147680
ecx            0x4      4
edx            0x1182e0 1147616
ebx            0x4      4
esp            0x115770 0x115770
ebp            0x115788 0x115788
esi            0x17f20  98080
edi            0x11aa6c 1157740
eip            0x10860a 0x10860a
eflags         0x2      2
cs             0x8      8
ss             0x0      0
ds             0x0      0
es             0x0      0
fs             0x0      0
gs             0x0      0
(gdb) set debug remote 1
(gdb) next
Sending packet: $s#73...Ack
Packet received: T05thread:00000001;08:0d861000;04:64571100;
Sending packet: $m10860a,1#2a...Ack
Packet received: 83
Sending packet: $X10860a,1:Ì#1b...Ack
Packet received: OK
Sending packet: $s#73...Ack
Packet received: T05thread:00000001;08:12861000;04:60571100;
Sending packet: $s#73...Ack
Packet received: T05thread:00000001;08:a4dd1000;04:5c571100;
Sending packet: $m11575c,4#33...Ack
Packet received: 01000000
Sending packet: $g#67...Ack
Packet received:
2083110004000000e0821100040000005c57110088571100207f01006caa110
0a4dd100007000000080000000000000000000000
Sending packet: $m1,1#fb...Ack
Packet received: e7
Sending packet: $X1,1:Ì#ec...Ack
Packet received: OK
Sending packet: $c#63...Ack
Packet received:
O456E746572696E672074776F7468726561647327206379675F757365725F73
7461727428292066756E6374696F6E0A
Entering twothreads' cyg_user_start() function
Packet received:
O426567696E6E696E6720657865637574696F6E3B2074687265616420646174
6120697320300A
Beginning execution; thread data is 0
Packet received:
O426567696E6E696E6720657865637574696F6E3B2074687265616420646174
6120697320310A
Beginning execution; thread data is 1
Packet received:
O54687265616420303A20616E64206E6F7720612064656C6179206F66203233
3920636C6F636B207469636B730A
Thread 0: and now a delay of 239 clock ticks
Packet received:
O54687265616420313A20616E64206E6F7720612064656C6179206F66203233
3020636C6F636B207469636B730A
Thread 1: and now a delay of 230 clock ticks
remote_interrupt called
remote_stop called
Packet received: T02thread:00000001;08:15821000;04:d05e1100;

Program received signal SIGINT, Interrupt.
Sending packet: $X1,1:ç#07...Ack
Packet received: OK
Sending packet: $g#67...Ack
Packet received:
96010000000000006058110014b91000d05e1100fc5e1100000011110000111
11582100007020000080000000000000000000000
Sending packet: $X10860a,1:\203#d2...Ack
Packet received: OK
0x108215 in hal_idle_thread_action ()
    at
/d/home/jag/ecos/packages/language/c/libc/startup/current/src/atexit.cxx:
123
123     } // atexit()
Current language:  auto; currently c++
(gdb)

-----Original Message-----
From: Allan Young [ mailto:AYoung@YottaYotta.com ]
Sent: 22 August 2001 20:20
To: ecos-discuss@sourceware.cygnus.com
Subject: RE: [ECOS] gdb 'next' problem with i386 HAL


I've been playing around with a recent (via anonymous cvs, grabbed around
August 10th) version of eCos and I've also observed the i386 gdb "next that
continues" problem too.  This is repeatable with the redboot floppy I've
built from sources as well as one created with the pre-built redboot binary
available at the redhat/ecos site.

Like Boris I'm also using gdb version 5.0 but I'm running on RedHat 7.1.
Also, the problem is repeatable when gdb is connected by serial port or
ethernet.

For what it's worth I get proper 'gdb next' behavior with the same
gcc/gdb/binutil tool chain with an ancient, pre-redboot, 1.3.1 version of
eCos.

> Perhaps it might behave better if the debugged app was built with no
> optimization. Other than that, you'll need to investigate further
> (e.g. by using "set debug remote 1" and seeing where GDB sets its 
> "next" breakpoint and see if that's valid).

It will take me a while to decode the gdb packet information from my 'gdb
next' test with debug remote set to 1.  Unfortunately, I won't have time to
look at this for at least a few days...

^ permalink raw reply	[flat|nested] 16+ messages in thread
* RE: [ECOS] gdb 'next' problem with i386 HAL
@ 2001-08-24  7:19 Patrick O'Grady
  0 siblings, 0 replies; 16+ messages in thread
From: Patrick O'Grady @ 2001-08-24  7:19 UTC (permalink / raw)
  To: ecos-discuss

I may have some clues about gdb's next problem--as I recall, GDB does a
'next' by 1) poking a breakpoint instruction after the current statement,
and 2) sending a continue instruction to the stub.  I would guess that step
(1) isn't supported in the current i386 stub: it's likely that the earlier
GDB computed the length of the current instruction, and used a memory write
command to put the breakpoint in there, and that the current version asks
the target to do that work.  HTH...

-patrick


^ permalink raw reply	[flat|nested] 16+ messages in thread
* [ECOS] gdb 'next' problem with i386 HAL
@ 2001-08-29  6:42 John Gumb
  2001-08-29  6:47 ` Mark Salter
  0 siblings, 1 reply; 16+ messages in thread
From: John Gumb @ 2001-08-29  6:42 UTC (permalink / raw)
  To: 'ecos-discuss@sourceware.cygnus.com'

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1894 bytes --]

Hi,

I seem to have tracked down the cause of the problem and have a (nasty) workaround but I'm not sure why this is happening in the first place.

The problem only occurs when 'nexting' over a function call. Immediately on entry to the called function, gdb attempts to work out the return PC address. It does this using the SAVED_PC_AFTER_CALL macro in /src/gdb/insight-5.0/gdb/config/i386/tm-i386.h invoked from step_over_function in /src/gdb/insight-5.0/gdb/infrun.c  What this does is to look on stack for the return address in order that it can set a breakpoint there. SAVED_PC_AFTER_CALL expands to

read_memory_integer ( read_register (SP_REGNUM), 4) )

The trouble is, the return address isn't there. I had a poke around and it actually is 16 bytes further down the stack. So I modified the above code to

read_memory_integer ( read_register (SP_REGNUM)+0x10, 4) )

and I appear to have correct 'next' behaviour. I'd need to do a *lot* more testing to be sure this is working properly though.

I'd be most grateful if anyone could shed light on what's actually going on. I'm guessing that another stack frame has been pushed on somehow.

FYI we can actually see this going wrong in the trace I posted:

Sending packet: $m11575c,4#33...Ack
Packet received: 01000000
Sending packet: $g#67...Ack
Packet received:
2083110004000000e0821100040000005c57110088571100207f01006caa110
0a4dd100007000000080000000000000000000000
Sending packet: $m1,1#fb...Ack
Packet received: e7
Sending packet: $X1,1:Ì#ec...Ack

The $m11575c,4 is attempting to get the return PC. The target responds with 0x00000001. After getting the registers GDB then attempts to set a break at address1 (Sending packet: $X1,1:Ì#ec...Ack). This will not be of much use.

You can imagine it was a blast debugging this :-)

Cheers,

John Gumb
Ridgeway Systems and Software
john@gumb.org (home)
jgumb@ridgeway-sys.com (work)

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2001-09-05 15:17 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-15 15:08 [ECOS] gdb 'next' problem with i386 HAL John Gumb
2001-08-16  6:44 ` Jonathan Larmour
2001-08-17  0:31   ` Boris V. Guzhov
2001-08-17  6:17     ` Jonathan Larmour
2001-08-22 12:20 Allan Young
2001-08-23  2:54 John Gumb
2001-08-24  7:19 Patrick O'Grady
2001-08-29  6:42 John Gumb
2001-08-29  6:47 ` Mark Salter
2001-09-05  8:32   ` Jonathan Larmour
2001-09-05  8:44     ` Mark Salter
2001-09-05  8:55       ` Jonathan Larmour
2001-09-05  9:33         ` Mark Salter
2001-09-05 14:16           ` Jonathan Larmour
2001-09-05 14:59             ` Mark Salter
2001-09-05 15:17               ` Jonathan Larmour

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).