Mail Archives: djgpp/2015/05/24/11:45:43
Am 24.05.2015 14:48, schrieb Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de):
> Am 24.05.2015 11:24, schrieb Eli Zaretskii (eliz AT gnu DOT org):
>>> Date: Sun, 24 May 2015 11:17:27 +0300
>>> From: "Andris Pavenis (andris DOT pavenis AT iki DOT fi)"<djgpp AT delorie DOT com>
>>>
>>>> So what and how goes wrong in the DJGPP build of GDB? Can someone
>>>> with enough free time step through the go32 initialization, and see
>>>> what's wrong there?
>>>
>>> Perhaps at least some hint could give GDB commit which caused that DJGPP port stopped to work (with
>>> symptoms described earlier)
>>>
>>> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=9b409511d07fe375284701af34909fb539029caf
>>
>> Thanks!
>>
>> Actually, it seems bd265cd0bde9e045ab5946532449430b66fe91ad, which is
>> a followup to the one you mentioned, is the bad commit. It seems a
>> simple case of misunderstanding the API conventions of our read_child
>> and write_child.
>>
>> Can you try the patch below? If it fixes the problem, I will push it.
>>
>> diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
>> index f3966cd..852473b 100644
>> --- a/gdb/go32-nat.c
>> +++ b/gdb/go32-nat.c
>> @@ -587,6 +587,13 @@
>> else
>> res = read_child (memaddr, readbuf, len);
>>
>> + /* read_child and write_child return zero on success, non-zero on
>> + failure; adjust the result value to that. */
>> + if (res == 0)
>> + res = len;
>> + else
>> + res = -1;
>> +
>> if (res<= 0)
>> return TARGET_XFER_E_IO;
>>
>
> I have tried the patch with gdb 7.9.1 and djgpp support seems to work again.
> Neitherless sometimes backtrace and finish behave strange. Please give me
> some time more to check. Especially with djgpp 2.05.
>
> Regards,
> Juan M. Guerrero
>
>
OFYI,
I have compiled the repository code from yesterday using GCC 4.9.2 and GNU Binutils 2.24.
I have used -O0 -ggdb flags. This was intentional to be able to step into functions.
The produced library has been installed and used to compile GDB 7.9.1.
The following test program has been compiled using -O0 -ggdb:
------------- program start -------------
#include <stdio.h>
int print(const char *message)
{
int written;
written = printf("%s\n", message);
return written;
}
int main(void)
{
int written = 0;
written = print("qwertz");
return written;
}
------------- program end -------------
Steppinng into the code works well.
If I step into printf() and I issue the bt command I get the following
output:
(gdb) r
Starting program: c:/tmp/5/a.exe
Breakpoint 1, main () at a.c:15
15 int written = 0;
(gdb) s
17 written = print("qwertz");
(gdb)
print (message=0x1f35 <print+33> "qwertz") at a.c:8
8 written = printf("%s\n", message);
(gdb)
printf (fmt=0x1f10 <_crt0_init_mcount+10> "%s\n") at printf.c:10
10 {
(gdb)
printf (fmt=0x1f10 <_crt0_init_mcount+10> "%s\n") at printf.c:14
14 va_start(args, fmt);
(gdb) n
15 len = _doprnt(fmt, args, stdout);
(gdb) bt
#0 printf (fmt=0x1f10 <_crt0_init_mcount+10> "%s\n") at printf.c:15
#1 0x00003316 in nofpsig () at npxsetup.c:51
#2 0x00000006 in ?? ()
#3 0x00001f2a in print (message=0x1f35 <print+33> "qwertz") at a.c:8
#4 0x00001f61 in main () at a.c:17
(gdb)
The remarkable issue is that although I used the n command to avoid stepping
into _doprnt() gdb behaves as if the s command had been used. After having
stepped into _doprnt() I get the following output for the bt command:
10 {
(gdb)
printf (fmt=0x1f10 <_crt0_init_mcount+10> "%s\n") at printf.c:14
14 va_start(args, fmt);
(gdb) n
15 len = _doprnt(fmt, args, stdout);
(gdb) bt
#0 printf (fmt=0x1f10 <_crt0_init_mcount+10> "%s\n") at printf.c:15
#1 0x00003316 in nofpsig () at npxsetup.c:51
#2 0x00000006 in ?? ()
#3 0x00001f2a in print (message=0x1f35 <print+33> "qwertz") at a.c:8
#4 0x00001f61 in main () at a.c:17
(gdb) n
_doprnt (fmt0=0x1f10 <_crt0_init_mcount+10> "%s\n", argp=0x99b24 "5\037",
fp=0x11db0 <__dj_stdout>) at doprnt.c:119
119 {
(gdb)
148 locale_info = localeconv();
(gdb)
149 decimal_point = locale_info->decimal_point[0];
(gdb) bt
#0 _doprnt (fmt0=0x1f10 <_crt0_init_mcount+10> "%s\n", argp=0x99b24 "5\037",
fp=0x11db0 <__dj_stdout>) at doprnt.c:149
#1 0x00000000 in ?? ()
(gdb)
If I issue the finish command to run until the end of the function
I get the following output:
#0 printf (fmt=0x1f10 <_crt0_init_mcount+10> "%s\n") at printf.c:15
#1 0x00003316 in nofpsig () at npxsetup.c:51
#2 0x00000006 in ?? ()
#3 0x00001f2a in print (message=0x1f35 <print+33> "qwertz") at a.c:8
#4 0x00001f61 in main () at a.c:17
(gdb) n
_doprnt (fmt0=0x1f10 <_crt0_init_mcount+10> "%s\n", argp=0x99b24 "5\037",
fp=0x11db0 <__dj_stdout>) at doprnt.c:119
119 {
(gdb)
148 locale_info = localeconv();
(gdb)
149 decimal_point = locale_info->decimal_point[0];
(gdb) bt
#0 _doprnt (fmt0=0x1f10 <_crt0_init_mcount+10> "%s\n", argp=0x99b24 "5\037",
fp=0x11db0 <__dj_stdout>) at doprnt.c:149
#1 0x00000000 in ?? ()
(gdb) finish
Run till exit from #0 _doprnt (fmt0=0x1f10 <_crt0_init_mcount+10> "%s\n",
argp=0x99b24 "5\037", fp=0x11db0 <__dj_stdout>) at doprnt.c:149
Warning:
Cannot insert breakpoint 0.
Cannot access memory at address 0x0
(gdb)
If more information is required please let me know.
Regards,
Juan M. Guerrero
- Raw text -