[rfc] Move putchar_filtered() to utils.c

Andrew Cagney ac131313@cygnus.com
Tue Jan 30 16:11:00 GMT 2001


Hello,

The attatched moves the recently added putchar_filtered() function to
utils.c/defs.h.  That is where all the *_filtered() wrapper functions
currently live.  I can't think of a good reason to put just one function
down in cli/cli-utils.c especially when we're hopefully going to delete
it :-)

People looking at the *_filtered() stuff probably want to look at the
TODO file vis:

--

Send normal output to gdb_stdout.
Send error messages to gdb_stderror.
Send debug and log output log gdb_stdlog.

GDB still contains many cases where (f)printf or printf_filtered () is
used when it should be sending the messages to gdb_stderror or
gdb_stdlog.  The thought of #defining printf to something has crossed
peoples minds ;-)

--

Re-do GDB's output pager.

GDB's output pager still relies on people correctly using *_filtered
for gdb_stdout and *_unfiltered for gdb_stdlog / gdb_stderr.
Hopefully, with all normal output going to gdb_stdout, the pager can
just look at the ui_file that the output is on and then use that to
decide what to do about paging.  Sounds good in theory.

--

	Andrew
Tue Jan 30 15:43:08 2001  Andrew Cagney  <cagney@cygnus.com>

	* cli/cli-utils.c (putchar_filtered): Move from here. Delete file.
	* cli/cli-utils.h: Delete.
	* utils.c (putchar_filtered): To here.
	* defs.h (putchar_filtered): Add declaration.
	
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.58
diff -p -r1.58 Makefile.in
*** Makefile.in	2001/01/23 22:48:55	1.58
--- Makefile.in	2001/01/30 23:51:09
*************** INTL_CFLAGS = -I$(INTL_DIR) -I$(INTL_SRC
*** 141,150 ****
  # CLI sub directory definitons
  #
  SUBDIR_CLI_OBS = \
! 	cli-decode.o cli-script.o cli-cmds.o cli-setshow.o cli-utils.o
  SUBDIR_CLI_SRCS = \
! 	cli/cli-decode.c cli/cli-script.c cli/cli-cmds.c cli/cli-setshow.c \
! 	cli/cli-utils.c
  SUBDIR_CLI_DEPS =
  SUBDIR_CLI_INITS =
  SUBDIR_CLI_LDFLAGS=
--- 141,149 ----
  # CLI sub directory definitons
  #
  SUBDIR_CLI_OBS = \
! 	cli-decode.o cli-script.o cli-cmds.o cli-setshow.o
  SUBDIR_CLI_SRCS = \
! 	cli/cli-decode.c cli/cli-script.c cli/cli-cmds.c cli/cli-setshow.c
  SUBDIR_CLI_DEPS =
  SUBDIR_CLI_INITS =
  SUBDIR_CLI_LDFLAGS=
*************** cli_decode_h =	$(srcdir)/cli/cli-decode.
*** 605,611 ****
  cli_cmds_h =	$(srcdir)/cli/cli-cmds.h
  cli_script_h =	$(srcdir)/cli/cli-script.h
  cli_setshow_h =	$(srcdir)/cli/cli-setshow.h
- cli_utils_h =	$(srcdir)/cli/cli-utils.h
  
  # Header files that need to have srcdir added.  Note that in the cases
  # where we use a macro like $(gdbcmd_h), things are carefully arranged
--- 604,609 ----
*************** cli-script.o: $(srcdir)/cli/cli-script.c
*** 2084,2092 ****
  		$(cli_cmds_h) $(cli_decode_h) top.h \
  		$(defs_h) $(value_h) language.h $(ui_out_h)
  	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-script.c
- 
- cli-utils.o: $(srcdir)/cli/cli-utils.c $(cli_utils_h) $(defs_h)
- 	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-utils.c
  
  #
  # MI dependencies
--- 2082,2087 ----
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.34
diff -p -r1.34 defs.h
*** defs.h	2001/01/19 08:01:46	1.34
--- defs.h	2001/01/30 23:51:10
*************** extern struct ui_file *gdb_stdtarg;
*** 435,441 ****
  
  #include "ui-file.h"
  
! /* More generic printf like operations */
  
  extern void fputs_filtered (const char *, struct ui_file *);
  
--- 435,442 ----
  
  #include "ui-file.h"
  
! /* More generic printf like operations.  Filtered versions may return
!    non-locally on error.  */
  
  extern void fputs_filtered (const char *, struct ui_file *);
  
*************** extern void fputs_unfiltered (const char
*** 444,449 ****
--- 445,452 ----
  extern int fputc_filtered (int c, struct ui_file *);
  
  extern int fputc_unfiltered (int c, struct ui_file *);
+ 
+ extern int putchar_filtered (int c);
  
  extern int putchar_unfiltered (int c);
  
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.25
diff -p -r1.25 utils.c
*** utils.c	2000/12/15 01:01:50	1.25
--- utils.c	2001/01/30 23:51:10
*************** putchar_unfiltered (int c)
*** 1866,1871 ****
--- 1866,1880 ----
    return c;
  }
  
+ /* Write character C to gdb_stdout using GDB's paging mechanism and return C.
+    May return nonlocally.  */
+ 
+ int
+ putchar_filtered (int c)
+ {
+   return fputc_filtered (c, gdb_stdout);
+ }
+ 
  int
  fputc_unfiltered (int c, struct ui_file *stream)
  {
Index: cli/cli-utils.c
===================================================================
RCS file: cli-utils.c
diff -N cli-utils.c
*** /sourceware/cvs-tmp/cvsZK15os	Tue Jan 30 15:51:11 2001
--- /dev/null	Tue May  5 13:32:27 1998
***************
*** 1,29 ****
- /* GDB CLI utility library.
-    Copyright 2001 Free Software Foundation, Inc.
- 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
- 
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
- 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330,
-    Boston, MA 02111-1307, USA.  */
- 
- #include "defs.h"
- #include "cli/cli-utils.h"
- 
- /* Write character C to gdb_stdout using GDB's paging mechanism and return C.
-    May return nonlocally.  */
- 
- int
- putchar_filtered (int c)
- {
-   return fputc_filtered (c, gdb_stdout);
- }
--- 0 ----
Index: cli/cli-utils.h
===================================================================
RCS file: cli-utils.h
diff -N cli-utils.h
*** /sourceware/cvs-tmp/cvsGPINFs	Tue Jan 30 15:51:12 2001
--- /dev/null	Tue May  5 13:32:27 1998
***************
*** 1,27 ****
- /* Header file for GDB CLI utility library.
-    Copyright (C) 2001 Free Software Foundation, Inc.
- 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
- 
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
- 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330,
-    Boston, MA 02111-1307, USA.  */
- 
- #if !defined (CLI_UTILS_H)
- # define CLI_UTILS_H 1
- 
- /* Write character C to gdb_stdout using GDB's paging mechanism and return C.
-    May return nonlocally.  */
- 
- extern int putchar_filtered (int c);
- 
- #endif /* !defined (CLI_UTILS_H) */
--- 0 ----


More information about the Gdb-patches mailing list