aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>1994-05-13 00:31:31 +0000
committerStan Shebs <shebs@codesourcery.com>1994-05-13 00:31:31 +0000
commita6b26c4431ede17adf8a07f61a43c01b92b8f83f (patch)
tree42579e6fdb96cb16812b39602fd3cc67b538e984
parentedfb9ffd1f5f733233b926d7121d31d6fb4dde62 (diff)
downloadgdb-a6b26c4431ede17adf8a07f61a43c01b92b8f83f.zip
gdb-a6b26c4431ede17adf8a07f61a43c01b92b8f83f.tar.gz
gdb-a6b26c4431ede17adf8a07f61a43c01b92b8f83f.tar.bz2
Changes for MacGDB:
Thu May 12 17:04:58 1994 Stan Shebs (shebs@andros.cygnus.com) * mpw-make.in (INCLUDE_CFLAGS): Add readline source dir. (READLINE_CFLAGS, READLINE_SRC, READLINE_DIR): Uncomment. (TSOBS): Don't compile inflow.c. (all, install): Add MacGDB. * main.c (main): Do Mac-specific init and command loop if a standalone app, skip full option help message if compiling with MPW C. (gdb_readline): If MPW, add a newline after the (gdb) prompt. * utils.c (_initialize_utils): If MPW, don't try to use termcap to compute the window size. * config/m68k/xm-mpw.h (printf, fprintf, fputs, fputc, putc, fflush): Define as macros that expand into hacked_... versions. (StandAlone, mac_app): Declare. * macgdb.r (SIZE): Set the default partition to 4000K. * mac-xdep.c (readline.h, history.h): Include. (terminal.h): Don't include. (mac_app): Define. (gdb_has_a_terminal): Define Mac-specific version. (do_keyboard_command): Simplify search for command string. (readline): Define as gdb_readline. Add other history/readline stubs to make main gdb link. (hacked_fprintf, hacked_printf, hacked_vfprintf, hacked_fputs, hacked_fputc, hacked_fflush): New functions, intercept output to stdout and stderr, send to console window.
-rw-r--r--gdb/ChangeLog.mpw27
-rw-r--r--gdb/config/m68k/xm-mpw.h13
-rw-r--r--gdb/mac-xdep.c238
-rw-r--r--gdb/macgdb.r4
-rw-r--r--gdb/main.c86
-rw-r--r--gdb/mpw-make.in19
-rw-r--r--gdb/utils.c10
7 files changed, 357 insertions, 40 deletions
diff --git a/gdb/ChangeLog.mpw b/gdb/ChangeLog.mpw
index b50de2e..e63dd75 100644
--- a/gdb/ChangeLog.mpw
+++ b/gdb/ChangeLog.mpw
@@ -1,3 +1,30 @@
+Thu May 12 17:04:58 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ * mpw-make.in (INCLUDE_CFLAGS): Add readline source dir.
+ (READLINE_CFLAGS, READLINE_SRC, READLINE_DIR): Uncomment.
+ (TSOBS): Don't compile inflow.c.
+ (all, install): Add MacGDB.
+ * main.c (main): Do Mac-specific init and command loop if a
+ standalone app, skip full option help message if compiling
+ with MPW C.
+ (gdb_readline): If MPW, add a newline after the (gdb) prompt.
+ * utils.c (_initialize_utils): If MPW, don't try to use termcap to
+ compute the window size.
+ * config/m68k/xm-mpw.h (printf, fprintf, fputs, fputc, putc,
+ fflush): Define as macros that expand into hacked_... versions.
+ (StandAlone, mac_app): Declare.
+ * macgdb.r (SIZE): Set the default partition to 4000K.
+ * mac-xdep.c (readline.h, history.h): Include.
+ (terminal.h): Don't include.
+ (mac_app): Define.
+ (gdb_has_a_terminal): Define Mac-specific version.
+ (do_keyboard_command): Simplify search for command string.
+ (readline): Define as gdb_readline.
+ Add other history/readline stubs to make main gdb link.
+ (hacked_fprintf, hacked_printf, hacked_vfprintf, hacked_fputs,
+ hacked_fputc, hacked_fflush): New functions, intercept output to
+ stdout and stderr, send to console window.
+
Tue Apr 26 17:44:27 1994 Stan Shebs (shebs@andros.cygnus.com)
* mpw-make.in (MacGDB): New target, standalone Mac-hosted gdb.
diff --git a/gdb/config/m68k/xm-mpw.h b/gdb/config/m68k/xm-mpw.h
index a072db4..653b6ba 100644
--- a/gdb/config/m68k/xm-mpw.h
+++ b/gdb/config/m68k/xm-mpw.h
@@ -61,6 +61,15 @@ void mpw_abort ();
#define fseek mpw_fseek
#define abort mpw_abort
+#define printf hacked_printf
+#define fprintf hacked_fprintf
+#define vprintf hacked_vfprintf
+#define fputs hacked_fputs
+#define fputc hacked_fputc
+#undef putc
+#define putc hacked_putc
+#define fflush hacked_fflush
+
/* Define as macros so as to mask the previous enum. */
#ifndef BFD_TRUE_FALSE
@@ -112,3 +121,7 @@ char *strdup (char *s1);
#ifndef R_OK
#define R_OK 4
#endif
+
+extern int StandAlone;
+
+extern int mac_app;
diff --git a/gdb/mac-xdep.c b/gdb/mac-xdep.c
index 93fd054..e291262 100644
--- a/gdb/mac-xdep.c
+++ b/gdb/mac-xdep.c
@@ -20,6 +20,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
+#include "readline.h"
+#include "history.h"
+
#include <Values.h>
#include <Types.h>
#include <Resources.h>
@@ -75,10 +78,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "gdbtypes.h"
#include "expression.h"
#include "language.h"
-#include "terminal.h" /* For job_control. */
#include "mac-defs.h"
+int mac_app;
+
int useWNE;
int hasColorQD;
@@ -102,6 +106,10 @@ TEHandle console_text;
Rect console_text_rect;
+/* This will go away eventually. */
+gdb_has_a_terminal () { return 1; }
+
+
mac_init ()
{
SysEnvRec se;
@@ -154,7 +162,7 @@ mac_init ()
else
console_window = GetNewWindow (wConsole, NULL, (WindowPtr) -1L);
- if (1) DebugStr("\pnear beginning");
+ if (0) DebugStr("\pnear beginning");
SetPort (console_window);
console_text_rect = console_window->portRect;
console_text_rect.bottom -= sbarwid - 1;
@@ -526,6 +534,7 @@ do_keyboard_command (key)
char key;
{
int startpos, endpos, i;
+ char *last_newline;
char buf[10], *text_str, *command;
CharsHandle text;
@@ -544,24 +553,20 @@ char key;
}
else
{
- for (i = startpos; i > 0; --i)
+ DebugStr("\plooking for command");
+ last_newline = strrchr(*text+startpos, '\n');
+ if (last_newline)
{
- strncpy (buf, *text + i, 5);
- buf[5] = 0;
- if (strncmp (buf, "(gdb)") == 0)
- break;
- }
- if (i > 0)
- {
- strncpy (commandbuf + 1, *text + i + 5, startpos - i);
- commandbuf[1 + startpos - i] = '\0';
+ strncpy (commandbuf + 1,
+ last_newline,
+ last_newline - (*text+startpos));
+ commandbuf[1 + last_newline - (*text+startpos)] = 0;
+ command = commandbuf + 1;
}
else
{
- SysBeep (20);
- commandbuf[1] = '\0';
+ command = "help";
}
- command = commandbuf + 1;
}
HUnlock ((Handle) text);
commandbuf[0] = strlen(command);
@@ -623,8 +628,207 @@ adjust_console_scrollbars ()
newmax = lines - (((*console_text)->viewRect.bottom - (*console_text)->viewRect.top)
/ (*console_text)->lineHeight);
if (newmax < 0) newmax = 0;
- SetCtlMax(console_v_scrollbar, newmax);
+ SetCtlMax (console_v_scrollbar, newmax);
value = ((*console_text)->viewRect.top - (*console_text)->destRect.top)
/ (*console_text)->lineHeight;
- SetCtlValue(console_v_scrollbar, value);
+ SetCtlValue (console_v_scrollbar, value);
}
+
+/* Readline substitute. */
+
+char *
+readline (char *prrompt)
+{
+ return gdb_readline (prrompt);
+}
+
+char *rl_completer_word_break_characters;
+
+char *rl_completer_quote_characters;
+
+int (*rl_completion_entry_function) ();
+
+int rl_point;
+
+char *rl_line_buffer;
+
+char *rl_readline_name;
+
+/* History substitute. */
+
+void
+add_history (char *buf)
+{
+}
+
+void
+stifle_history (int n)
+{
+}
+
+int
+unstifle_history ()
+{
+}
+
+int
+read_history (char *name)
+{
+}
+
+int
+write_history (char *name)
+{
+}
+
+int
+history_expand (char *x, char **y)
+{
+}
+
+extern HIST_ENTRY *
+history_get (int xxx)
+{
+ return NULL;
+}
+
+int history_base;
+
+char *
+filename_completion_function (char *text, char *name)
+{
+ return "?";
+}
+
+char *
+tilde_expand (char *str)
+{
+ return strsave (str);
+}
+
+/* Modified versions of standard I/O. */
+
+#include <stdarg.h>
+
+#undef fprintf
+
+int
+hacked_fprintf (FILE *fp, const char *fmt, ...)
+{
+ int ret;
+ va_list ap;
+
+ va_start (ap, fmt);
+ if (mac_app && (fp == stdout || fp == stderr))
+ {
+ char buf[1000];
+
+ ret = vsprintf(buf, fmt, ap);
+ TEInsert (buf, strlen(buf), console_text);
+ TESetSelect (100000, 100000, console_text);
+ draw_console ();
+ }
+ else
+ ret = vfprintf (fp, fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
+#undef printf
+
+int
+hacked_printf (const char *fmt, ...)
+{
+ int ret;
+ va_list ap;
+
+ va_start (ap, fmt);
+ if (mac_app)
+ {
+ ret = hacked_vfprintf(stdout, fmt, ap);
+ }
+ else
+ ret = vfprintf (stdout, fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
+#undef vfprintf
+
+int
+hacked_vfprintf (FILE *fp, const char *format, va_list args)
+{
+ if (mac_app && (fp == stdout || fp == stderr))
+ {
+ char buf[1000];
+ int ret;
+
+ ret = vsprintf(buf, format, args);
+ TEInsert (buf, strlen(buf), console_text);
+ TESetSelect (100000, 100000, console_text);
+ draw_console ();
+ return ret;
+ }
+ else
+ return vfprintf (fp, format, args);
+}
+
+#undef fputs
+
+hacked_fputs (const char *s, FILE *fp)
+{
+ if (mac_app && (fp == stdout || fp == stderr))
+ {
+ TEInsert (s, strlen(s), console_text);
+ TESetSelect (100000, 100000, console_text);
+ draw_console ();
+ return 0;
+ }
+ else
+ return fputs (s, fp);
+}
+
+#undef fputc
+
+hacked_fputc (const char c, FILE *fp)
+{
+ if (mac_app && (fp == stdout || fp == stderr))
+ {
+ char buf[2];
+
+ buf[0] = c;
+ TEInsert (buf, 1, console_text);
+ TESetSelect (100000, 100000, console_text);
+ draw_console ();
+ return 0;
+ }
+ else
+ return fputc (c, fp);
+}
+
+#undef putc
+
+hacked_putc (const char c, FILE *fp)
+{
+ if (mac_app && (fp == stdout || fp == stderr))
+ {
+ char buf[2];
+
+ buf[0] = c;
+ TEInsert (buf, 1, console_text);
+ TESetSelect (100000, 100000, console_text);
+ draw_console ();
+ }
+ else
+ return fputc (c, fp);
+}
+
+#undef fflush
+
+hacked_fflush (FILE *fp)
+{
+ if (mac_app && (fp == stdout || fp == stderr))
+ return 0;
+ return fflush (fp);
+}
+
diff --git a/gdb/macgdb.r b/gdb/macgdb.r
index c6798f7..b7bd3a9 100644
--- a/gdb/macgdb.r
+++ b/gdb/macgdb.r
@@ -138,8 +138,8 @@ resource 'SIZE' (-1) {
reserved,
reserved,
reserved,
- 50000,
- 50000
+ 4000*1024,
+ 4000*1024
};
resource 'DLOG' (128) {
diff --git a/gdb/main.c b/gdb/main.c
index 83cbde9..a93461a 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -382,6 +382,18 @@ return_to_top_level (reason)
disable_current_display ();
do_cleanups (ALL_CLEANUPS);
+
+ if (annotation_level > 1)
+ switch (reason)
+ {
+ case RETURN_QUIT:
+ printf_unfiltered ("\n\032\032quit\n");
+ break;
+ case RETURN_ERROR:
+ printf_unfiltered ("\n\032\032error\n");
+ break;
+ }
+
(NORETURN void) longjmp
(reason == RETURN_ERROR ? error_return : quit_return, 1);
}
@@ -551,6 +563,16 @@ main (argc, argv)
register int i;
+/* start-sanitize-mpw */
+#ifdef MPW
+ /* Drop into MacsBug, but only if the executable is specially named. */
+ if (strcmp(argv[0], "DEBUGGDB") == 0)
+ DebugStr("\pat start of GDB main");
+
+ if (StandAlone)
+ mac_app = mac_init ();
+#endif /* MPW */
+/* end-sanitize-mpw */
/* This needs to happen before the first use of malloc. */
init_malloc ((PTR) NULL);
@@ -790,6 +812,12 @@ main (argc, argv)
/* But don't use *_filtered here. We don't want to prompt for continue
no matter how small the screen or how much we're going to print. */
+/* start-sanitize-mpw */
+/* For reasons too ugly to describe... */
+#ifdef MPW_C
+ fputs_unfiltered ("This is the GNU debugger.\n", gdb_stdout);
+#else
+/* end-sanitize-mpw */
fputs_unfiltered ("\
This is the GNU debugger. Usage:\n\
gdb [options] [executable-file [core-file or process-id]]\n\
@@ -812,6 +840,9 @@ Options:\n\
--mapped Use mapped symbol files if supported on this system.\n\
--readnow Fully read symbol files on first access.\n\
", gdb_stdout);
+/* start-sanitize-mpw */
+#endif /* MPW_C */
+/* end-sanitize-mpw */
#ifdef ADDITIONAL_OPTION_HELP
fputs_unfiltered (ADDITIONAL_OPTION_HELP, gdb_stdout);
#endif
@@ -990,6 +1021,17 @@ GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
if (!SET_TOP_LEVEL ())
{
do_cleanups (ALL_CLEANUPS); /* Do complete cleanup */
+/* start-sanitize-mpw */
+#ifdef MPW
+ /* If we're being a Mac application, go into a Mac-specific
+ event-handling loop instead. We still want to be inside
+ the outer loop, because that will catch longjmps resulting
+ from some command executions. */
+ if (mac_app)
+ mac_command_loop ();
+ else
+#endif /* MPW */
+/* start-sanitize-mpw */
command_loop ();
quit_command ((char *)0, instream == stdin);
}
@@ -1119,7 +1161,7 @@ command_loop ()
reinitialize_more_filter ();
old_chain = make_cleanup (command_loop_marker, 0);
command = command_line_input (instream == stdin ? prompt : (char *) NULL,
- instream == stdin);
+ instream == stdin, "prompt");
if (command == 0)
return;
execute_command (command, instream == stdin);
@@ -1166,6 +1208,13 @@ gdb_readline (prrompt)
character position to be off, since the newline we read from
the user is not accounted for. */
fputs_unfiltered (prrompt, gdb_stdout);
+/* start-sanitize-mpw */
+#ifdef MPW
+ /* Move to a new line so the entered line doesn't have a prompt
+ on the front of it. */
+ fputs_unfiltered ("\n", gdb_stdout);
+#endif /* MPW */
+/* end-sanitize-mpw */
gdb_flush (gdb_stdout);
}
@@ -1691,9 +1740,10 @@ init_signals ()
simple input as the user has requested. */
char *
-command_line_input (prrompt, repeat)
+command_line_input (prrompt, repeat, annotation_suffix)
char *prrompt;
int repeat;
+ char *annotation_suffix;
{
static char *linebuffer = 0;
static unsigned linelength = 0;
@@ -1705,11 +1755,17 @@ command_line_input (prrompt, repeat)
char *nline;
char got_eof = 0;
- if (annotation_level > 1 && prrompt != NULL)
+ if (annotation_level > 1 && instream == stdin)
{
- local_prompt = alloca (strlen (prrompt) + 20);
- strcpy (local_prompt, prrompt);
- strcat (local_prompt, "\n\032\032prompt\n");
+ local_prompt = alloca ((prrompt == NULL ? 0 : strlen (prrompt))
+ + strlen (annotation_suffix) + 40);
+ if (prrompt == NULL)
+ local_prompt[0] = '\0';
+ else
+ strcpy (local_prompt, prrompt);
+ strcat (local_prompt, "\n\032\032");
+ strcat (local_prompt, annotation_suffix);
+ strcat (local_prompt, "\n");
}
if (linebuffer == 0)
@@ -1748,7 +1804,11 @@ command_line_input (prrompt, repeat)
}
if (annotation_level > 1 && instream == stdin)
- printf_unfiltered ("\n\032\032pre-prompt\n");
+ {
+ printf_unfiltered ("\n\032\032pre-");
+ printf_unfiltered (annotation_suffix);
+ printf_unfiltered ("\n");
+ }
/* Don't use fancy stuff if not talking to stdin. */
if (command_editing_p && instream == stdin
@@ -1758,7 +1818,11 @@ command_line_input (prrompt, repeat)
rl = gdb_readline (local_prompt);
if (annotation_level > 1 && instream == stdin)
- printf_unfiltered ("\n\032\032post-prompt\n");
+ {
+ printf_unfiltered ("\n\032\032post-");
+ printf_unfiltered (annotation_suffix);
+ printf_unfiltered ("\n");
+ }
if (!rl || rl == (char *) EOF)
{
@@ -1827,7 +1891,7 @@ command_line_input (prrompt, repeat)
if (expanded < 0)
{
free (history_value);
- return command_line_input (prrompt, repeat);
+ return command_line_input (prrompt, repeat, annotation_suffix);
}
if (strlen (history_value) > linelength)
{
@@ -1861,7 +1925,7 @@ command_line_input (prrompt, repeat)
&& ISATTY (stdin) && *linebuffer)
add_history (linebuffer);
- /* Note: lines consisting soley of comments are added to the command
+ /* Note: lines consisting solely of comments are added to the command
history. This is useful when you type a command, and then
realize you don't want to execute it quite yet. You can comment
out the command and then later fetch it from the value history
@@ -1928,7 +1992,7 @@ read_command_lines ()
while (1)
{
dont_repeat ();
- p = command_line_input ((char *) NULL, instream == stdin);
+ p = command_line_input ((char *) NULL, instream == stdin, "commands");
if (p == NULL)
/* Treat end of file like "end". */
break;
diff --git a/gdb/mpw-make.in b/gdb/mpw-make.in
index ebcfb3e..6d47665 100644
--- a/gdb/mpw-make.in
+++ b/gdb/mpw-make.in
@@ -112,7 +112,7 @@ CC-LD={CC}
# This is essentially the header file directory for the library
# routines in libiberty.
INCLUDE_DIR = "{srcroot}"include
-INCLUDE_CFLAGS = -i {INCLUDE_DIR} -i {INCLUDE_DIR}:mpw -i ::extra-include -i "{srcroot}"bfd
+INCLUDE_CFLAGS = -i {INCLUDE_DIR} -i {INCLUDE_DIR}:mpw -i ::extra-include -i "{srcroot}"bfd -i "{srcroot}"readline
# Where is the "-liberty" library, containing getopt and obstack?
LIBIBERTY = ::libiberty:libiberty.o
@@ -133,12 +133,12 @@ BFD_SRC = "{srcdir}"{BFD_DIR}
BFD_CFLAGS = -i {BFD_DIR} -i {BFD_SRC}
# Where is the READLINE library? Typically in ::readline.
-#READLINE_DIR = ::readline
+READLINE_DIR = ::readline
READLINE = {READLINE_DIR}:libreadline.o
-READLINE_DISABLE = -d NO_READLINE
-#READLINE_SRC = "{srcdir}"{READLINE_DIR}
-#READLINE_CFLAGS = -i {READLINE_SRC}
-READLINE_CFLAGS = {READLINE_DISABLE}
+#READLINE_DISABLE = -d NO_READLINE
+READLINE_SRC = "{srcdir}"{READLINE_DIR}
+READLINE_CFLAGS = -i {READLINE_SRC}
+#READLINE_CFLAGS = {READLINE_DISABLE}
# Opcodes currently live in one of two places. Either they are in the
# opcode library, typically ::opcodes, or they are in a header file
@@ -659,7 +659,7 @@ OBS = "{o}"version.c.o "{o}"main.c.o "{o}"blockframe.c.o "{o}"breakpoint.gc.o "{
"{o}"c-valprint.c.o "{o}"cp-valprint.c.o "{o}"ch-valprint.c.o "{o}"m2-valprint.c.o "{o}"nlmread.c.o \Option-d
"{o}"serial.c.o "{o}"mdebugread.c.o
-TSOBS = "{o}"inflow.c.o
+TSOBS =
NTSOBS = "{o}"standalone.c.o
@@ -678,7 +678,7 @@ YYOBJ = c-exp.tab.c.o m2-exp.tab.c.o ch-exp.tab.c.o
# .c.o \Option-f
# {CC} -c {INTERNAL_CFLAGS} $<
-all \Option-f gdb
+all \Option-f gdb MacGDB
# @{MAKE} {FLAGS_TO_PASS} DO=all "DODIRS=`echo {SUBDIRS} | sed 's:testsuite::'`" subdir_do
# The check target can not use subdir_do, because subdir_do does not
@@ -705,7 +705,8 @@ gdb.z \Option-f gdb.1
# install-only is intended to address that need.
install \Option-f all install-only
install-only \Option-f
- Duplicate -i -y gdb "{bindir}"gdb
+ Duplicate -y gdb "{bindir}":gdb
+ Duplicate -y MacGDB "{bindir}":MacGDB
uninstall \Option-f force
Delete -i -y {bindir}:gdb {man1dir}:gdb.1
diff --git a/gdb/utils.c b/gdb/utils.c
index 33501ba..0640cac 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -251,7 +251,7 @@ warning (va_alist)
}
/* Start the printing of an error message. Way to use this is to call
- this, output the error message, and then call
+ this, output the error message (use filtered output), and then call
return_to_top_level (RETURN_ERROR). error() provides a convenient way to
do this for the special case that the error message can be formatted with
a single printf call, but this is more general. */
@@ -1733,6 +1733,11 @@ _initialize_utils ()
#else
lines_per_page = 24;
chars_per_line = 80;
+/* start-sanitize-mpw */
+#ifndef MPW
+ /* No termcap under MPW, although might be cool to do something
+ by looking at worksheet or console window sizes. */
+/* end-sanitize-mpw */
/* Initialize the screen height and width from termcap. */
{
char *termtype = getenv ("TERM");
@@ -1767,6 +1772,9 @@ _initialize_utils ()
}
}
}
+/* start-sanitize-mpw */
+#endif /* MPW */
+/* end-sanitize-mpw */
#if defined(SIGWINCH) && defined(SIGWINCH_HANDLER)