From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9951 invoked by alias); 11 May 2005 14:01:39 -0000 Mailing-List: contact insight-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: insight-owner@sources.redhat.com Received: (qmail 9534 invoked from network); 11 May 2005 14:01:29 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 11 May 2005 14:01:29 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j4BE1TUg013640; Wed, 11 May 2005 10:01:29 -0400 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j4BE1SO29663; Wed, 11 May 2005 10:01:28 -0400 Received: from redhat.com (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.toronto.redhat.com (8.12.8/8.12.8) with ESMTP id j4BE1Nk0028418; Wed, 11 May 2005 10:01:25 -0400 Message-ID: <42820FE7.8020702@redhat.com> Date: Wed, 11 May 2005 14:01:00 -0000 From: Fernando Nasser User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 MIME-Version: 1.0 To: James Lemke CC: insight@sourceware.org Subject: Re: RFC: patch for insight & target stdin References: <1115757946.24600.25.camel@keel.thelemkes.ca> In-Reply-To: <1115757946.24600.25.camel@keel.thelemkes.ca> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2005-q2/txt/msg00021.txt.bz2 Hi Jim, The reason I left this out was because it breaks on Windows (Cygwin), at least the code I had at the time broke with the Cygwin of that time... We need someone to test this on a Windows machine and see what happens. Cheers, Fernando James Lemke wrote: > I had a customer complaint about insight, that target programs could > write to stdout but not read from stdin. On Linux, stdout went to the > console window and stdin came from the launch shell. On Windows stdout > went to the console window and stdin just failed with EBADF. > > Apparently this was never implemented, so I made an attempt. Reads from > stdin now come from the console window. This has been tested with > x86-linux x xscale-elf and cygwin x xscale-elf. > > I don't know gdb / gdbtk implementation well, so I'm open to comments. > > Jim. > > > > ------------------------------------------------------------------------ > > Index: ChangeLog > =================================================================== > RCS file: /cvs/src/src/gdb/gdbtk/ChangeLog,v > retrieving revision 1.362 > diff -u -p -r1.362 ChangeLog > --- ChangeLog 28 Apr 2005 23:45:06 -0000 1.362 > +++ ChangeLog 10 May 2005 20:13:42 -0000 > @@ -1,3 +1,10 @@ > +2005-05-10 James Lemke > + > + * generic/gdbtk-hooks.c (gdbtk_fileopenin, gdbtk_read): New functions > + for target to read stdin from console window. > + * generic/gdbtk-interp.c (_stdtargin): Added. > + * generic/gdbtk.h (gdbtk_fileopenin): Add declaration. > + > 2005-04-28 Ben Elliston > > * generic/gdbtk-interp.c (gdbtk_interpreter_exec): Return struct > Index: generic/gdbtk-hooks.c > =================================================================== > RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-hooks.c,v > retrieving revision 1.39 > diff -u -p -r1.39 gdbtk-hooks.c > --- generic/gdbtk-hooks.c 13 Dec 2004 20:42:20 -0000 1.39 > +++ generic/gdbtk-hooks.c 10 May 2005 20:13:42 -0000 > @@ -105,6 +105,7 @@ static void gdbtk_set_hook (struct cmd_l > * See note there for details. > */ > > +long gdbtk_read (struct ui_file *, char *, long); > void gdbtk_fputs (const char *, struct ui_file *); > static int gdbtk_load_hash (const char *, unsigned long); > > @@ -220,6 +221,14 @@ gdbtk_two_elem_cmd (cmd_name, argv1) > } > > struct ui_file * > +gdbtk_fileopenin (void) > +{ > + struct ui_file *file = ui_file_new (); > + set_ui_file_read (file, gdbtk_read); > + return file; > +} > + > +struct ui_file * > gdbtk_fileopen (void) > { > struct ui_file *file = ui_file_new (); > @@ -227,6 +236,42 @@ gdbtk_fileopen (void) > return file; > } > > +/* This handles input from the gdb console. > + */ > + > +long > +gdbtk_read (struct ui_file *stream, char *buf, long sizeof_buf) > +{ > + int result; > + size_t actual_len; > + > + if (stream == gdb_stdtargin) > + { > + result = Tcl_Eval (gdbtk_interp, "gdbtk_console_read"); > + if (result != TCL_OK) > + { > + report_error (); > + actual_len = 0; > + } > + else > + actual_len = strlen (gdbtk_interp->result); > + > + /* Truncate the string if it is too big for the caller's buffer. */ > + if (actual_len >= sizeof_buf) > + actual_len = sizeof_buf - 1; > + > + memcpy (buf, gdbtk_interp->result, actual_len); > + buf[actual_len] = '\0'; > + return actual_len; > + } > + else > + { > + errno = EBADF; > + return 0; > + } > +} > + > + > /* This handles all the output from gdb. All the gdb printf_xxx functions > * eventually end up here. The output is either passed to the result_ptr > * where it will go to the result of some gdbtk command, or passed to the > Index: generic/gdbtk-interp.c > =================================================================== > RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-interp.c,v > retrieving revision 1.6 > diff -u -p -r1.6 gdbtk-interp.c > --- generic/gdbtk-interp.c 28 Apr 2005 23:45:07 -0000 1.6 > +++ generic/gdbtk-interp.c 10 May 2005 20:13:42 -0000 > @@ -43,6 +43,7 @@ struct gdbtk_interp_data > struct ui_file *_stderr; > struct ui_file *_stdlog; > struct ui_file *_stdtarg; > + struct ui_file *_stdtargin; > }; > > static struct gdbtk_interp_data *gdbtk_data; > @@ -83,6 +84,7 @@ gdbtk_interpreter_resume (void *data) > gdb_stderr = d->_stderr; > gdb_stdlog = d->_stdlog; > gdb_stdtarg = d->_stdtarg; > + gdb_stdtargin = d->_stdtargin; > > deprecated_command_loop_hook = gdbtk_command_loop; > > @@ -172,6 +174,7 @@ _initialize_gdbtk_interp (void) > gdbtk_data->_stderr = gdbtk_fileopen (); > gdbtk_data->_stdlog = gdbtk_fileopen (); > gdbtk_data->_stdtarg = gdbtk_fileopen (); > + gdbtk_data->_stdtargin = gdbtk_fileopenin (); > gdbtk_interp = interp_new ("insight", gdbtk_data, cli_out_new (gdbtk_data->_stdout), > &procs); > interp_add (gdbtk_interp); > Index: generic/gdbtk.h > =================================================================== > RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk.h,v > retrieving revision 1.9 > diff -u -p -r1.9 gdbtk.h > --- generic/gdbtk.h 25 Jun 2004 19:44:22 -0000 1.9 > +++ generic/gdbtk.h 10 May 2005 20:13:42 -0000 > @@ -159,6 +159,7 @@ extern int gdbtk_two_elem_cmd (char *, c > extern int target_is_native (struct target_ops *t); > extern void gdbtk_fputs (const char *, struct ui_file *); > extern struct ui_file *gdbtk_fileopen (void); > +extern struct ui_file *gdbtk_fileopenin (void); > extern int gdbtk_disable_fputs; > > #ifdef _WIN32