This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
Re: Output of printf command
- From: Kai Ruottu <kai dot ruottu at luukku dot com>
- Cc: Insight Maling List <insight at sources dot redhat dot com>
- Date: Wed, 13 Feb 2002 13:57:15 +0200
- Subject: Re: Output of printf command
- Organization: MTV3i Internet, Finland
- References: <Pine.GSO.4.33.0202122034460.18500-100000@makita.cygnus.com>
- Reply-to: karuottu at mbnet dot fi
Keith Seitz wrote:
>
> On Thu, 7 Feb 2002, Keith Seitz wrote:
>
> > On Thu, 7 Feb 2002, David Mc Kenna wrote:
> >
> > > This GDB was configured as "--host=i686-pc-cygwin --target=arm-elf".
> >
> > Ok, that's starting to make some sense. Cygwin hosts obviously don't have
> > xterms (even those with XFree86, as far as Insight is concerned).
> >
> > I will check into this and get back to you.
>
> Ok, I've checked into this, and it is a simulator problem. The ARM
> simulator (sim/arm) doesn't use the gdb/sim callback interface for os-like
> functions. It just does printf/fprintf and ignores that there might be a
> ui on the other side.
>
> I've modified src/sim/arm/armos.c to use the callback interface, and it
> works for me for my simple testcase.
>
> I've contacted some sim folks, and I'll send a note when/if this is fixed.
> I don't know how this has gone unnoticed for so long.
All the other sims could also be checked, the japanese targets used to output
to the GDB-console ("Console Window") as default, while some like the PowerPC
'psim' use 'write(1,...)' directly, this forces the output to the 'system console',
to the xterm or to the Win32-console. This has been compatible with the native
Insights (this far). Outputting to the GDB-console has been seen uncompatible
by me, but it has been the only possibility on systems without a 'system console'
like Win32s. Here is a clip taken from my 'sim/ppc/emul-unix.c':
----------------------- clip ----------------------
static void
do_unix_write(os_emul_data *emul,
unsigned call,
const int arg0,
cpu *processor,
unsigned_word cia)
{
void *scratch_buffer = NULL;
int d = (int)cpu_registers(processor)->gpr[arg0];
unsigned_word buf = cpu_registers(processor)->gpr[arg0+1];
int nbytes = cpu_registers(processor)->gpr[arg0+2];
int status;
if (WITH_TRACE && ppc_trace[trace_os_emul])
printf_filtered ("%d, 0x%lx, %d", d, (long)buf, nbytes);
/* get a tempoary bufer */
scratch_buffer = zalloc(nbytes); /* FIXME - nbytes == 0 */
/* copy in */
emul_read_buffer(scratch_buffer, buf, nbytes,
processor, cia);
/* write */
#ifdef __WIN32S__
status = ppc_callback->write(ppc_callback, d, scratch_buffer, nbytes);
#else
status = write(d, scratch_buffer, nbytes);
#endif
emul_write_status(processor, status, errno);
zfree(scratch_buffer);
flush_stdoutput();
}
----------------------- clip ----------------------
The GDB-console has been the only available place for the 'callback-writes'
AFAIK... Is there something else available now?
This far ('...5.0') the direct 'write()'s have however worked on Unix and
Win32, but is there now some change in '5.1.x' ? The last sources I have
tried are from the sad day '20010911' and a little later and then the output
to the system console still worked... But I may have some local patches added,
to continue to use the 'system console' just as earlier, which I have now
forgotten. Anyway with the Autumn-2001 snapshots the following happens on
Win32 when I click a '<prefix>-gdb' icon:
1. The black Win32 console, the 'system console' for the 'stdout' from the
debugged program opens
2. After a while the empty Source Window, ie. the Insight-GUI opens
If the 1. doesn't happen, there is some essential difference between my
(patched) and the plain vanilla Insight sources... Or the user is still
using Win3.1x/Win32s ;-)
I use Mingw as the Win32-host, not Cygwin... Neither I build the Win32-
binaries under Windoze, but under Linux (using Linux-x-Mingw tools), but
this should make any difference (than making the builds much easier and
quicker...)
Cheers, Kai