From: kseitz Date: Wed, 1 Jun 2005 15:23:15 +0000 (+0000) Subject: From James Lemke : X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=37df3a86fc26d42365f891bfd60b73fa18703355;p=pf3gnuchains%2Fpf3gnuchains3x.git From 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. --- diff --git a/gdb/gdbtk/ChangeLog b/gdb/gdbtk/ChangeLog index f2a1569f6f..ed18e63027 100644 --- a/gdb/gdbtk/ChangeLog +++ b/gdb/gdbtk/ChangeLog @@ -1,3 +1,11 @@ +2005-06-01 Keith Seitz + + From 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-05-26 Keith Seitz * generic/gdbtk-cmds.c (gdb_set_mem): target_write_memory now takes diff --git a/gdb/gdbtk/generic/gdbtk-hooks.c b/gdb/gdbtk/generic/gdbtk-hooks.c index c01a30573e..04c222d9cb 100644 --- a/gdb/gdbtk/generic/gdbtk-hooks.c +++ b/gdb/gdbtk/generic/gdbtk-hooks.c @@ -105,6 +105,7 @@ static void gdbtk_set_hook (struct cmd_list_element *cmdblk); * 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 diff --git a/gdb/gdbtk/generic/gdbtk-interp.c b/gdb/gdbtk/generic/gdbtk-interp.c index 0e668352f3..a480b745cc 100644 --- a/gdb/gdbtk/generic/gdbtk-interp.c +++ b/gdb/gdbtk/generic/gdbtk-interp.c @@ -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); diff --git a/gdb/gdbtk/generic/gdbtk.h b/gdb/gdbtk/generic/gdbtk.h index c46b285b50..3b59e9cd4f 100644 --- a/gdb/gdbtk/generic/gdbtk.h +++ b/gdb/gdbtk/generic/gdbtk.h @@ -159,6 +159,7 @@ extern int gdbtk_two_elem_cmd (char *, char *); 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