diff options
author | Stan Shebs <shebs@codesourcery.com> | 1995-05-11 02:01:22 +0000 |
---|---|---|
committer | Stan Shebs <shebs@codesourcery.com> | 1995-05-11 02:01:22 +0000 |
commit | 19405856a16f83ee28958ee6c9d6e44b1feceff6 (patch) | |
tree | e9616ecff6a37eaa0c61a4d5f874e6a03db62d5f /gdb | |
parent | dea16e4dba6da5a7c9593606f99056c14631280f (diff) | |
download | gdb-19405856a16f83ee28958ee6c9d6e44b1feceff6.zip gdb-19405856a16f83ee28958ee6c9d6e44b1feceff6.tar.gz gdb-19405856a16f83ee28958ee6c9d6e44b1feceff6.tar.bz2 |
Blasting old junk
Diffstat (limited to 'gdb')
-rwxr-xr-x | gdb/energize-patches | 1749 | ||||
-rw-r--r-- | gdb/energize.c | 1716 | ||||
-rw-r--r-- | gdb/energize.h | 92 | ||||
-rw-r--r-- | gdb/remote-mon.c | 1259 | ||||
-rw-r--r-- | gdb/remote-sa.sparc.c | 1144 | ||||
-rw-r--r-- | gdb/state.c | 775 | ||||
-rw-r--r-- | gdb/state.h | 85 |
7 files changed, 0 insertions, 6820 deletions
diff --git a/gdb/energize-patches b/gdb/energize-patches index ed5b581..e69de29 100755 --- a/gdb/energize-patches +++ b/gdb/energize-patches @@ -1,1749 +0,0 @@ -# Apply these patches to GDB to produce an Energize GDB. -# To apply these patches, first cd to gdb-XX/gdb, run "patch -p0 <thisfile", -# and then Sanitize. - -=================================================================== -*** 2.72 1992/09/27 06:48:41 ---- .Sanitize 1992/09/28 21:34:08 -*************** -*** 74,79 **** ---- 74,82 ---- - doc - dwarfread.c - elfread.c -+ energize -+ energize.c -+ energize.h - environ.c - environ.h - eval.c -=================================================================== -*** 1.187 1992/09/26 08:06:30 ---- Makefile.in 1992/09/28 21:34:08 -*************** -*** 123,128 **** ---- 123,135 ---- - READLINE_DEP = $$(READLINE_DIR) - RL_LIB = ./../readline${subdir}/libreadline.a - -+ # Energize libraries. Works slightly differently than other libraries -+ # because it is a gdb subdir and we try to build the energize library -+ # if it doesn't exist, unlike readline, bfd, mmalloc, etc. Note -+ # that SDIR and BDIR will be different if we configured with -srcdir. -+ ENERGIZE_DIR = energize -+ ENERGIZE_LIB = ${ENERGIZE_DIR}/libconn.a -+ - # All the includes used for CFLAGS and for lint. - # -I. for config files. - # -I${srcdir} possibly for regex.h also. -*************** -*** 157,166 **** - # Libraries and corresponding dependencies for compiling gdb. - # {X,T}M_CLIBS, defined in *config files, have host- and target-dependent libs. - # TERMCAP comes after readline, since readline depends on it. -! CLIBS = ${BFD_LIB} ${RL_LIB} ${TERMCAP} ${OPCODES} ${MMALLOC_LIB} ${LIBIBERTY} \ -! ${XM_CLIBS} ${TM_CLIBS} ${NAT_CLIBS} -! CDEPS = ${XM_CDEPS} ${TM_CDEPS} ${NAT_CDEPS} \ -! ${BFD_LIB} ${RL_LIB} ${OPCODES} ${MMALLOC_LIB} ${LIBIBERTY} - - ADD_FILES = ${REGEX} ${ALLOCA} ${XM_ADD_FILES} ${TM_ADD_FILES} ${NAT_ADD_FILES} - ADD_DEPS = ${REGEX1} ${ALLOCA1} ${XM_ADD_FILES} ${TM_ADD_FILES} ${NAT_ADD_FILES} ---- 164,173 ---- - # Libraries and corresponding dependencies for compiling gdb. - # {X,T}M_CLIBS, defined in *config files, have host- and target-dependent libs. - # TERMCAP comes after readline, since readline depends on it. -! CLIBS = ${BFD_LIB} ${RL_LIB} ${TERMCAP} ${OPCODES} ${MMALLOC_LIB} \ -! ${LIBIBERTY} ${XM_CLIBS} ${TM_CLIBS} ${NAT_CLIBS} ${ENERGIZE_LIB} -! CDEPS = ${XM_CDEPS} ${TM_CDEPS} ${NAT_CDEPS} ${BFD_LIB} ${RL_LIB} ${OPCODES} \ -! ${MMALLOC_LIB} ${LIBIBERTY} ${ENERGIZE_LIB} - - ADD_FILES = ${REGEX} ${ALLOCA} ${XM_ADD_FILES} ${TM_ADD_FILES} ${NAT_ADD_FILES} - ADD_DEPS = ${REGEX1} ${ALLOCA1} ${XM_ADD_FILES} ${TM_ADD_FILES} ${NAT_ADD_FILES} -*************** -*** 200,206 **** - mem-break.c target.c \ - dbxread.c coffread.c elfread.c dwarfread.c xcoffread.c stabsread.c \ - language.c parse.c buildsym.c objfiles.c \ -! minsyms.c mipsread.c maint.c - - # Source files in subdirectories (which will be handled separately by - # 'make gdb.tar.Z'). ---- 207,213 ---- - mem-break.c target.c \ - dbxread.c coffread.c elfread.c dwarfread.c xcoffread.c stabsread.c \ - language.c parse.c buildsym.c objfiles.c \ -! minsyms.c mipsread.c maint.c energize.c - - # Source files in subdirectories (which will be handled separately by - # 'make gdb.tar.Z'). -*************** -*** 289,295 **** - command.o utils.o expprint.o environ.o version.o gdbtypes.o \ - copying.o $(DEPFILES) mem-break.o target.o \ - putenv.o parse.o language.o $(YYOBJ) \ -! buildsym.o objfiles.o minsyms.o maint.o demangle.o \ - dbxread.o coffread.o elfread.o dwarfread.o xcoffread.o mipsread.o \ - stabsread.o core.o - ---- 296,302 ---- - command.o utils.o expprint.o environ.o version.o gdbtypes.o \ - copying.o $(DEPFILES) mem-break.o target.o \ - putenv.o parse.o language.o $(YYOBJ) \ -! buildsym.o objfiles.o minsyms.o maint.o demangle.o energize.o \ - dbxread.o coffread.o elfread.o dwarfread.o xcoffread.o mipsread.o \ - stabsread.o core.o - -*************** -*** 303,309 **** - - NTSSTART = kdb-start.o - -! SUBDIRS = doc - - # For now, shortcut the "configure GDB for fewer languages" stuff. - YYFILES = c-exp.tab.c m2-exp.tab.c ---- 310,316 ---- - - NTSSTART = kdb-start.o - -! SUBDIRS = doc ${ENERGIZE_DIR} - - # For now, shortcut the "configure GDB for fewer languages" stuff. - YYFILES = c-exp.tab.c m2-exp.tab.c -*************** -*** 365,370 **** ---- 372,391 ---- - #load `echo " "$(DEPFILES) | sed -e 's/\.o/.c/g' -e 's, , ../,g'` - echo "Load .c corresponding to:" $(DEPFILES) - -+ ${ENERGIZE_LIB} : -+ @(cd ${ENERGIZE_DIR}; \ -+ $(MAKE) \ -+ "against=$(against)" \ -+ "AR=$(AR)" \ -+ "AR_FLAGS=$(AR_FLAGS)" \ -+ "CC=$(CC)" \ -+ "CFLAGS=$(CFLAGS)" \ -+ "RANLIB=$(RANLIB)" \ -+ "MAKEINFO=$(MAKEINFO)" \ -+ "INSTALL=$(INSTALL)" \ -+ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ -+ "INSTALL_DATA=$(INSTALL_DATA)" \ -+ "BISON=$(BISON)") - - # This is useful when debugging GDB, because some Unix's don't let you run GDB - # on itself without copying the executable. So "make gdb1" will make -=================================================================== -*** 1.48 1992/09/29 05:07:04 ---- breakpoint.c 1992/09/28 21:34:09 -*************** -*** 273,278 **** ---- 273,279 ---- - b->cond_string = NULL; - if (from_tty) - printf_filtered ("Breakpoint %d now unconditional.\n", bnum); -+ energize_condition_breakpoint(b); - } - else - { -*************** -*** 281,286 **** ---- 282,288 ---- - typed in or the decompiled expression. */ - b->cond_string = savestring (arg, strlen (arg)); - b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0); -+ energize_condition_breakpoint(b); - if (*arg) - error ("Junk at end of expression"); - } -*************** -*** 322,327 **** ---- 324,330 ---- - l = read_command_lines (); - free_command_lines (&b->commands); - b->commands = l; -+ energize_commands_breakpoint(b); - return; - } - error ("No breakpoint number %d.", bnum); -*************** -*** 445,452 **** - b->enable = disabled; - if (!disabled_breaks) - { -! fprintf (stderr, -! "Cannot insert breakpoint %d:\n", b->number); - printf_filtered ("Disabling shared library breakpoints:\n"); - } - disabled_breaks = 1; ---- 448,455 ---- - b->enable = disabled; - if (!disabled_breaks) - { -! fprintf_filtered (stderr, "Cannot insert breakpoint %d:\n", -! b->number); - printf_filtered ("Disabling shared library breakpoints:\n"); - } - disabled_breaks = 1; -*************** -*** 455,464 **** - else - #endif - { -! fprintf (stderr, "Cannot insert breakpoint %d:\n", b->number); - #ifdef ONE_PROCESS_WRITETEXT -! fprintf (stderr, -! "The same program may be running in another process.\n"); - #endif - memory_error (val, b->address); /* which bombs us out */ - } ---- 458,468 ---- - else - #endif - { -! fprintf_filtered (stderr, "Cannot insert breakpoint %d:\n", -! b->number); - #ifdef ONE_PROCESS_WRITETEXT -! fprintf_filtered (stderr, -! "The same program may be running in another process.\n"); - #endif - memory_error (val, b->address); /* which bombs us out */ - } -*************** -*** 478,484 **** - int val; - - #ifdef BREAKPOINT_DEBUG -! printf ("Removing breakpoints.\n"); - #endif /* BREAKPOINT_DEBUG */ - - ALL_BREAKPOINTS (b) ---- 482,488 ---- - int val; - - #ifdef BREAKPOINT_DEBUG -! printf_filtered ("Removing breakpoints.\n"); - #endif /* BREAKPOINT_DEBUG */ - - ALL_BREAKPOINTS (b) -*************** -*** 489,500 **** - return val; - b->inserted = 0; - #ifdef BREAKPOINT_DEBUG -! printf ("Removed breakpoint at %s", -! local_hex_string(b->address)); -! printf (", shadow %s", -! local_hex_string(b->shadow_contents[0])); -! printf (", %s.\n", -! local_hex_string(b->shadow_contents[1])); - #endif /* BREAKPOINT_DEBUG */ - } - ---- 493,504 ---- - return val; - b->inserted = 0; - #ifdef BREAKPOINT_DEBUG -! printf_filtered ("Removed breakpoint at %s", -! local_hex_string(b->address)); -! printf_filtered (", shadow %s", -! local_hex_string(b->shadow_contents[0])); -! printf_filtered (", %s.\n", -! local_hex_string(b->shadow_contents[1])); - #endif /* BREAKPOINT_DEBUG */ - } - -*************** -*** 922,927 **** ---- 926,932 ---- - { - b->ignore_count--; - this_bp_stop = 0; -+ energize_ignore_breakpoint(b); - } - else - { -*************** -*** 1141,1157 **** - others++; - if (others > 0) - { -! printf ("Note: breakpoint%s ", (others > 1) ? "s" : ""); - ALL_BREAKPOINTS (b) - if (b->address == pc) - { - others--; -! printf ("%d%s%s ", -! b->number, -! (b->enable == disabled) ? " (disabled)" : "", -! (others > 1) ? "," : ((others == 1) ? " and" : "")); - } -! printf ("also set at pc %s.\n", local_hex_string(pc)); - } - } - ---- 1146,1163 ---- - others++; - if (others > 0) - { -! printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : ""); - ALL_BREAKPOINTS (b) - if (b->address == pc) - { - others--; -! printf_filtered ("%d%s%s ", -! b->number, -! (b->enable == disabled) ? " (disabled)" : "", -! (others > 1) ? "," : -! ((others == 1) ? " and" : "")); - } -! printf_filtered ("also set at pc %s.\n", local_hex_string(pc)); - } - } - -*************** -*** 1373,1378 **** ---- 1379,1386 ---- - mention (b) - struct breakpoint *b; - { -+ energize_create_breakpoint(b); -+ - switch (b->type) - { - case bp_watchpoint: -*************** -*** 1550,1557 **** - - if (sals.nelts > 1) - { -! printf ("Multiple breakpoints were set.\n"); -! printf ("Use the \"delete\" command to delete unwanted breakpoints.\n"); - } - free ((PTR)sals.sals); - } ---- 1558,1565 ---- - - if (sals.nelts > 1) - { -! printf_filtered ("Multiple breakpoints were set.\n"); -! printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n"); - } - free ((PTR)sals.sals); - } -*************** -*** 1769,1775 **** - goto win; - } - #endif -! printf ("No catch clause for exception %s.\n", p); - #if 0 - win: - #endif ---- 1777,1783 ---- - goto win; - } - #endif -! printf_filtered ("No catch clause for exception %s.\n", p); - #if 0 - win: - #endif -*************** -*** 1970,1985 **** - b->enable = enabled; - b->disposition = tempflag ? delete : donttouch; - -! printf ("Breakpoint %d at %s", b->number, local_hex_string(b->address)); - if (b->symtab) -! printf (": file %s, line %d.", b->symtab->filename, b->line_number); -! printf ("\n"); - } - - if (sals.nelts > 1) - { -! printf ("Multiple breakpoints were set.\n"); -! printf ("Use the \"delete\" command to delete unwanted breakpoints.\n"); - } - free ((PTR)sals.sals); - } ---- 1978,1995 ---- - b->enable = enabled; - b->disposition = tempflag ? delete : donttouch; - -! printf_filtered ("Breakpoint %d at %s", b->number, -! local_hex_string(b->address)); - if (b->symtab) -! printf_filtered (": file %s, line %d.", -! b->symtab->filename, b->line_number); -! printf_filtered ("\n"); - } - - if (sals.nelts > 1) - { -! printf_filtered ("Multiple breakpoints were set.\n"); -! printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n"); - } - free ((PTR)sals.sals); - } -*************** -*** 2086,2095 **** - } - - if (found->next) from_tty = 1; /* Always report if deleted more than one */ -! if (from_tty) printf ("Deleted breakpoint%s ", found->next ? "s" : ""); - while (found) - { -! if (from_tty) printf ("%d ", found->number); - b1 = found->next; - delete_breakpoint (found); - found = b1; ---- 2096,2106 ---- - } - - if (found->next) from_tty = 1; /* Always report if deleted more than one */ -! if (from_tty) printf_filtered ("Deleted breakpoint%s ", -! found->next ? "s" : ""); - while (found) - { -! if (from_tty) printf_filtered ("%d ", found->number); - b1 = found->next; - delete_breakpoint (found); - found = b1; -*************** -*** 2120,2125 **** ---- 2131,2138 ---- - register struct breakpoint *b; - register bpstat bs; - -+ energize_delete_breakpoint(bpt); -+ - if (bpt->inserted) - target_remove_breakpoint(bpt->address, bpt->shadow_contents); - -*************** -*** 2144,2150 **** - free ((PTR)bpt->addr_string); - - if (xgdb_verbose && bpt->type == bp_breakpoint) -! printf ("breakpoint #%d deleted\n", bpt->number); - - /* Be sure no bpstat's are pointing at it after it's been freed. */ - /* FIXME, how can we find all bpstat's? We just check stop_bpstat for now. */ ---- 2157,2163 ---- - free ((PTR)bpt->addr_string); - - if (xgdb_verbose && bpt->type == bp_breakpoint) -! printf_filtered ("breakpoint #%d deleted\n", bpt->number); - - /* Be sure no bpstat's are pointing at it after it's been freed. */ - /* FIXME, how can we find all bpstat's? We just check stop_bpstat for now. */ -*************** -*** 2264,2270 **** - - ALL_BREAKPOINTS_SAFE (b, temp) - { -! sprintf (message, message1, b->number); /* Format possible error msg */ - catch_errors (breakpoint_re_set_one, (char *) b, message); - } - ---- 2277,2283 ---- - - ALL_BREAKPOINTS_SAFE (b, temp) - { -! printf_filtered (message, message1, b->number); /* Format possible error msg */ - catch_errors (breakpoint_re_set_one, (char *) b, message); - } - -*************** -*** 2298,2303 **** ---- 2311,2317 ---- - if (b->number == bptnum) - { - b->ignore_count = count; -+ energize_ignore_breakpoint(b); - if (!from_tty) - return; - else if (count == 0) -*************** -*** 2322,2328 **** - struct breakpoint *b; - - ALL_BREAKPOINTS (b) -! b->ignore_count = 0; - } - - /* Command to set ignore-count of breakpoint N to COUNT. */ ---- 2336,2345 ---- - struct breakpoint *b; - - ALL_BREAKPOINTS (b) -! { -! b->ignore_count = 0; -! energize_ignore_breakpoint(b); -! } - } - - /* Command to set ignore-count of breakpoint N to COUNT. */ -*************** -*** 2377,2383 **** - function (b); - goto win; - } -! printf ("No breakpoint number %d.\n", num); - win: - p = p1; - } ---- 2394,2400 ---- - function (b); - goto win; - } -! printf_filtered ("No breakpoint number %d.\n", num); - win: - p = p1; - } -*************** -*** 2389,2396 **** - { - bpt->enable = enabled; - - if (xgdb_verbose && bpt->type == bp_breakpoint) -! printf ("breakpoint #%d enabled\n", bpt->number); - - check_duplicates (bpt->address); - if (bpt->type == bp_watchpoint) ---- 2406,2415 ---- - { - bpt->enable = enabled; - -+ energize_enable_breakpoint(bpt); -+ - if (xgdb_verbose && bpt->type == bp_breakpoint) -! printf_filtered ("breakpoint #%d enabled\n", bpt->number); - - check_duplicates (bpt->address); - if (bpt->type == bp_watchpoint) -*************** -*** 2436,2441 **** ---- 2455,2462 ---- - disable_breakpoint (bpt) - struct breakpoint *bpt; - { -+ energize_disable_breakpoint(bpt); -+ - bpt->enable = disabled; - - if (xgdb_verbose && bpt->type == bp_breakpoint) -=================================================================== -*** 1.18 1992/07/10 17:22:30 ---- command.c 1992/09/28 21:34:09 -*************** -*** 1093,1098 **** ---- 1093,1100 ---- - else - error ("gdb internal error: bad cmd_type in do_setshow_command"); - (*c->function.sfunc) (NULL, from_tty, c); -+ if (energize) -+ print_prompt(); - } - - /* Show all the settings in a list of show commands. */ -*************** -*** 1148,1154 **** - } - - if (pid != -1) -! while ((rc = wait (&status)) != pid && rc != -1) - ; - else - error ("Fork failed"); ---- 1150,1156 ---- - } - - if (pid != -1) -! while ((rc = energize_shell_wait (&status)) != pid && rc != -1) - ; - else - error ("Fork failed"); -=================================================================== -*** 1.67 1992/09/21 20:01:00 ---- configure.in 1992/09/28 21:34:10 -*************** -*** 1,4 **** -! configdirs="doc" - srcname="GDB" - srctrigger=main.c - ---- 1,4 ---- -! configdirs="energize doc" - srcname="GDB" - srctrigger=main.c - -=================================================================== -*** 1.48 1992/09/15 08:55:59 ---- defs.h 1992/09/28 21:34:10 -*************** -*** 811,814 **** ---- 811,816 ---- - #define MAINTENANCE_CMDS 1 - #endif - -+ #include "energize.h" -+ - #endif /* !defined (DEFS_H) */ -=================================================================== -*** 2.5 1992/09/03 16:26:03 ---- demangle.c 1992/09/28 21:34:10 -*************** -*** 37,43 **** - the appropriate target configuration file. */ - - #ifndef DEFAULT_DEMANGLING_STYLE -! # define DEFAULT_DEMANGLING_STYLE AUTO_DEMANGLING_STYLE_STRING - #endif - - /* String name for the current demangling style. Set by the "set demangling" ---- 37,43 ---- - the appropriate target configuration file. */ - - #ifndef DEFAULT_DEMANGLING_STYLE -! # define DEFAULT_DEMANGLING_STYLE LUCID_DEMANGLING_STYLE_STRING - #endif - - /* String name for the current demangling style. Set by the "set demangling" -=================================================================== -*** 1.34 1992/09/26 05:20:04 ---- infcmd.c 1992/09/28 21:34:11 -*************** -*** 242,247 **** ---- 242,248 ---- - - target_create_inferior (exec_file, inferior_args, - environ_vector (inferior_environ)); -+ energize_new_process(); - } - - static void -=================================================================== -*** 1.29 1992/09/25 19:19:00 ---- inflow.c 1992/09/28 21:34:11 -*************** -*** 87,93 **** - static short pgrp_inferior; - static short pgrp_ours; - # else /* not def SHORT_PGRP */ -! static int pgrp_inferior; - static int pgrp_ours; - # endif /* not def SHORT_PGRP */ - #else /* not def TIOCGPGRP */ ---- 87,93 ---- - static short pgrp_inferior; - static short pgrp_ours; - # else /* not def SHORT_PGRP */ -! int pgrp_inferior; - static int pgrp_ours; - # endif /* not def SHORT_PGRP */ - #else /* not def TIOCGPGRP */ -=================================================================== -*** 1.59 1992/09/26 01:49:01 ---- infrun.c 1992/09/28 21:34:12 -*************** -*** 519,525 **** - flush_cached_frames (); - registers_changed (); - -! target_wait (&w); - - #ifdef SIGTRAP_STOP_AFTER_LOAD - ---- 519,525 ---- - flush_cached_frames (); - registers_changed (); - -! energize_wait (&w); - - #ifdef SIGTRAP_STOP_AFTER_LOAD - -=================================================================== -*** 1.17 1992/09/26 09:06:10 ---- inftarg.c 1992/09/28 21:34:12 -*************** -*** 123,128 **** ---- 123,129 ---- - - attach (pid); - inferior_pid = pid; -+ energize_new_process(); - push_target (&child_ops); - #endif /* ATTACH_DETACH */ - } -=================================================================== -*** 1.57 1992/09/29 05:07:14 ---- main.c 1992/09/28 21:34:13 -*************** -*** 441,446 **** ---- 441,447 ---- - char *corearg = NULL; - char *cdarg = NULL; - char *ttyarg = NULL; -+ char *energize_id = NULL; - - /* Pointers to all arguments of +command option. */ - char **cmdarg; -*************** -*** 539,544 **** ---- 540,546 ---- - {"tty", required_argument, 0, 't'}, - {"baud", required_argument, 0, 'b'}, - {"b", required_argument, 0, 'b'}, -+ {"context", required_argument, 0, 12}, - /* Allow machine descriptions to add more options... */ - #ifdef ADDITIONAL_OPTIONS - ADDITIONAL_OPTIONS -*************** -*** 571,576 **** ---- 573,581 ---- - case 11: - cdarg = optarg; - break; -+ case 12: -+ energize_id = optarg; -+ break; - case 's': - symarg = optarg; - break; -*************** -*** 611,617 **** - ADDITIONAL_OPTION_CASES - #endif - case '?': -! fprintf (stderr, - "Use `%s +help' for a complete list of options.\n", - argv[0]); - exit (1); ---- 616,622 ---- - ADDITIONAL_OPTION_CASES - #endif - case '?': -! fprintf_filtered (stderr, - "Use `%s +help' for a complete list of options.\n", - argv[0]); - exit (1); -*************** -*** 668,674 **** - corearg = argv[optind]; - break; - case 3: -! fprintf (stderr, - "Excess command line arguments ignored. (%s%s)\n", - argv[optind], (optind == argc - 1) ? "" : " ..."); - break; ---- 673,679 ---- - corearg = argv[optind]; - break; - case 3: -! fprintf_filtered (stderr, - "Excess command line arguments ignored. (%s%s)\n", - argv[optind], (optind == argc - 1) ? "" : " ..."); - break; -*************** -*** 679,684 **** ---- 684,692 ---- - - /* Run the init function of each source file */ - -+ /* Must call this first to setup tty */ -+ energize_initialize (energize_id, execarg); -+ - initialize_cmd_lists (); /* This needs to be done first */ - initialize_all_files (); - initialize_main (); /* But that omits this file! Do it now */ -*************** -*** 853,859 **** - if (!setjmp (to_top_level)) - { - do_cleanups (ALL_CLEANUPS); /* Do complete cleanup */ -! command_loop (); - quit_command ((char *)0, instream == stdin); - } - } ---- 861,870 ---- - if (!setjmp (to_top_level)) - { - do_cleanups (ALL_CLEANUPS); /* Do complete cleanup */ -! if (energize) -! energize_main_loop(); -! else -! command_loop (); - quit_command ((char *)0, instream == stdin); - } - } -*************** -*** 915,921 **** - else if (c->function.cfunc == NO_FUNCTION) - error ("That is not a command, just a help topic."); - else -! (*c->function.cfunc) (arg, from_tty & caution); - } - - /* Tell the user if the language has changed (except first time). */ ---- 926,932 ---- - else if (c->function.cfunc == NO_FUNCTION) - error ("That is not a command, just a help topic."); - else -! energize_call_command (c, arg, from_tty & caution); - } - - /* Tell the user if the language has changed (except first time). */ -*************** -*** 1317,1323 **** - #else - signal (STOP_SIGNAL, stop_sig); - #endif -! printf ("%s", prompt); - fflush (stdout); - - /* Forget about any previous command -- null line now will do nothing. */ ---- 1328,1334 ---- - #else - signal (STOP_SIGNAL, stop_sig); - #endif -! printf_filtered ("%s", prompt); - fflush (stdout); - - /* Forget about any previous command -- null line now will do nothing. */ -*************** -*** 1463,1469 **** - if (expanded) - { - /* Print the changes. */ -! printf ("%s\n", history_value); - - /* If there was an error, call this function again. */ - if (expanded < 0) ---- 1474,1480 ---- - if (expanded) - { - /* Print the changes. */ -! printf_filtered ("%s\n", history_value); - - /* If there was an error, call this function again. */ - if (expanded < 0) -*************** -*** 1570,1576 **** - while (1) - { - dont_repeat (); -! p = command_line_input ((char *) NULL, instream == stdin); - if (p == NULL) - /* Treat end of file like "end". */ - break; ---- 1581,1587 ---- - while (1) - { - dont_repeat (); -! p = energize_command_line_input ((char *) NULL, instream == stdin); - if (p == NULL) - /* Treat end of file like "end". */ - break; -*************** -*** 1661,1667 **** - char *arg; - int from_tty; - { -! printf ("\"info\" must be followed by the name of an info command.\n"); - help_list (infolist, "info ", -1, stdout); - } - ---- 1672,1678 ---- - char *arg; - int from_tty; - { -! printf_filtered ("\"info\" must be followed by the name of an info command.\n"); - help_list (infolist, "info ", -1, stdout); - } - -*************** -*** 1777,1783 **** - - if (from_tty) - { -! printf ("Type commands for definition of \"%s\".\n\ - End with a line saying just \"end\".\n", comname); - fflush (stdout); - } ---- 1788,1794 ---- - - if (from_tty) - { -! printf_filtered ("Type commands for definition of \"%s\".\n\ - End with a line saying just \"end\".\n", comname); - fflush (stdout); - } -*************** -*** 1810,1816 **** - error ("Command \"%s\" is built-in.", comname); - - if (from_tty) -! printf ("Type documentation for \"%s\".\n\ - End with a line saying just \"end\".\n", comname); - - doclines = read_command_lines (); ---- 1821,1827 ---- - error ("Command \"%s\" is built-in.", comname); - - if (from_tty) -! printf_filtered ("Type documentation for \"%s\".\n\ - End with a line saying just \"end\".\n", comname); - - doclines = read_command_lines (); -*************** -*** 1841,1847 **** - static void - print_gnu_advertisement() - { -! printf ("\ - GDB is free software and you are welcome to distribute copies of it\n\ - under certain conditions; type \"show copying\" to see the conditions.\n\ - There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\ ---- 1852,1858 ---- - static void - print_gnu_advertisement() - { -! printf_filtered ("\ - GDB is free software and you are welcome to distribute copies of it\n\ - under certain conditions; type \"show copying\" to see the conditions.\n\ - There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\ -*************** -*** 1874,1880 **** - void - print_prompt () - { -! printf ("%s", prompt); - fflush (stdout); - } - ---- 1885,1891 ---- - void - print_prompt () - { -! printf_filtered ("%s", prompt); - fflush (stdout); - } - -*************** -*** 1920,1929 **** - getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); - - if (strcmp (gdb_dirbuf, current_directory)) -! printf ("Working directory %s\n (canonically %s).\n", - current_directory, gdb_dirbuf); - else -! printf ("Working directory %s.\n", current_directory); - } - - static void ---- 1931,1940 ---- - getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); - - if (strcmp (gdb_dirbuf, current_directory)) -! printf_filtered ("Working directory %s\n (canonically %s).\n", - current_directory, gdb_dirbuf); - else -! printf_filtered ("Working directory %s.\n", current_directory); - } - - static void -*************** -*** 2160,2166 **** - char *args; - int from_tty; - { -! printf ("\"set history\" must be followed by the name of a history subcommand.\n"); - help_list (sethistlist, "set history ", -1, stdout); - } - ---- 2171,2177 ---- - char *args; - int from_tty; - { -! printf_filtered ("\"set history\" must be followed by the name of a history subcommand.\n"); - help_list (sethistlist, "set history ", -1, stdout); - } - -=================================================================== -*** 1.33 1992/09/29 05:07:19 ---- printcmd.c 1992/09/28 21:34:13 -*************** -*** 778,792 **** - { - int histindex = record_latest_value (val); - - if (inspect) -! printf ("\031(gdb-makebuffer \"%s\" %d '(\"", exp, histindex); - else - if (histindex >= 0) printf_filtered ("$%d = ", histindex); - - print_formatted (val, format, fmt.size); - printf_filtered ("\n"); - if (inspect) -! printf("\") )\030"); - } - - if (cleanup) ---- 778,802 ---- - { - int histindex = record_latest_value (val); - -+ if (energize) -+ { -+ char buf[20]; -+ -+ sprintf(buf, "$%d", histindex); -+ energize_start_variable_annotation(buf, NULL, VALUE_TYPE(val), -+ VALUE_ADDRESS(val), ""); -+ } -+ - if (inspect) -! printf_filtered ("\031(gdb-makebuffer \"%s\" %d '(\"", exp, histindex); - else - if (histindex >= 0) printf_filtered ("$%d = ", histindex); - - print_formatted (val, format, fmt.size); -+ energize_end_variable_annotation(); - printf_filtered ("\n"); - if (inspect) -! printf_filtered("\") )\030"); - } - - if (cleanup) -*************** -*** 890,896 **** - { - if (is_a_field_of_this) - { -! printf ("Symbol \"%s\" is a field of the local class variable `this'\n", exp); - return; - } - ---- 900,906 ---- - { - if (is_a_field_of_this) - { -! printf_filtered ("Symbol \"%s\" is a field of the local class variable `this'\n", exp); - return; - } - -*************** -*** 897,903 **** - msymbol = lookup_minimal_symbol (exp, (struct objfile *) NULL); - - if (msymbol != NULL) -! printf ("Symbol \"%s\" is at %s in a file compiled without debugging.\n", - exp, local_hex_string(msymbol -> address)); - else - error ("No symbol \"%s\" in current context.", exp); ---- 907,913 ---- - msymbol = lookup_minimal_symbol (exp, (struct objfile *) NULL); - - if (msymbol != NULL) -! printf_filtered ("Symbol \"%s\" is at %s in a file compiled without debugging.\n", - exp, local_hex_string(msymbol -> address)); - else - error ("No symbol \"%s\" in current context.", exp); -*************** -*** 904,910 **** - return; - } - -! printf ("Symbol \"%s\" is ", SYMBOL_NAME (sym)); - val = SYMBOL_VALUE (sym); - basereg = SYMBOL_BASEREG (sym); - ---- 914,920 ---- - return; - } - -! printf_filtered ("Symbol \"%s\" is ", SYMBOL_NAME (sym)); - val = SYMBOL_VALUE (sym); - basereg = SYMBOL_BASEREG (sym); - -*************** -*** 912,945 **** - { - case LOC_CONST: - case LOC_CONST_BYTES: -! printf ("constant"); - break; - - case LOC_LABEL: -! printf ("a label at address %s", local_hex_string(SYMBOL_VALUE_ADDRESS (sym))); - break; - - case LOC_REGISTER: -! printf ("a variable in register %s", reg_names[val]); - break; - - case LOC_STATIC: -! printf ("static storage at address %s", local_hex_string(SYMBOL_VALUE_ADDRESS (sym))); - break; - - case LOC_REGPARM: -! printf ("an argument in register %s", reg_names[val]); - break; - - case LOC_ARG: - if (SYMBOL_BASEREG_VALID (sym)) - { -! printf ("an argument at offset %ld from register %s", - val, reg_names[basereg]); - } - else - { -! printf ("an argument at offset %ld", val); - } - break; - ---- 922,955 ---- - { - case LOC_CONST: - case LOC_CONST_BYTES: -! printf_filtered ("constant"); - break; - - case LOC_LABEL: -! printf_filtered ("a label at address %s", local_hex_string(SYMBOL_VALUE_ADDRESS (sym))); - break; - - case LOC_REGISTER: -! printf_filtered ("a variable in register %s", reg_names[val]); - break; - - case LOC_STATIC: -! printf_filtered ("static storage at address %s", local_hex_string(SYMBOL_VALUE_ADDRESS (sym))); - break; - - case LOC_REGPARM: -! printf_filtered ("an argument in register %s", reg_names[val]); - break; - - case LOC_ARG: - if (SYMBOL_BASEREG_VALID (sym)) - { -! printf_filtered ("an argument at offset %ld from register %s", - val, reg_names[basereg]); - } - else - { -! printf_filtered ("an argument at offset %ld", val); - } - break; - -*************** -*** 946,957 **** - case LOC_LOCAL_ARG: - if (SYMBOL_BASEREG_VALID (sym)) - { -! printf ("an argument at offset %ld from register %s", - val, reg_names[basereg]); - } - else - { -! printf ("an argument at frame offset %ld", val); - } - break; - ---- 956,967 ---- - case LOC_LOCAL_ARG: - if (SYMBOL_BASEREG_VALID (sym)) - { -! printf_filtered ("an argument at offset %ld from register %s", - val, reg_names[basereg]); - } - else - { -! printf_filtered ("an argument at frame offset %ld", val); - } - break; - -*************** -*** 958,990 **** - case LOC_LOCAL: - if (SYMBOL_BASEREG_VALID (sym)) - { -! printf ("a local variable at offset %ld from register %s", - val, reg_names[basereg]); - } - else - { -! printf ("a local variable at frame offset %ld", val); - } - break; - - case LOC_REF_ARG: -! printf ("a reference argument at offset %ld", val); - break; - - case LOC_TYPEDEF: -! printf ("a typedef"); - break; - - case LOC_BLOCK: -! printf ("a function at address %s", - local_hex_string(BLOCK_START (SYMBOL_BLOCK_VALUE (sym)))); - break; - - default: -! printf ("of unknown (botched) type"); - break; - } -! printf (".\n"); - } - - static void ---- 968,1000 ---- - case LOC_LOCAL: - if (SYMBOL_BASEREG_VALID (sym)) - { -! printf_filtered ("a local variable at offset %ld from register %s", - val, reg_names[basereg]); - } - else - { -! printf_filtered ("a local variable at frame offset %ld", val); - } - break; - - case LOC_REF_ARG: -! printf_filtered ("a reference argument at offset %ld", val); - break; - - case LOC_TYPEDEF: -! printf_filtered ("a typedef"); - break; - - case LOC_BLOCK: -! printf_filtered ("a function at address %s", - local_hex_string(BLOCK_START (SYMBOL_BLOCK_VALUE (sym)))); - break; - - default: -! printf_filtered ("of unknown (botched) type"); - break; - } -! printf_filtered (".\n"); - } - - static void -*************** -*** 1419,1425 **** - d->status = disabled; - return; - } -! printf ("No display number %d.\n", num); - } - - void ---- 1429,1435 ---- - d->status = disabled; - return; - } -! printf_filtered ("No display number %d.\n", num); - } - - void -*************** -*** 1428,1434 **** - if (current_display_number >= 0) - { - disable_display (current_display_number); -! fprintf (stderr, "Disabling display %d to avoid infinite recursion.\n", - current_display_number); - } - current_display_number = -1; ---- 1438,1444 ---- - if (current_display_number >= 0) - { - disable_display (current_display_number); -! fprintf_filtered (stderr, "Disabling display %d to avoid infinite recursion.\n", - current_display_number); - } - current_display_number = -1; -*************** -*** 1442,1448 **** - register struct display *d; - - if (!display_chain) -! printf ("There are no auto-display expressions now.\n"); - else - printf_filtered ("Auto-display expressions now in effect:\n\ - Num Enb Expression\n"); ---- 1452,1458 ---- - register struct display *d; - - if (!display_chain) -! printf_filtered ("There are no auto-display expressions now.\n"); - else - printf_filtered ("Auto-display expressions now in effect:\n\ - Num Enb Expression\n"); -*************** -*** 1495,1501 **** - d->status = enabled; - goto win; - } -! printf ("No display number %d.\n", num); - win: - p = p1; - while (*p == ' ' || *p == '\t') ---- 1505,1511 ---- - d->status = enabled; - goto win; - } -! printf_filtered ("No display number %d.\n", num); - win: - p = p1; - while (*p == ' ' || *p == '\t') -*************** -*** 1652,1662 **** ---- 1662,1680 ---- - standard indentation here is 4 spaces, and val_print indents - 2 for each recurse. */ - val = read_var_value (sym, FRAME_INFO_ID (fi)); -+ -+ energize_start_variable_annotation(SYMBOL_NAME(sym), sym, -+ VALUE_TYPE(val), -+ VALUE_ADDRESS(val), ""); -+ - if (val) - val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), VALUE_ADDRESS (val), - stream, 0, 0, 2, Val_no_prettyprint); - else - fputs_filtered ("???", stream); -+ -+ energize_end_variable_annotation(); -+ - first = 0; - } - -=================================================================== -*** 1.35 1992/09/18 09:20:00 ---- stack.c 1992/09/28 21:34:14 -*************** -*** 159,165 **** - if (addressprint) - printf_filtered ("%s in ", local_hex_string(fi->pc)); - -! fputs_demangled (fname, stdout, 0); - fputs_filtered (" (...)\n", stdout); - - return; ---- 159,168 ---- - if (addressprint) - printf_filtered ("%s in ", local_hex_string(fi->pc)); - -! if (energize) -! energize_annotate_function(fname, 0, level); -! else -! fputs_demangled (fname, stdout, 0); - fputs_filtered (" (...)\n", stdout); - - return; -*************** -*** 218,224 **** - if (addressprint) - if (fi->pc != sal.pc || !sal.symtab) - printf_filtered ("%s in ", local_hex_string(fi->pc)); -! fputs_demangled (funname ? funname : "??", stdout, 0); - wrap_here (" "); - fputs_filtered (" (", stdout); - if (args) ---- 221,230 ---- - if (addressprint) - if (fi->pc != sal.pc || !sal.symtab) - printf_filtered ("%s in ", local_hex_string(fi->pc)); -! if (energize) -! energize_annotate_function(funname ? funname : "??", 0, level); -! else -! fputs_demangled (funname ? funname : "??", stdout, 0); - wrap_here (" "); - fputs_filtered (" (", stdout); - if (args) -*************** -*** 255,261 **** - { - if (addressprint && mid_statement) - printf_filtered ("%s\t", local_hex_string(fi->pc)); -! print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); - } - current_source_line = max (sal.line - lines_to_list/2, 1); - } ---- 261,268 ---- - { - if (addressprint && mid_statement) - printf_filtered ("%s\t", local_hex_string(fi->pc)); -! if (!energize) -! print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); - } - current_source_line = max (sal.line - lines_to_list/2, 1); - } -*************** -*** 429,435 **** - if (funname) - { - printf_filtered (" in "); -! fputs_demangled (funname, stdout, DMGL_ANSI | DMGL_PARAMS); - } - wrap_here (" "); - if (sal.symtab) ---- 436,446 ---- - if (funname) - { - printf_filtered (" in "); -! if (energize) -! energize_annotate_function(funname, DMGL_ANSI | DMGL_PARAMS, -! selected_frame_level); -! else -! fputs_demangled (funname, stdout, DMGL_ANSI | DMGL_PARAMS); - } - wrap_here (" "); - if (sal.symtab) -=================================================================== -*** 1.59 1992/09/29 05:07:26 ---- symfile.c 1992/09/28 21:34:14 -*************** -*** 614,619 **** ---- 614,621 ---- - fflush (stdout); - } - -+ energize_symbol_file(objfile); -+ - return (objfile); - } - -*************** -*** 646,652 **** - current_source_line = 0; - if (from_tty) - { -! printf ("No symbol file now.\n"); - } - } - else ---- 648,654 ---- - current_source_line = 0; - if (from_tty) - { -! printf_filtered ("No symbol file now.\n"); - } - } - else -*************** -*** 1164,1170 **** - return; - clear_symtab_users_done = clear_symtab_users_queued; - -! printf ("Resetting debugger state after updating old symbol tables\n"); - - /* Someday, we should do better than this, by only blowing away - the things that really need to be blown. */ ---- 1166,1172 ---- - return; - clear_symtab_users_done = clear_symtab_users_queued; - -! printf_filtered ("Resetting debugger state after updating old symbol tables\n"); - - /* Someday, we should do better than this, by only blowing away - the things that really need to be blown. */ -=================================================================== -*** 1.63 1992/09/26 05:34:06 ---- utils.c 1992/09/28 21:34:15 -*************** -*** 700,720 **** - fflush (stdout); - va_start (args); - ctlstr = va_arg (args, char *); - vfprintf_filtered (stdout, ctlstr, args); -- va_end (args); - printf_filtered ("(y or n) "); -! fflush (stdout); -! answer = fgetc (stdin); -! clearerr (stdin); /* in case of C-d */ -! if (answer == EOF) /* C-d */ -! return 1; -! if (answer != '\n') /* Eat rest of input line, to EOF or newline */ -! do -! { -! ans2 = fgetc (stdin); -! clearerr (stdin); -! } -! while (ans2 != EOF && ans2 != '\n'); - if (answer >= 'a') - answer -= 040; - if (answer == 'Y') ---- 700,731 ---- - fflush (stdout); - va_start (args); - ctlstr = va_arg (args, char *); -+ energize_query (ctlstr, args); - vfprintf_filtered (stdout, ctlstr, args); - printf_filtered ("(y or n) "); -! if (energize) -! { -! char *buf; -! -! buf = energize_command_line_input(0, 0); -! answer = buf ? *buf : 'Y'; -! energize_acknowledge_query(buf); -! } -! else -! { -! fflush (stdout); -! answer = fgetc (stdin); -! clearerr (stdin); /* in case of C-d */ -! if (answer == EOF) /* C-d */ -! return 1; -! if (answer != '\n') /* Eat rest of input line, to EOF or newline */ -! do -! { -! ans2 = fgetc (stdin); -! clearerr (stdin); -! } -! while (ans2 != EOF && ans2 != '\n'); -! } - if (answer >= 'a') - answer -= 040; - if (answer == 'Y') -*************** -*** 722,727 **** ---- 733,739 ---- - if (answer == 'N') - return 0; - printf_filtered ("Please answer y or n.\n"); -+ va_end (args); - } - } - -*************** -*** 1000,1005 **** ---- 1012,1023 ---- - if (linebuffer == 0) - return; - -+ if (energize) -+ { -+ energize_fputs(linebuffer); -+ return; -+ } -+ - /* Don't do any filtering if it is disabled. */ - if (stream != stdout - || (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX)) -=================================================================== -*** 1.55 1992/09/29 05:07:34 ---- valprint.c 1992/09/28 21:34:15 -*************** -*** 384,390 **** - VALUE_CONTENTS (val) + typelen * i, - VALUE_ADDRESS (val) + typelen * i, - stream, format, 1, 0, pretty); -! fprintf (stream, " <repeats %u times>", reps); - i = rep1 - 1; - things_printed += REPEAT_COUNT_THRESHOLD; - } ---- 384,390 ---- - VALUE_CONTENTS (val) + typelen * i, - VALUE_ADDRESS (val) + typelen * i, - stream, format, 1, 0, pretty); -! fprintf_filtered (stream, " <repeats %u times>", reps); - i = rep1 - 1; - things_printed += REPEAT_COUNT_THRESHOLD; - } -*************** -*** 488,493 **** ---- 488,494 ---- - struct type **dont_print; - { - int i, len, n_baseclasses; -+ char expr_tag[100]; /* Energize */ - - check_stub_type (type); - -*************** -*** 552,557 **** ---- 553,565 ---- - fprint_symbol (stream, TYPE_FIELD_NAME (type, i)); - fputs_filtered (" = ", stream); - } -+ -+ sprintf(expr_tag, ".%s", TYPE_FIELD_NAME(type, i)); -+ -+ energize_start_variable_annotation(expr_tag, NULL, -+ TYPE_FIELD_TYPE(type, i), -+ (CORE_ADDR) (valaddr + TYPE_FIELD_BITPOS(type, i) / 8), -+ ""); - if (TYPE_FIELD_PACKED (type, i)) - { - value v; -*************** -*** 570,575 **** ---- 578,584 ---- - valaddr + TYPE_FIELD_BITPOS (type, i) / 8, - 0, stream, format, 0, recurse + 1, pretty); - } -+ energize_end_variable_annotation(); - } - if (pretty) - { -*************** -*** 804,809 **** ---- 813,819 ---- - unsigned int rep1; - /* Number of repetitions we have detected so far. */ - unsigned int reps; -+ char expr_tag[100]; /* Energize */ - - if (i != 0) - if (arrayprint) -*************** -*** 825,830 **** ---- 835,845 ---- - ++rep1; - } - -+ sprintf(expr_tag, "[%d]", i); -+ energize_start_variable_annotation(expr_tag, NULL, -+ elttype, -+ (CORE_ADDR) (valaddr + i * eltlen), -+ ""); - if (reps > REPEAT_COUNT_THRESHOLD) - { - val_print (elttype, valaddr + i * eltlen, -*************** -Sun Oct 24 23:48:55 1993*** 841,846 **** ---- 856,862 ---- - recurse + 1, pretty); - things_printed++; - } -+ energize_end_variable_annotation(); - } - if (i < len) - fprintf_filtered (stream, "..."); -*************** -*** 910,916 **** - { - fprintf_filtered (stream, "&"); - type_print_varspec_prefix (TYPE_FN_FIELD_TYPE (f, j), stream, 0, 0); -! fprintf (stream, kind); - if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_' - && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER) - type_print_method_args ---- 926,932 ---- - { - fprintf_filtered (stream, "&"); - type_print_varspec_prefix (TYPE_FN_FIELD_TYPE (f, j), stream, 0, 0); -! fprintf_filtered (stream, kind); - if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_' - && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER) - type_print_method_args -*************** -*** 1528,1534 **** - - case TYPE_CODE_METHOD: - if (passed_a_ptr) -! fprintf (stream, "("); - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, - 0); - if (passed_a_ptr) ---- 1544,1550 ---- - - case TYPE_CODE_METHOD: - if (passed_a_ptr) -! fprintf_filtered (stream, "("); - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, - 0); - if (passed_a_ptr) -*************** -*** 1907,1913 **** - if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0) - { - /* Keep GDB from crashing here. */ -! fprintf (stream, "<undefined type> %s;\n", - TYPE_FN_FIELD_PHYSNAME (f, j)); - break; - } ---- 1923,1929 ---- - if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0) - { - /* Keep GDB from crashing here. */ -! fprintf_filtered (stream, "<undefined type> %s;\n", - TYPE_FN_FIELD_PHYSNAME (f, j)); - break; - } -*************** -*** 2098,2104 **** - char *arg; - int from_tty; - { -! printf ( - "\"set print\" must be followed by the name of a print subcommand.\n"); - help_list (setprintlist, "set print ", -1, stdout); - } ---- 2114,2120 ---- - char *arg; - int from_tty; - { -! printf_filtered ( - "\"set print\" must be followed by the name of a print subcommand.\n"); - help_list (setprintlist, "set print ", -1, stdout); - } -=================================================================== -*** 1.5 1992/09/26 08:07:45 ---- amix.mh 1992/09/28 21:34:15 -*************** -*** 22,24 **** ---- 22,38 ---- - - # SVR4 puts the BSD compatible install in /usr/ucb. - INSTALL = /usr/ucb/install -c -+ -+ # These are the libs that are needed for the Energize version of gdb on -+ # SVR4. Note that we MUST include the standard C library before libucb.a, -+ # otherwise we get lots of broken stuff we don't want. -+ ENERGIZE_LIB = energize/libconn.a -+ ENERGIZE_LIBS = ${ENERGIZE_LIB} -L/usr/lib -lm -lnet -lresolv -lform \ -+ -lsocket -lc /usr/ucblib/libucb.a -lnsl -+ -+ # These are the libs that are needed for the Energize version of gdb on -+ # SVR4. Note that we MUST include the standard C library before libucb.a, -+ # otherwise we get lots of broken stuff we don't want. -+ ENERGIZE_LIB = energize/libconn.a -+ ENERGIZE_LIBS = ${ENERGIZE_LIB} -L/usr/lib -lm -lnet -lresolv -lform \ -+ -lsocket -lc /usr/ucblib/libucb.a -lnsl -=================================================================== -*** 1.5 1992/09/26 08:08:14 ---- ncr3000.mh 1992/09/28 21:34:16 -*************** -*** 38,40 **** ---- 38,59 ---- - # The /usr/ucb/install program is incompatible (complains about unknown - # group staff). Use good old cp... - INSTALL = cp -+ -+ # These are the libs that are needed for the Energize version of gdb on -+ # SVR4. Note that we MUST include the standard C library before libucb.a, -+ # otherwise we get lots of broken stuff we don't want. -+ XM_CLIBS = -L/usr/lib -lm -lnet -lresolv -lform -lsocket -lnsl -lc -+ -+ # These are the libs that are needed for the Energize version of gdb on -+ # SVR4. Note that we MUST include the standard C library before libucb.a, -+ # otherwise we get lots of broken stuff we don't want. -+ ENERGIZE_LIB = energize/libconn.a -+ ENERGIZE_LIBS = ${ENERGIZE_LIB} -L/usr/lib -lm -lnet -lresolv -lform \ -+ -lsocket -lc /usr/ucblib/libucb.a -lnsl -+ -+ # These are the libs that are needed for the Energize version of gdb on -+ # SVR4. Note that we MUST include the standard C library before libucb.a, -+ # otherwise we get lots of broken stuff we don't want. -+ ENERGIZE_LIB = energize/libconn.a -+ ENERGIZE_LIBS = ${ENERGIZE_LIB} -L/usr/lib -lm -lnet -lresolv -lform \ -+ -lsocket -lc /usr/ucblib/libucb.a -lnsl diff --git a/gdb/energize.c b/gdb/energize.c index 88b442e..e69de29 100644 --- a/gdb/energize.c +++ b/gdb/energize.c @@ -1,1716 +0,0 @@ -/* Energize (formerly known as Cadillac) interface routines. - Copyright 1991, 1992 Free Software Foundation, Inc. - -This file is part of GDB. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "symtab.h" -#include "inferior.h" -#include "command.h" -#include "bfd.h" -#include "symfile.h" -#include "objfiles.h" -#include "target.h" -#include <sys/types.h> -#include <sys/time.h> -#include <sys/param.h> -#include "energize/connection.h" -#include "energize/genericreq.h" -#include "energize/debuggerreq.h" -#include "energize/debuggerconn.h" -#include "energize/ttyconn.h" -#include <varargs.h> -#include <sys/stat.h> -#ifdef USG -#include <sys/file.h> -#endif -#include <fcntl.h> -#include <sys/filio.h> -#include <setjmp.h> -#include <signal.h> -#include <sys/errno.h> -#include <termios.h> -#include <string.h> -#ifdef NCR486 -#include <sys/stropts.h> -#endif - -/* Non-zero means that we're doing the energize interface. */ -int energize = 0; - -/* Non-zero means we are reloading breakpoints, etc from the - Energize kernel, and we should suppress various messages */ -static int energize_reloading = 0; - -/* Connection block for debugger<=>kernel communications. */ -static Connection *conn = 0; - -/* fd for our socket to the kernel. */ -static int kerfd; - -/* The kernel's ID for this instance of the program. */ -static int program_id; - -static int instance_id; - -/* The fd for the pty associated with the inferior. */ -static int inferior_pty = -1; -static int inferior_tty = -1; - -static int has_run = 0; - -extern int pgrp_inferior; - -extern char *source_path; - -/* The name of the executable file */ -static char *exec_file; - -/* Tell energize_command_line_input() where to get its text from */ -static int doing_breakcommands_message = 0; - -/* Stash command text here */ -static char *command_line_text = 0; -static int command_line_length = 0; - -/* Flags returned by wait_for_events() */ -#define KERNEL_EVENT 1 -#define PTY_EVENT 2 - -static void execute_command_1(); - - -/* This routine redirects the output of fputs_filtered to the kernel so that - the user can see what's going on in his debugger window. */ - -void -energize_fputs(ptr) - const char *ptr; -{ - if (conn) - CVWriteTranscriptInfo (conn, instance_id, (char *)ptr); - else - fputs (ptr, stdout); -} - -void -energize_query(query, args) - char *query; - va_list args; -{ - char buf[100]; - - if (!energize) - return; - - vsprintf(buf, query, args); - - CVWriteQueryInfo(conn, - instance_id, - CQueryConfirm, - qno_unknown, - buf, - ""); /* transcript */ -} - -void -energize_acknowledge_query(ack) - char *ack; -{ - CVWriteQueryInfo(conn, - instance_id, - CQueryAcknowleged, - 0, - ack, - ""); /* transcript */ -} - -/* Copy all data from the pty to the kernel. */ - -static void -pty_to_kernel() -{ - CTtyRequest *req; - char buf[1024]; - int cc; - - while (1) - { - cc = read(inferior_pty, buf, sizeof(buf)); - - if (cc == 0 - || (cc < 0 - && (errno == EWOULDBLOCK - || errno == EAGAIN))) - break; - - if (cc < 0) - { - close(inferior_pty); - inferior_pty = -1; - perror("pty_to_kernel: pty read error"); - break; - } - - req = CWriteTtyRequest(conn, TextIORType); - CWriteVstringLen(conn, buf, cc); - CWriteLength(conn); - } - CWriteRequestBuffer(conn); -} - -/* Copy data from the kernel to the pty. */ - -static void -kernel_to_pty(data, len) - char *data; - int len; -{ - int cc; - - cc = write(inferior_pty, data, len); - - if (cc != len) - { - if (cc < 0) - { - close(inferior_pty); - inferior_pty = -1; - perror("kernel_to_pty: pty write error"); - return; - } - printf("Couldn't write all the data to the pty, wanted %d, got %d\n", - len, cc); - } -} - -static char * -full_filename(symtab) - struct symtab *symtab; -{ - int pathlen; - char *filename; - - if (!symtab) - return NULL; - - if (symtab->fullname) - return savestring(symtab->fullname, strlen(symtab->fullname)); - - if (symtab->filename[0] == '/') - return savestring(symtab->filename, strlen(symtab->filename)); - - if (symtab->dirname) - pathlen = strlen(symtab->dirname); - else - pathlen = 0; - if (symtab->filename) - pathlen += strlen(symtab->filename); - - filename = xmalloc(pathlen+1); - - if (symtab->dirname) - strcpy(filename, symtab->dirname); - else - *filename = '\000'; - if (symtab->filename) - strcat(filename, symtab->filename); - - return filename; -} - -/* Tell the energize kernel how high the stack is so that frame numbers (which - are relative to the current stack height make sense. - - Calculate the number of frames on the stack, and the number of subroutine - invocations that haven't changed since the last call to this routine. The - second number is calculated by comparing the PCs of the current stack frames - to the PCs of the previous set of stack frames. The screw here is that a - subroutine may call several different procedures, which means that the PC - in its frame changes, even though you are still in the same subroutine. We - resolve this by converting the frames PC into the PC at the start of the - function (for efficiency, this is done only if the simple comparison test - fails). */ - -struct pclist -{ - CORE_ADDR pc; - struct pclist *next; -}; - -/* Non-zero means that Energize kernel already knows how high the stack is. */ -static int stack_info_valid = 0; - -static void -send_stack_info() -{ - struct pclist *pclist = 0, *pli, *opli; - static struct pclist *old_pclist; - struct frame_info *frame; - int height, similar; - - if (stack_info_valid) - return; - - height = 0; - similar = 0; - -/* First, calculate the stack height, and build the new pclist */ - - for (frame = get_current_frame(); - frame != 0; - frame = get_prev_frame(frame)) - { - (height)++; - pli = (struct pclist *)xmalloc(sizeof(struct pclist)); - - pli->pc = frame->pc; - pli->next = pclist; - pclist = pli; - } - -/* Now, figure out how much of the stack hasn't changed */ - - for (pli = pclist, opli = old_pclist; - pli != 0 && opli != 0; - pli = pli->next, opli = opli->next, (similar)++) - { - if ((pli->pc != opli->pc) - && (get_pc_function_start(pli->pc) - != get_pc_function_start(opli->pc))) - break; - } - -/* Free up all elements of the old pclist */ - - opli = old_pclist; - - while (opli) - { - pli = opli->next; - free (opli); - opli = pli; - } - - old_pclist = pclist; /* Install the new pclist */ - - CVWriteStackSizeInfo(conn, - instance_id, - height, /* Frame depth */ - CInnerFrameIs0, - similar, /* Frame diff */ - "" /* Transcript */ - ); - - stack_info_valid = 1; -} - -/* Tell the Energize server about the file and line # that corresponds to pc, - and which stack frame level that pc corresponds to. */ - -static void -send_location(pc, frame_level) - CORE_ADDR pc; - int frame_level; -{ - char *funcname, *filename; - struct symtab_and_line sal; - struct symbol *symbol; - - sal = find_pc_line(pc, 0); - symbol = find_pc_function(pc); - - funcname = symbol ? symbol->name : ""; - filename = full_filename(sal.symtab); - - send_stack_info(); - - CVWriteStackFrameInfo(conn, - instance_id, - sal.line, - CFileLinePos, - frame_level, - funcname, - filename, - "" /* XXX ? transcript */ - ); - if (filename) - free(filename); -} - -/* Tell the kernel where we are in the program, and what the stack looks like. - */ - -static void -send_status() -{ - char *funcname; - struct symbol *symbol; - static int sent_prog_inst = 0; - - symbol = find_pc_function(stop_pc); - funcname = symbol ? symbol->name : ""; - - if (!has_run) - return; - - if (inferior_pid == 0) /* target has died */ - { - CVWriteProgramTerminatedInfo(conn, - instance_id, - "" - ); - return; - } - - if (!sent_prog_inst) - { - sent_prog_inst = 1; - CVWriteProgramInstanceInfo(conn, - program_id, - instance_id, - "", /* hostname */ - "", /* arglist */ - "" - ); - } - - send_location(stop_pc, - selected_frame_level); /* Had better be 0! */ - - CVWriteProgramStoppedInfo(conn, - instance_id, - 0, /* XXX - breakpoint # or signal # */ - CDebuggerCommand, - funcname, - "" /* XXX ? transcript */ - ); - -} - -/* Call this to output annotated function names. Names will be demangled if - necessary. arg_mode contains flags that are passed on to cplus_demangle. */ - -void -energize_annotate_function(funcname, arg_mode, level) - char *funcname; - int arg_mode; - int level; -{ - char *demangled_name = NULL; - - if (funcname == NULL) - return; - - if (demangle) - { - demangled_name = cplus_demangle(funcname, arg_mode); - - if (demangled_name) - { - funcname = demangled_name; - printf_filtered("'"); - } - } - - send_stack_info(); - - if (level < 0) level = 0; - - CVWriteBackTraceEntryInfo(conn, - instance_id, - level, /* frameNo */ - funcname); - - if (demangled_name) - { - free(demangled_name); - printf_filtered("'"); - } -} - -/* Call this just prior to printing out the name & value of a variable. This - tells the kernel where to annotate the output. */ - -/* The args are: - expression - A text handle on what GDB can use to reference this value. - This can be a symbol name, or a convenience var, etc... - symbol - Used to determine the scope of the data. May be NULL. - type - Determines if we have a pointer ref, and the print name of the type. - Used in ShowValue message. - valaddr - The address in target memory of the data. - field - The field name of the struct or union element being referenced. -*/ - -static char cum_expr[200]; /* Cumulative expression */ -static char *expr_stack[100] = {cum_expr}; /* Pointers to end of expressions */ -static char **last_expr = expr_stack; /* Current expr stack pointer */ - -void -energize_start_variable_annotation(expression, symbol, type, valaddr, field) - char *expression; - struct symbol *symbol; - struct type *type; - CORE_ADDR valaddr; - char *field; -{ - int ref_type; - int stor_cl; - enum type_code type_code; - enum address_class sym_class; - char *type_cast; - - if (!energize) - return; - - send_stack_info(); - - strcpy(*last_expr++, expression); - *last_expr = *(last_expr-1) + strlen(expression); - - switch (TYPE_CODE(type)) - { - case TYPE_CODE_ARRAY: - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - case TYPE_CODE_ENUM: - case TYPE_CODE_INT: - case TYPE_CODE_FLT: - ref_type = CValueValueRef; - break; - case TYPE_CODE_PTR: - ref_type = CValuePointerRef; - break; - default: - ref_type = CValueUndefRef; - break; - } - -/* Make sure that pointer points at something we understand */ - - if (ref_type == CValuePointerRef) - switch (TYPE_CODE(TYPE_TARGET_TYPE(type))) - { - case TYPE_CODE_PTR: - case TYPE_CODE_ARRAY: - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - case TYPE_CODE_ENUM: - case TYPE_CODE_INT: - case TYPE_CODE_FLT: - break; - default: - ref_type = CValueUndefRef; - break; - } - - if (symbol) - { - sym_class = SYMBOL_CLASS(symbol); - - switch (sym_class) - { - case LOC_CONST: - case LOC_CONST_BYTES: - stor_cl = CValueStorStaticConst; - break; - case LOC_STATIC: - stor_cl = CValueStorStaticVar; - break; - case LOC_REGISTER: - case LOC_REGPARM: - stor_cl = CValueStorRegister; - break; - case LOC_ARG: - case LOC_REF_ARG: - case LOC_LOCAL: - case LOC_LOCAL_ARG: - stor_cl = CValueStorLocalVar; - break; - default: - stor_cl = CValueStorUndef; - break; - } - } - else - stor_cl = CValueStorUndef; - - type_cast = TYPE_NAME(type); - - CVWriteValueBeginInfo(conn, - instance_id, - valaddr, - ref_type, - stor_cl, - 0, /* XXX - frameno */ - cum_expr, - field, - type_cast, - ""); /* transcript */ -} - -void -energize_end_variable_annotation() -{ - if (!energize) - return; - - last_expr--; /* Pop the expr stack */ - **last_expr = '\000'; /* Cut off the last part of the expr */ - - CVWriteValueEndInfo(conn, - instance_id, - ""); /* transcript */ -} - -/* Tell the kernel that the target is now running. */ - -static void -go_busy() -{ - CVWriteProgramBusyInfo(conn, - instance_id, - ""); /* XXX ? transcript */ - CWriteRequestBuffer(conn); /* Must take place synchronusly! */ - stack_info_valid = 0; -} - - -void -energize_symbol_file(objfile) - struct objfile *objfile; -{ - if (!energize) - return; - - CVWriteSymbolTableInfo(conn, - objfile->name, - ""); /* Transcript */ -} - -/* execute_command_1(echo, queue, cmd, args) - echo - non-zero means echo the - command. queue - non-zero means don't execute it now, just save it away for - later. cmd - string containing printf control sequences. args - list of - arguments needed by those control sequences. - */ - -/* Linked list of queued up commands */ -static struct command_line *queued_commands = 0; -static struct command_line *last_queued_command = 0; - -/* Call this routine to save a command for later. The command string is - copied into freshly malloc'ed memory. */ - -static void -queue_command(cmd) - char *cmd; -{ - char *buf; - struct command_line *cl; - unsigned long s; - - s = (strlen(cmd) + 1) + 7 & ~(unsigned long)7; - - buf = (char *)xmalloc(s + sizeof(struct command_line)); - cl = (struct command_line *)(buf + s); - cl->next = 0; - cl->line = buf; - - strncpy(cl->line, cmd, s); - - if (queued_commands) - last_queued_command->next = cl; - else - queued_commands = cl; - - last_queued_command = cl; -} - -/* Call this procedure to take a command off of the command queue. It returns - a pointer to a buf which the caller is responsible for freeing. NULL is - returned if there are no commands queued. */ - -static char * -dequeue_command() -{ - struct command_line *cl; - char *cmd; - - cl = queued_commands; - - if (!cl) - return NULL; - - queued_commands = cl->next; - - return cl->line; -} - -static void -execute_command_1(va_alist) - va_dcl -{ - char buf[100]; /* XXX - make buf dynamic! */ - - int echo; - int queue; - char *cmd; - va_list args; - - va_start(args); - echo = va_arg(args, int); - - queue = va_arg(args, int); - cmd = va_arg(args, char *); - - vsprintf(buf, cmd, args); - - if (queue) - queue_command(buf); - else - { - if (echo) - printf_filtered("%s\n", buf); - execute_command(buf, 1); - } - - va_end(args); -} - -#ifdef KERNEL_RECORD -GDB_FILE *kerout; - -static int -kernel_record(fd, ptr, num) - int fd, num; - char *ptr; - -{ - fwrite(ptr, num, 1, kerout); - fflush(kerout); - return write(fd, ptr, num); -} -#endif - -void -energize_condition_breakpoint(b) - struct breakpoint *b; -{ - if (energize) - CVWriteBreakConditionInfo(conn, - instance_id, - b->number, - b->cond_string ? b->cond_string : "", - "" /* transcript */ - ); -} - -void -energize_commands_breakpoint(b) - struct breakpoint *b; -{ - struct command_line *l; - - if (!energize) - return; - - CVWriteBreakCommandBegInfo(conn, - instance_id, - b->number, - ""); /* transcript */ - - for (l = b->commands; l; l = l->next) - CVWriteBreakCommandEntryInfo(conn, - instance_id, - l->line, - ""); /* transcript */ - - CVWriteBreakCommandEndInfo(conn, - instance_id, - ""); /* transcript */ -} - -static void -breakpoint_notify(b, action) - struct breakpoint *b; - int action; -{ - struct symbol *sym; - char *funcname = ""; - char *filename; - char *included_in_filename = ""; - - if (!energize - || energize_reloading) /* Don't notify energize about breakpoint changes, as it's about to send us - a new bunch. */ - return; - - if (b->type != bp_breakpoint) - return; - - filename = full_filename(b->symtab); - - sym = find_pc_function(b->address); - if (sym) - funcname = SYMBOL_NAME(sym); - - CVWriteBreakpointInfo (conn, - instance_id, - b->number, - b->line_number, - CFileLinePos, - CBreakOnInstrAccess, - action, - b->ignore_count, - funcname, - filename ? filename : "", - "", /* included_in_filename */ - "" /* transcript */ - ); - - if (b->commands) - energize_commands_breakpoint(b); - - energize_condition_breakpoint(b); - - if (filename) - free(filename); -} - -void -energize_create_breakpoint(b) - struct breakpoint *b; -{ - breakpoint_notify(b, CEnableBreakpoint); -} - -void -energize_delete_breakpoint(b) - struct breakpoint *b; -{ - breakpoint_notify(b, CDeleteBreakpoint); -} - -void -energize_enable_breakpoint(b) - struct breakpoint *b; -{ - breakpoint_notify(b, CEnableBreakpoint); -} - -void -energize_disable_breakpoint(b) - struct breakpoint *b; -{ - breakpoint_notify(b, CDisableBreakpoint); -} - -void -energize_ignore_breakpoint(b) - struct breakpoint *b; -{ - breakpoint_notify(b, CBreakAttrUnchanged); -} - -/* Open up a pty and its associated tty. Return the fd of the tty. */ - -#ifndef NCR486 -static void -getpty() -{ - int n, ptyfd, ttyfd; - static char dev[30]; - struct stat statbuf; - struct termios termios; - -#define HIGHPTY (('z' - 'p') * 16 - 1) - - for (n = 0; n <= HIGHPTY; n++) - { - sprintf(dev, "/dev/pty%c%x", n/16 + 'p', n%16); - if (stat(dev, &statbuf)) - break; - ptyfd = open(dev, O_RDWR); - if (ptyfd < 0) - continue; - sprintf(dev, "/dev/tty%c%x", n/16 + 'p', n%16); - ttyfd = open(dev, O_RDWR); - if (ttyfd < 0) - { - close(ptyfd); - continue; - } - - /* Setup pty for non-blocking I/O. Also make it give us a SIGIO when - there's data available. */ - - n = fcntl(ptyfd, F_GETFL, 0); - fcntl(ptyfd, F_SETFL, n|FNDELAY|FASYNC); - fcntl(ptyfd, F_SETOWN, getpid()); - - tcgetattr(ttyfd, &termios); - termios.c_oflag &= ~OPOST; /* No post-processing */ - tcsetattr(ttyfd, TCSANOW, &termios); - - inferior_pty = ptyfd; - inferior_tty = ttyfd; - return; - } - - error ("getpty: can't get a pty\n"); -} -#endif -/* Alternate getpty for NCRs */ - -#ifdef NCR486 /* LTL */ -#define MAX_PTM_TRY 16 -#define MAX_GRANTPT_TRY 4 -static void -getpty() -{ - char *slavename; - extern char *ptsname(); - int j, i; - int n, mfd, sfd; - struct stat statbuf; - struct termios termios; - - mfd = open("/dev/ptmx", O_RDWR); /* get the master */ - if (mfd < 0) - error ("getpty: can't locate master\n"); - - if (grantpt(mfd) < 0) /* get a slave */ - error ("getpty: can't acquire slave"); - - unlockpt(mfd); - - slavename = ptsname(mfd); /* get the slave device name */ - if (!slavename) - error ("getpty: can't get a pts\n"); - - /* Drop controlling tty, become pgrp master */ - - if (setpgid(0, getppid()) == -1) - perror("setpgid() failed: "); - - if (setsid() == -1) - perror("setsid() failed: "); - - sfd = open(slavename, O_RDWR); - if (sfd < 0) - { - close(mfd); - error ("getpty: can't open slave\n"); - } - - - if (ioctl(sfd, I_PUSH, "ptem")) perror ("getpty: ioctl I_PUSH fails"); - if (ioctl(sfd, I_PUSH, "ldterm")) perror ("getpty: ioctl I_PUSH fails"); - - /* setup mty for non-blocking I/O. */ - - n = fcntl(mfd, F_GETFL); - if (n < 0) - perror ("getpty: fcntl F_GETFL failed"); - - if (fcntl(mfd, F_SETFL, n|O_NDELAY) <0) - perror("getpty: fcntl F_SETFL failed"); - - /* set up for async i/o - V.4 will send SIGPOLL when data available */ - - if (ioctl (mfd, I_SETSIG, S_INPUT|S_RDNORM) < 0) - perror ("getpty: ioctl I_SETSIG failed"); - - if (tcgetattr(sfd, &termios)) - perror("getpty: tcgetattr fails"); - termios.c_oflag &= ~OPOST; /* no post-processing */ - if (tcsetattr(sfd, TCSANOW, &termios)) - perror("getpty: tcsetattr fails"); - - inferior_pty=mfd; - inferior_tty=sfd; - - return; -} - -#endif /* NCR486 */ - -/* Examine a protocol packet from the driver. */ - -static void -kernel_dispatch(queue) - int queue; /* Non-zero means we should just queue up - commands. */ -{ - register CHeader *head; - - head = (CHeader *)CPeekNextRequest (conn); - if (head == NULL) - { - fprintf (stderr, "EOF on kernel read!\n"); - exit (1); - } - - if (head->reqType < LastTtyRequestRType) - { - CTtyRequest* req = CReadTtyRequest (conn); - switch (req->head.reqType) - { - case AcceptConnectionRType: - /* Tell the rest of the world that energize is now set up */ - CSkipRequest (conn); - break; - - case RefuseConnectionRType: - fprintf (stderr, "Debugger connection refused\n"); - exit (1); - - case KillProgramRType: - exit (0); - - case TextIORType: - { - char *p; - ReqLen len; - - p = CGetVstring(conn, &len); - kernel_to_pty(p, len); - } - break; - default: - fprintf(stderr, "Unknown Tty request type = %d\n", - req->head.reqType); - break; - } - } - else - { - CVDebuggerRequest *req = CVReadDebuggerRequest (conn); - if (!req) - { - fprintf (stderr, "CVReadDebuggerRequest returned NULL, type = %d\n", - head->reqType); - exit(1); - } - - switch (req->head.request->reqType) - { - case OpenProgramInstanceRType: - { - char *arglist, buf[100]; /* XXX - Make buf dynamic! */ - int arglen; - /* XXX - should notice when program_id changes */ - arglist = req->openProgramInstance.progArglist.text; - arglen = req->openProgramInstance.progArglist.byteLen; - - execute_command_1(1, queue, "break main"); - execute_command_1(1, queue, "enable delete $bpnum"); - if (arglist) - { - execute_command_1(1, queue, "set args %.*s", arglen, arglist); - } - execute_command_1(1, queue, "run"); - } - break; - case SearchPathRType: - directory_command(req->searchPath.searchPath.text, 0); - break; - case QuitDebuggerRType: - execute_command_1(1, queue, "quit"); - break; - case RunRType: - if (req->run.request->useArglist == CNewArglist) - { - execute_command_1(1, queue, "set args %.*s", - req->run.progArglist.byteLen, - req->run.progArglist.text); - } - execute_command_1(1, queue, "run"); - break; - case ContinueRType: - execute_command_1(1, queue, "continue"); - break; - case StepRType: - execute_command_1(1, queue, "step %d", req->step.request->stepCount); - break; - case NextRType: - execute_command_1(1, queue, "next %d", req->next.request->nextCount); - break; - case ChangeStackFrameRType: - switch (req->changeStackFrame.request->frameMovement) - { - case CToCurrentStackFrame: - execute_command_1(1, queue, "frame %d", - req->changeStackFrame.request->frameNo); - break; - case CToInnerStackFrame: - execute_command_1(1, queue, "down %d", - req->changeStackFrame.request->frameNo); - break; - case CToOuterStackFrame: - execute_command_1(1, queue, "up %d", - req->changeStackFrame.request->frameNo); - break; - case CToAbsoluteStackFrame: - execute_command_1(1, queue, "frame %d", - req->changeStackFrame.request->frameNo); - break; - } - break; - case BackTraceRType: - /* XXX - deal with limit??? */ - execute_command_1(1, queue, "backtrace"); - break; - case FinishRType: - execute_command_1(1, queue, "finish"); - break; - case TerminateProgramRType: - execute_command_1(1, queue, "kill"); - break; - case NewBreakpointRType: - { - char *tail; - int skipped; - - tail = strrchr(req->newBreakpoint.fileName.text, '/'); - if (!tail) - tail = req->newBreakpoint.fileName.text; - else - tail++; - skipped = tail - req->newBreakpoint.fileName.text; - execute_command_1(1, queue, "break %.*s:%d", - req->newBreakpoint.fileName.byteLen - skipped, - tail, - req->newBreakpoint.request->fileLinePos); - } - break; - case StopRType: - kill(-pgrp_inferior, SIGINT); - break; - case UserInputRType: - { - char *text; - long len; - - /* XXX - should really break command up into seperate lines - and spoon-feed it to execute_command */ - - text = req->userInput.userInput.text; - len = req->userInput.userInput.byteLen; - - if (text[len-1] == '\n') text[len-1] = '\000'; - - while (*text == ' ' || *text == '\t') text++; - - if (STREQ(text, "]*[")) /* XXX - What does this mean??? */ - break; - - if (*text != '\000') - execute_command_1(0, queue, "%s", text); - else - print_prompt(); /* User just typed a blank line */ - } - break; - case QueryResponseRType: - { - char *resp; - - if (req->queryResponse.request->response) - resp = "y"; - else - resp = "n"; - execute_command_1(1, 1, resp); - printf_filtered("%s\n", resp); - } - break; - case ChangeBreakpointRType: - switch (req->changeBreakpoint.request->breakpointAttr) - { - case CBreakAttrUnchanged: - execute_command_1(1, queue, "ignore %d %d", - req->changeBreakpoint.request->breakpointId, - req->changeBreakpoint.request->ignoreCount); - break; - case CEnableBreakpoint: - execute_command_1(1, queue, "enable %d", - req->changeBreakpoint.request->breakpointId); - break; - case CDisableBreakpoint: - execute_command_1(1, queue, "disable %d", - req->changeBreakpoint.request->breakpointId); - break; - case CDeleteBreakpoint: - execute_command_1(1, queue, "delete %d", - req->changeBreakpoint.request->breakpointId); - break; - case CEnableDisableBreakpoint: - execute_command_1(1, queue, "enable once %d", - req->changeBreakpoint.request->breakpointId); - break; - case CEnableDeleteBreakpoint: - execute_command_1(1, queue, "enable delete %d", - req->changeBreakpoint.request->breakpointId); - break; - default: - printf_filtered("ChangeBreakpointRType: unknown breakpointAttr\n"); - printf_filtered(" breakpointAttr = %d\n", - req->changeBreakpoint.request->breakpointAttr); - printf_filtered(" breakpointId = %d\n", - req->changeBreakpoint.request->breakpointId); - printf_filtered(" breakpointType = %d\n", - req->changeBreakpoint.request->breakpointType); - printf_filtered(" ignoreCount = %d\n", - req->changeBreakpoint.request->ignoreCount); - break; - } - break; - case BreakConditionRType: - execute_command_1(1, queue, "condition %d %.*s", - req->breakCondition.request->breakpointId, - req->breakCondition.condition.byteLen, - req->breakCondition.condition.text); - break; - case BreakCommandsRType: - /* Put pointers to where energize_command_line_input() can find - them. */ - doing_breakcommands_message = 1; - command_line_length = req->breakCommands.commands.byteLen; - command_line_text = req->breakCommands.commands.text; - execute_command_1(1, queue, "commands %d", - req->breakCommands.request->breakpointId); - command_line_text = (char *)NULL; - command_line_length = 0; - doing_breakcommands_message = 0; - break; - case ShowValueRType: - { - char expr[100], *p = expr; - - expr[0] = 0; - - if (req->showValue.request->ref_type == CValuePointerRef) - strcat(expr, "* "); - - if (req->showValue.type_cast.byteLen) - { - strcat(expr, "("); - strncat(expr, req->showValue.type_cast.text, - req->showValue.type_cast.byteLen); - strcat(expr, ") "); - } - - if (req->showValue.field.byteLen) - strcat(expr, "("); - - strncat(expr, req->showValue.expression.text, - req->showValue.expression.byteLen); - - if (req->showValue.field.byteLen) - { - strcat(expr, ")"); - - strncat(expr, req->showValue.field.text, - req->showValue.field.byteLen); - } - - execute_command_1(1, queue, "print %s", expr); - } - break; - case SetValueRType: - { - char expr[100], *p = expr; - - expr[0] = 0; - - if (req->setValue.request->ref_type == CValuePointerRef) - strcat(expr, "* "); - -#if 0 - if (req->setValue.type_cast.byteLen) - { - strcat(expr, "("); - strncat(expr, req->setValue.type_cast.text, - req->setValue.type_cast.byteLen); - strcat(expr, ") "); - } -#endif - if (req->setValue.field.byteLen) - strcat(expr, "("); - - strncat(expr, req->setValue.expression.text, - req->setValue.expression.byteLen); - - if (req->setValue.field.byteLen) - { - strcat(expr, ")"); - - strncat(expr, req->setValue.field.text, - req->setValue.field.byteLen); - } - - execute_command_1(1, queue, "print %s = (%s) %s", expr, - req->setValue.type_cast.text, - req->setValue.value.text); - } - break; - case DynamicLoadRType: - { - char *filename; - - filename = req->dynamicLoad.filenames.byteLen ? - req->dynamicLoad.filenames.text : exec_file; - - switch (req->dynamicLoad.request->action) - { - case CDynamicLoadUpdateSymtab: - energize_reloading = 1; - execute_command_1(1, queue, "set confirm no"); - execute_command_1(1, queue, "delete"); -/* execute_command_1(1, queue, "set $bpnum=1");*/ /* Use this to reset breakpoint #s */ - execute_command_1(1, queue, "exec-file %s", filename); - execute_command_1(1, queue, "symbol-file %s", filename); - execute_command_1(1, queue, "set confirm yes"); - energize_reloading = 0; - break; - case CDynamicLoadRestoreStart: - break; - case CDynamicLoadRestoreEnd: /* Not used anymore??? */ - printf_filtered("\n[Target has changed, automatic restoration of state has been done.]\n"); - print_prompt(); - break; - default: - printf_filtered("DynamicLoadRType: unknown action=%d, filename=%s\n", - req->dynamicLoad.request->action, - req->dynamicLoad.filenames.text); - break; - } - } - break; - default: - fprintf(stderr, "Unknown Debugger request type = %d\n", - req->head.request->reqType); - break; - } - free (req); /* Should probably call CVFreeDebuggerRequest() here, but - can't do so if interrupt level has mucked with req-> - request. CVFreeDebuggerRequest() only ends up calling - free() anyway! */ - } -} - -/* Return a bitmask indicating if the kernel or the pty did something - interesting. Set poll to non-zero if you don't want to wait. */ - -static int -wait_for_events(poll) - int poll; -{ - fd_set readfds; - int numfds; - int eventmask = 0; - static struct timeval tv = {0}; - - /* Output all pending requests. */ - CWriteRequestBuffer(conn); - - FD_ZERO(&readfds); - - /* Wait till there's some activity from the kernel or the pty. */ - do - { - FD_SET(kerfd, &readfds); - - FD_SET(inferior_pty, &readfds); - - if (poll) - numfds = select(sizeof(readfds)*8, &readfds, 0, 0, &tv); - else - numfds = select(sizeof(readfds)*8, &readfds, 0, 0, 0); - } - while (numfds <= 0 && !poll); - - if (numfds == 0) - return 0; - - if (FD_ISSET(inferior_pty, &readfds)) - eventmask |= PTY_EVENT; - - if (FD_ISSET(kerfd, &readfds)) - eventmask |= KERNEL_EVENT; - - return eventmask; -} - -/* This is called from read_command_lines() to provide the text for breakpoint - commands, which is supplied in a BreakCommands message. Each call to this - routine supplies a single line of text, with the newline removed. */ - -/* This routine may be invoked in two different contexts. In the first, it - is being called as a result of the BreakCommands message. In this case, - all of the command text is immediately available. In the second case, it is - called as a result of the user typing the 'command' command. The command - text then needs to be glommed out of UserInput messages (and possibly other - messages as well). The most 'straighforward' way of doing this is to - basically simulate the main loop, but just accumulate the command text - instead of sending it to execute_command(). */ - -char * -energize_command_line_input(prompt, repeat) - char *prompt; - int repeat; -{ - char *p; - - if (!energize) - return command_line_input(prompt, repeat); - - if (doing_breakcommands_message) - { - if (command_line_length <= 0) - return (char *)NULL; - - p = command_line_text; - - while (command_line_length-- > 0) - { - if (*command_line_text == '\n') - { - *command_line_text = '\000'; - command_line_text++; - break; - } - command_line_text++; - } - - printf_filtered("%s\n", p); - return p; - } - else - { - /* We come here when the user has typed the 'command' or 'define' command - to the GDB window. We are basically deep inside of the 'command' - command processing routine right now, and will be called to get a new - line of input. We expect that kernel_dispatch will queue up only one - command at a time. */ - - int eventmask; - static char buf[100]; - - eventmask = wait_for_events(0); - - if (eventmask & PTY_EVENT) - pty_to_kernel(); - - if (eventmask & KERNEL_EVENT) - kernel_dispatch(1); /* Queue up commands */ - -/* Note that command has been echoed by the time we get here */ - - p = dequeue_command(); - - if (p) - { - strncpy(buf, p, sizeof(buf)); - free(p); - return buf; - } - else - return NULL; - } -} - -/* Establish contact with the kernel. */ - -void -energize_initialize(energize_id, execarg) - char *energize_id; - char *execarg; -{ - CTtyRequest *req; - char *ctmp; - extern long strtol(char *str, char **ptr, int base); - char pathname[MAXPATHLEN]; - int n; - - if (!energize_id) - return; - - if (!execarg) execarg = ""; - - exec_file = strdup(execarg); /* Save for later */ - - printf("\ngdb-debugger pid=%d\n", getpid()); /* XXX - debugging only */ - - /* First establish the connection with the kernel. */ - - kerfd = COpenClientSocket(NULL); - if (kerfd < 0) { - printf("COpenClientSocket() failed\n"); - exit(1); - } - - /* Setup for I/O interrupts when appropriate. */ - - signal(SIGIO, SIG_IGN); - -#ifdef NCR486 - if (ioctl (kerfd, I_SETSIG, S_INPUT|S_RDNORM) < 0) - perror ("getpty: ioctl I_SETSIG failed"); -#else - n = fcntl(kerfd, F_GETFL, 0); - fcntl(kerfd, F_SETFL, n|FASYNC); - fcntl(kerfd, F_SETOWN, getpid()); -#endif - - /* Setup connection buffering. */ - - CSetSocketBufferSize (kerfd, 12000); - - /* Generate a new connection control block. */ - - conn = NewConnection (0, kerfd, kerfd); - if (!conn) { - printf("NewConnection() failed\n"); - exit(1); - } - -#ifdef KERNEL_RECORD - kerout = fopen("kernel.output", "+w"); - - CReadWriteHooks(conn, conn->previewMethod, conn->readMethod, kernel_record); -#endif - - /* Tell the kernel that we are the "debugger". */ - - req = CWriteTtyRequest (conn, QueryConnectionRType); - req->generic.queryconnection.major = 0; - req->generic.queryconnection.minor = 0; - req->generic.queryconnection.cadillacId1=strtol(energize_id, &ctmp, 16); - req->generic.queryconnection.cadillacId2 = strtol(++ctmp, NULL, 16); - req->generic.queryconnection.nProtocols = 1; - CWriteProtocol (conn, 0, 0, "debugger"); - CWriteLength (conn); - - /* Tell the kernel that we are actually running. */ - - /* KROCK ALERT!!! The kernel doesn't really care about the arguments to - the program at all! It only cares that argument 7 be the name of the - target program. So, we just fill in the rest of the slots with - padding. I hope the kernel never cares about this! */ - - req = CWriteTtyRequest (conn, RunningProgramRType); - req->runningprogram.argc = 8; - getcwd (pathname, MAXPATHLEN); - CWriteVstring0 (conn, pathname); - - CWriteVstring0 (conn, "0"); - CWriteVstring0 (conn, "1"); - CWriteVstring0 (conn, "2"); - CWriteVstring0 (conn, "3"); - CWriteVstring0 (conn, "4"); - CWriteVstring0 (conn, "5"); - CWriteVstring0 (conn, "6"); - CWriteVstring0 (conn, execarg); - CWriteLength (conn); - - /* Tell the kernel our PID and all that */ - - program_id = 1; - CVWriteDebugProgramInfo(conn, - getpid(), - program_id, - execarg, - ""); - - /* Tell the rest of the world that Energize is now set up. */ - energize = 1; - - getpty(); /* Setup the pty */ - - /* Attach all GDB I/O to the pty */ - - dup2(inferior_tty, 0); - dup2(inferior_tty, 1); - dup2(inferior_tty, 2); -} - -/* This is called from execute_command, and provides a wrapper around - various command routines in a place where both protocol messages and - user input both flow through. -*/ - -void -energize_call_command(cmdblk, arg, from_tty) - struct cmd_list_element *cmdblk; - char *arg; - int from_tty; -{ - if (!energize) - { - (*cmdblk->function.cfunc) (arg, from_tty); - return; - } - - if (cmdblk->class == class_run) - { - go_busy(); - has_run = 1; - (*cmdblk->function.cfunc)(arg, from_tty); - send_status(); - } - else - (*cmdblk->function.cfunc)(arg, from_tty); - - if (STREQ(cmdblk->name, "up") - || STREQ(cmdblk->name, "down") - || STREQ(cmdblk->name, "frame")) - send_location(get_frame_info(selected_frame)->pc, - selected_frame_level); - print_prompt(); -} - -void -energize_new_process() -{ - instance_id = inferior_pid; -} - -static void -iosig(signo) - int signo; -{ - while (1) - { - int eventmask; - - eventmask = wait_for_events(1); - - if (eventmask == 0) - return; - - if (eventmask & PTY_EVENT) - pty_to_kernel(); - - if (eventmask & KERNEL_EVENT) - kernel_dispatch(1); - } -} - -int -energize_wait(status) - int *status; -{ - int pid; - struct sigaction action; - static sigset_t nullsigmask = {0}; - - if (!energize) - return target_wait(status); - -#ifdef NCR486 - action.sa_handler = iosig; - action.sa_mask = nullsigmask; - action.sa_flags = SA_RESTART; - sigaction(SIGIO, &action, NULL); -#else - signal(SIGIO, iosig); -#endif - - pid = target_wait(status); - - signal(SIGIO, SIG_IGN); - return pid; -} - -int -energize_shell_wait(status) - int *status; -{ - int pid; - struct sigaction action; - static sigset_t nullsigmask = {0}; - - if (!energize) - return wait(status); - -#ifdef NCR486 - action.sa_handler = iosig; - action.sa_mask = nullsigmask; - action.sa_flags = SA_RESTART; - sigaction(SIGIO, &action, NULL); -#else - signal(SIGIO, iosig); -#endif - - pid = wait(status); - - signal(SIGIO, SIG_IGN); - return pid; -} - -static void -null_routine(arg) - int arg; -{ -} - -/* All requests from the Energize kernel eventually end up here. */ - -void -energize_main_loop() -{ - CTtyRequest *req; - struct cleanup *old_chain; - - doing_breakcommands_message = 0; - -/* We will come thru here any time there is an error, so send status if - necessary. */ - - send_status(); - - print_prompt(); - - /* The actual event loop! */ - - while (1) - { - int eventmask; - char *cmd; - - old_chain = make_cleanup(null_routine, 0); - -/* First, empty out the command queue, then check for new requests. */ - - while (cmd = dequeue_command()) - { - execute_command_1(1, 0, cmd); - free(cmd); - } - - eventmask = wait_for_events(0); - - if (eventmask & PTY_EVENT) - pty_to_kernel(); - - if (eventmask & KERNEL_EVENT) - kernel_dispatch(0); - - bpstat_do_actions(&stop_bpstat); - do_cleanups(old_chain); - } -} diff --git a/gdb/energize.h b/gdb/energize.h index 8a39bf6..e69de29 100644 --- a/gdb/energize.h +++ b/gdb/energize.h @@ -1,92 +0,0 @@ -/* Energize interface defs for GDB. - Copyright (C) 1992 Free Software Foundation, Inc. - -This file is part of GDB. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if !defined (ENERGIZE_H) -#define ENERGIZE_H 1 - -#ifdef __STDC__ -struct cmd_list_element; -struct symbol; -struct type; -struct objfile; -struct breakpoint; -#endif /* __STDC__ */ - -/* Non-zero means that we're doing the energize interface. */ -extern int energize; - -/* Get a pty for use with energize */ -extern char *energize_getpty PARAMS ((void)); - -/* Notify energize of new process creation */ -extern void energize_new_process PARAMS ((void)); - -/* Low level wait routine for wait_for_inferior */ -extern int energize_wait PARAMS ((int *)); - -/* Wait routine for processes spawned by the shell command */ -extern int energize_shell_wait PARAMS ((int *statusp)); - -/* Initialize */ -extern void energize_initialize PARAMS ((char *, char *)); - -/* Main loop for energize protocol driver */ -extern void energize_main_loop PARAMS ((void)); - -/* Command hook for energize */ -extern void energize_call_command PARAMS ((struct cmd_list_element *, - char *, int)); - -/* Read commands for the command command, and others */ -extern char *energize_command_line_input PARAMS ((char *, int)); - -extern void energize_start_variable_annotation PARAMS ((char *, - struct symbol *, - struct type *, - CORE_ADDR, - char *)); - -extern void energize_end_variable_annotation PARAMS ((void)); - -extern void energize_annotate_function PARAMS ((char *, int, int)); - -extern void energize_symbol_file PARAMS ((struct objfile *)); - -/*extern void energize_query PARAMS ((char *, ...));*/ -extern void energize_query (); /* Prototypes for varargs don't work */ - -extern void energize_acknowledge_query PARAMS ((char *)); - -extern void energize_fputs PARAMS ((const char *)); - -extern void energize_condition_breakpoint PARAMS ((struct breakpoint *)); - -extern void energize_commands_breakpoint PARAMS ((struct breakpoint *)); - -extern void energize_ignore_breakpoint PARAMS ((struct breakpoint *)); - -extern void energize_create_breakpoint PARAMS ((struct breakpoint *)); - -extern void energize_delete_breakpoint PARAMS ((struct breakpoint *)); - -extern void energize_enable_breakpoint PARAMS ((struct breakpoint *)); - -extern void energize_disable_breakpoint PARAMS ((struct breakpoint *)); - -#endif /* !defined (ENERGIZE_H) */ diff --git a/gdb/remote-mon.c b/gdb/remote-mon.c index b7dabca..e69de29 100644 --- a/gdb/remote-mon.c +++ b/gdb/remote-mon.c @@ -1,1259 +0,0 @@ -/* Remote debugging interface for boot monitors, for GDB. - Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc. - Contributed by Cygnus Support. Written by Rob Savoye for Cygnus. - -This file is part of GDB. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This file was derived from remote-eb.c, which did a similar job, but for - an AMD-29K running EBMON. That file was in turn derived from remote.c - as mentioned in the following comment (left in for comic relief): - - "This is like remote.c but is for an esoteric situation-- - having an a29k board in a PC hooked up to a unix machine with - a serial line, and running ctty com1 on the PC, through which - the unix machine can run ebmon. Not to mention that the PC - has PC/NFS, so it can access the same executables that gdb can, - over the net in real time." - - In reality, this module talks to a debug monitor called 'MONITOR', which - We communicate with MONITOR via either a direct serial line, or a TCP - (or possibly TELNET) stream to a terminal multiplexor, - which in turn talks to the target board. - - This is based on remote-st2000.c. I left in the above note here for histerical - reasons. -*/ - -#include "defs.h" -#include "gdbcore.h" -#include "target.h" -#include "wait.h" -#include <varargs.h> -#include <signal.h> -#include <string.h> -#include <sys/types.h> -#include "command.h" -#include "serial.h" -#include "monitor.h" -#include "remote-utils.h" - -#ifdef HAVE_TERMIO -# define TERMINAL struct termios -#else -# define TERMINAL struct sgttyb -#endif - -struct monitor_ops *current_monitor; -extern struct target_ops rom68k_ops; /* Forward declaration */ -extern struct target_ops mon68_ops; /* Forward declaration */ -extern struct target_ops monitor_bug_ops; /* Forward declaration */ -extern struct monitor_ops rom68k_cmds; /* Forward declaration */ -#if 0 -extern struct monitor_ops mon68_cmds; /* Forward declaration */ -#endif -extern struct monitor_ops bug_cmds; /* Forward declaration */ -extern struct cmd_list_element *setlist; -extern struct cmd_list_element *unsetlist; -struct cmd_list_element *showlist; - -static void monitor_close(); -static void monitor_fetch_register(); -static void monitor_store_register(); -#if 0 -static int sr_get_debug(); /* flag set by "set remotedebug" */ -#endif -static int hashmark; /* flag set by "set hash" */ - -/* FIXME: Replace with sr_get_debug (). */ -#define LOG_FILE "monitor.log" -#if defined (LOG_FILE) -FILE *log_file; -#endif - -static int timeout = 24; - -/* Descriptor for I/O to remote machine. Initialize it to NULL so that - monitor_open knows that we don't have a file open when the program starts. - */ -static serial_t monitor_desc = NULL; - -/* Send data to monitor. Works just like printf. */ - -static void -printf_monitor(va_alist) - va_dcl -{ - va_list args; - char *pattern; - char buf[200]; - int i; - - va_start(args); - - pattern = va_arg(args, char *); - - vsprintf(buf, pattern, args); - - if (SERIAL_WRITE(monitor_desc, buf, strlen(buf))) - fprintf(stderr, "SERIAL_WRITE failed: %s\n", safe_strerror(errno)); -} - -/* Read a character from the remote system, doing all the fancy - timeout stuff. */ -static int -readchar(timeout) - int timeout; -{ - int c; - - c = SERIAL_READCHAR(monitor_desc, timeout); - - if (sr_get_debug()) - putchar(c & 0x7f); - -#ifdef LOG_FILE - if (isascii (c)) - putc(c & 0x7f, log_file); -#endif - - if (c >= 0) - return c & 0x7f; - - if (c == SERIAL_TIMEOUT) - { - if (timeout == 0) - return c; /* Polls shouldn't generate timeout errors */ - - error("Timeout reading from remote system."); - } - - perror_with_name("remote-monitor"); -} - -/* Scan input from the remote system, until STRING is found. If DISCARD is - non-zero, then discard non-matching input, else print it out. - Let the user break out immediately. */ -static void -expect(string, discard) - char *string; - int discard; -{ - char *p = string; - int c; - - if (sr_get_debug()) - printf ("Expecting \"%s\"\n", string); - - immediate_quit = 1; - while (1) - { - c = readchar(timeout); - if (!isascii (c)) - continue; - if (c == *p++) - { - if (*p == '\0') - { - immediate_quit = 0; - if (sr_get_debug()) - printf ("\nMatched\n"); - return; - } - } - else - { - if (!discard) - { - fwrite(string, 1, (p - 1) - string, stdout); - putchar((char)c); - fflush(stdout); - } - p = string; - } - } -} - -/* Keep discarding input until we see the MONITOR prompt. - - The convention for dealing with the prompt is that you - o give your command - o *then* wait for the prompt. - - Thus the last thing that a procedure does with the serial line - will be an expect_prompt(). Exception: monitor_resume does not - wait for the prompt, because the terminal is being handed over - to the inferior. However, the next thing which happens after that - is a monitor_wait which does wait for the prompt. - Note that this includes abnormal exit, e.g. error(). This is - necessary to prevent getting into states from which we can't - recover. */ -static void -expect_prompt(discard) - int discard; -{ -#if defined (LOG_FILE) - /* This is a convenient place to do this. The idea is to do it often - enough that we never lose much data if we terminate abnormally. */ - fflush(log_file); -#endif - expect (PROMPT, discard); -} - -/* Get a hex digit from the remote system & return its value. - If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */ -static int -get_hex_digit(ignore_space) - int ignore_space; -{ - int ch; - while (1) - { - ch = readchar(timeout); - if (ch >= '0' && ch <= '9') - return ch - '0'; - else if (ch >= 'A' && ch <= 'F') - return ch - 'A' + 10; - else if (ch >= 'a' && ch <= 'f') - return ch - 'a' + 10; - else if (ch == ' ' && ignore_space) - ; - else - { - expect_prompt(1); - error("Invalid hex digit from remote system."); - } - } -} - -/* Get a byte from monitor and put it in *BYT. Accept any number - leading spaces. */ -static void -get_hex_byte (byt) - char *byt; -{ - int val; - - val = get_hex_digit (1) << 4; - val |= get_hex_digit (0); - *byt = val; -} - -/* Get N 32-bit words from remote, each preceded by a space, - and put them in registers starting at REGNO. */ -static void -get_hex_regs (n, regno) - int n; - int regno; -{ - long val; - int i; - - for (i = 0; i < n; i++) - { - int j; - - val = 0; - for (j = 0; j < 8; j++) - val = (val << 4) + get_hex_digit (j == 0); - supply_register (regno++, (char *) &val); - } -} - -/* This is called not only when we first attach, but also when the - user types "run" after having attached. */ -static void -monitor_create_inferior (execfile, args, env) - char *execfile; - char *args; - char **env; -{ - int entry_pt; - - if (args && *args) - error("Can't pass arguments to remote MONITOR process"); - - if (execfile == 0 || exec_bfd == 0) - error("No exec file specified"); - - entry_pt = (int) bfd_get_start_address (exec_bfd); - -#ifdef LOG_FILE - fputs ("\nIn Create_inferior()", log_file); -#endif - -/* The "process" (board) is already stopped awaiting our commands, and - the program is already downloaded. We just set its PC and go. */ - - clear_proceed_status (); - - /* Tell wait_for_inferior that we've started a new process. */ - init_wait_for_inferior (); - - /* Set up the "saved terminal modes" of the inferior - based on what modes we are starting it with. */ - target_terminal_init (); - - /* Install inferior's terminal modes. */ - target_terminal_inferior (); - - /* insert_step_breakpoint (); FIXME, do we need this? */ - - /* Let 'er rip... */ - proceed ((CORE_ADDR)entry_pt, TARGET_SIGNAL_DEFAULT, 0); -} - -/* Open a connection to a remote debugger. - NAME is the filename used for communication. */ - -static int baudrate = 9600; -static char dev_name[100]; - -static void -general_open(args, name, from_tty) - char *args; - char *name; - int from_tty; -{ - if (args == NULL) - error ("Use `target %s DEVICE-NAME' to use a serial port, or \n\ -`target %s HOST-NAME:PORT-NUMBER' to use a network connection.", name, name); - - target_preopen(from_tty); - -/* if (is_open) */ - monitor_close(0); - - strcpy(dev_name, args); - monitor_desc = SERIAL_OPEN(dev_name); - - if (monitor_desc == NULL) - perror_with_name(dev_name); - - if (baud_rate != -1) - { - if (SERIAL_SETBAUDRATE (monitor_desc, baud_rate)) - { - SERIAL_CLOSE (monitor_desc); - perror_with_name (name); - } - } - - SERIAL_RAW(monitor_desc); - -#if defined (LOG_FILE) - log_file = fopen (LOG_FILE, "w"); - if (log_file == NULL) - perror_with_name (LOG_FILE); -#endif - - /* Hello? Are you there? */ - printf_monitor("\r"); /* CR wakes up monitor */ - - expect_prompt(1); - - if (from_tty) - printf("Remote %s connected to %s\n", target_shortname, - dev_name); -} - -static void -rom68k_open(args, from_tty) - char *args; - int from_tty; -{ - push_target(&rom68k_ops); - push_monitor (&rom68k_cmds); - - general_open (args, "rom68k", from_tty); -} - -static void -mon68_open(args, from_tty) - char *args; - int from_tty; -{ - push_target(&mon68_ops); -#if 0 - push_monitor (&mon68_cmds); -#endif - - general_open (args, "mon68", from_tty); -} - -static void -bug_open(args, from_tty) - char *args; - int from_tty; -{ - push_target(&monitor_bug_ops); - push_monitor (&bug_cmds); - - general_open (args, "bug", from_tty); -} - -/* - * _close -- Close out all files and local state before this target loses control. - */ - -static void -monitor_close (quitting) - int quitting; -{ - SERIAL_CLOSE(monitor_desc); - monitor_desc = NULL; - -#if defined (LOG_FILE) - if (log_file) { - if (ferror(log_file)) - fprintf(stderr, "Error writing log file.\n"); - if (fclose(log_file) != 0) - fprintf(stderr, "Error closing log file.\n"); - } -#endif -} - -/* Terminate the open connection to the remote debugger. - Use this when you want to detach and do something else - with your gdb. */ -static void -monitor_detach (from_tty) - int from_tty; -{ - pop_target(); /* calls monitor_close to do the real work */ - if (from_tty) - printf ("Ending remote %s debugging\n", target_shortname); -} - -/* - * _resume -- Tell the remote machine to resume. - */ -static void -monitor_resume (pid, step, sig) - int pid, step; - enum target_signal sig; -{ -#ifdef LOG_FILE - fprintf (log_file, "\nIn Resume (step=%d, sig=%d)\n", step, sig); -#endif - - if (step) - { - printf_monitor (STEP_CMD); - /* wait for the echo. */ - expect (STEP_CMD, 1); - } - else - { - printf_monitor (GO_CMD); - /* swallow the echo. */ - expect (GO_CMD, 1); - } -} - -/* - * _wait -- Wait until the remote machine stops, then return, - * storing status in status just as `wait' would. - */ - -static int -monitor_wait (pid, status) - int pid; - struct target_waitstatus *status; -{ - int old_timeout = timeout; -#ifdef LOG_FILE - fputs ("\nIn wait ()", log_file); -#endif - - status->kind = TARGET_WAITKIND_EXITED; - status->value.integer = 0; - - timeout = 0; /* Don't time out -- user program is running. */ - - expect_prompt(0); /* Wait for prompt, outputting extraneous text */ - - status->kind = TARGET_WAITKIND_STOPPED; - status->value.sig = TARGET_SIGNAL_TRAP; - - timeout = old_timeout; - - return 0; -} - -/* Return the name of register number regno in the form input and output by - monitor. Currently, register_names just happens to contain exactly what - monitor wants. Lets take advantage of that just as long as possible! */ - -static char * -get_reg_name (regno) - int regno; -{ - static char buf[50]; - const char *p; - char *b; - - b = buf; - - if (regno < 0) - return (""); - for (p = reg_names[regno]; *p; p++) - *b++ = toupper(*p); - *b = '\000'; - - return buf; -} - -/* read the remote registers into the block regs. */ - -static void -monitor_fetch_registers () -{ - int regno; - - /* yeah yeah, i know this is horribly inefficient. but it isn't done - very often... i'll clean it up later. */ - - for (regno = 0; regno <= PC_REGNUM; regno++) - monitor_fetch_register(regno); -} - -/* Fetch register REGNO, or all registers if REGNO is -1. - Returns errno value. */ -static void -monitor_fetch_register (regno) - int regno; -{ - int val, j; - -#ifdef LOG_FILE - fprintf (log_file, "\nIn Fetch Register (reg=%s)\n", get_reg_name (regno)); - fflush (log_file); -#endif - - if (regno < 0) - { - monitor_fetch_registers (); - } - else - { - char *name = get_reg_name (regno); - printf_monitor (GET_REG, name); - expect (name, 1); - expect (REG_DELIM, 1); - if (strcasecmp (name, "SR") == 0) - { - val = 0; - for (j = 0; j < 4; j++) - val = (val << 4) + get_hex_digit (j == 0); - supply_register (regno, (char *) &val); - } - else - { - get_hex_regs (1, regno); - } - if (CMD_END) - { - expect (CMD_DELIM); - printf_monitor (CMD_END); - } - expect_prompt (1); - } - return; -} - -/* Store the remote registers from the contents of the block REGS. */ - -static void -monitor_store_registers () -{ - int regno; - - for (regno = 0; regno <= PC_REGNUM; regno++) - monitor_store_register(regno); - - registers_changed (); -} - -/* Store register REGNO, or all if REGNO == 0. - return errno value. */ -static void -monitor_store_register (regno) - int regno; -{ -#ifdef LOG_FILE - fprintf (log_file, "\nIn Store_register (regno=%d)\n", regno); -#endif - if (regno == -1) - monitor_store_registers (); - else - { - if (sr_get_debug()) - printf ("Setting register %s to 0x%x\n", get_reg_name (regno), read_register (regno)); - - printf_monitor (SET_REG, get_reg_name (regno), - read_register (regno)); - - expect_prompt (1); - } -} - -/* Get ready to modify the registers array. On machines which store - individual registers, this doesn't need to do anything. On machines - which store all the registers in one fell swoop, this makes sure - that registers contains all the registers from the program being - debugged. */ - -static void -monitor_prepare_to_store () -{ - /* Do nothing, since we can store individual regs */ -} - -static void -monitor_files_info () -{ - printf ("\tAttached to %s at %d baud.\n", - dev_name, baudrate); -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. Returns length moved. */ -static int -monitor_write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - unsigned char *myaddr; - int len; -{ - int i; - char buf[10]; - -#ifdef LOG_FILE - fprintf (log_file, "\nIn Write_inferior_memory (memaddr=%x, len=%d)\n", memaddr, len); -#endif - for (i = 0; i < len; i++) - { - printf_monitor (MEM_SET_CMD, memaddr + i); - expect (sprintf (buf, MEM_PROMPT, memaddr + i), 1); - expect (CMD_DELIM); - printf_monitor ("%x", myaddr[i]); - if (sr_get_debug()) - printf ("\nSet 0x%x to 0x%x\n", memaddr + i, myaddr[i]); - if (CMD_END) - { -/*** expect (sprintf (buf, MEM_PROMPT, memaddr + i +1), 1); - expect (CMD_DELIM); ***/ - printf_monitor (CMD_END); - } - expect_prompt (1); - } - return len; -} - -/* Read LEN bytes from inferior memory at MEMADDR. Put the result - at debugger address MYADDR. Returns length moved. */ -static int -monitor_read_inferior_memory(memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int i, j; - char buf[20]; - - /* Number of bytes read so far. */ - int count; - - /* Starting address of this pass. */ - unsigned long startaddr; - - /* Number of bytes to read in this pass. */ - int len_this_pass; - -#ifdef LOG_FILE - fprintf (log_file, "\nIn Read_inferior_memory (memaddr=%x, len=%d)\n", memaddr, len); -#endif - - /* Note that this code works correctly if startaddr is just less - than UINT_MAX (well, really CORE_ADDR_MAX if there was such a - thing). That is, something like - monitor_read_bytes (CORE_ADDR_MAX - 4, foo, 4) - works--it never adds len To memaddr and gets 0. */ - /* However, something like - monitor_read_bytes (CORE_ADDR_MAX - 3, foo, 4) - doesn't need to work. Detect it and give up if there's an attempt - to do that. */ - if (((memaddr - 1) + len) < memaddr) { - errno = EIO; - return 0; - } - - startaddr = memaddr; - count = 0; - while (count < len) - { - len_this_pass = 16; - if ((startaddr % 16) != 0) - len_this_pass -= startaddr % 16; - if (len_this_pass > (len - count)) - len_this_pass = (len - count); - if (sr_get_debug()) - printf ("\nDisplay %d bytes at %x\n", len_this_pass, startaddr); - - for (i = 0; i < len_this_pass; i++) - { - printf_monitor (MEM_DIS_CMD, startaddr); - expect (sprintf(buf, MEM_PROMPT, startaddr), 1); - get_hex_byte (&myaddr[count++]); - if (sr_get_debug()) - printf ("\nRead a 0x%x from 0x%x\n", myaddr[count-1], startaddr); - if (CMD_END) - { - expect (CMD_DELIM); - printf_monitor (CMD_END); - } - expect_prompt (1); - startaddr += 1; - } - } - return len; -} - -/* FIXME-someday! merge these two. */ -static int -monitor_xfer_inferior_memory (memaddr, myaddr, len, write, target) - CORE_ADDR memaddr; - char *myaddr; - int len; - int write; - struct target_ops *target; /* ignored */ -{ - if (write) - return monitor_write_inferior_memory (memaddr, myaddr, len); - else - return monitor_read_inferior_memory (memaddr, myaddr, len); -} - -static void -monitor_kill (args, from_tty) - char *args; - int from_tty; -{ - return; /* ignore attempts to kill target system */ -} - -/* Clean up when a program exits. - The program actually lives on in the remote processor's RAM, and may be - run again without a download. Don't leave it full of breakpoint - instructions. */ - -static void -monitor_mourn_inferior () -{ - remove_breakpoints (); - generic_mourn_inferior (); /* Do all the proper things now */ -} - -#define MAX_MONITOR_BREAKPOINTS 16 - -extern int memory_breakpoint_size; -static CORE_ADDR breakaddr[MAX_MONITOR_BREAKPOINTS] = {0}; - -static int -monitor_insert_breakpoint (addr, shadow) - CORE_ADDR addr; - char *shadow; -{ - int i; - -#ifdef LOG_FILE - fprintf (log_file, "\nIn Insert_breakpoint (addr=%x)\n", addr); -#endif - for (i = 0; i <= MAX_MONITOR_BREAKPOINTS; i++) - if (breakaddr[i] == 0) - { - breakaddr[i] = addr; - if (sr_get_debug()) - printf ("Breakpoint at %x\n", addr); - monitor_read_inferior_memory(addr, shadow, memory_breakpoint_size); - printf_monitor(SET_BREAK_CMD, addr); - expect_prompt(1); - return 0; - } - - fprintf(stderr, "Too many breakpoints (> 16) for monitor\n"); - return 1; -} - -/* - * _remove_breakpoint -- Tell the monitor to remove a breakpoint - */ -static int -monitor_remove_breakpoint (addr, shadow) - CORE_ADDR addr; - char *shadow; -{ - int i; - -#ifdef LOG_FILE - fprintf (log_file, "\nIn Remove_breakpoint (addr=%x)\n", addr); -#endif - for (i = 0; i < MAX_MONITOR_BREAKPOINTS; i++) - if (breakaddr[i] == addr) - { - breakaddr[i] = 0; - /* some monitors remove breakpoints based on the address */ - if (strcasecmp (target_shortname, "bug") == 0) - printf_monitor(CLR_BREAK_CMD, addr); - else - printf_monitor(CLR_BREAK_CMD, i); - expect_prompt(1); - return 0; - } - - fprintf(stderr, "Can't find breakpoint associated with 0x%x\n", addr); - return 1; -} - -/* Load a file. This is usually an srecord, which is ascii. No - protocol, just sent line by line. */ - -#define DOWNLOAD_LINE_SIZE 100 -static void -monitor_load (arg) - char *arg; -{ - FILE *download; - char buf[DOWNLOAD_LINE_SIZE]; - int i, bytes_read; - - if (sr_get_debug()) - printf ("Loading %s to monitor\n", arg); - - download = fopen (arg, "r"); - if (download == NULL) - { - error (sprintf (buf, "%s Does not exist", arg)); - return; - } - - printf_monitor (LOAD_CMD); -/* expect ("Waiting for S-records from host... ", 1); */ - - while (!feof (download)) - { - bytes_read = fread (buf, sizeof (char), DOWNLOAD_LINE_SIZE, download); - if (hashmark) - { - putchar ('.'); - fflush (stdout); - } - - if (SERIAL_WRITE(monitor_desc, buf, bytes_read)) { - fprintf(stderr, "SERIAL_WRITE failed: (while downloading) %s\n", safe_strerror(errno)); - break; - } - i = 0; - while (i++ <=200000) {} ; /* Ugly HACK, probably needs flow control */ - if (bytes_read < DOWNLOAD_LINE_SIZE) - { - if (!feof (download)) - error ("Only read %d bytes\n", bytes_read); - break; - } - } - - if (hashmark) - { - putchar ('\n'); - } - if (!feof (download)) - error ("Never got EOF while downloading"); - fclose (download); -} - -/* Put a command string, in args, out to MONITOR. Output from MONITOR is placed - on the users terminal until the prompt is seen. */ - -static void -monitor_command (args, fromtty) - char *args; - int fromtty; -{ -#ifdef LOG_FILE - fprintf (log_file, "\nIn command (args=%s)\n", args); -#endif - if (monitor_desc == NULL) - error("monitor target not open."); - - if (!args) - error("Missing command."); - - printf_monitor("%s\r", args); - expect_prompt(0); -} - -#if 0 - -/* Connect the user directly to MONITOR. This command acts just like the - 'cu' or 'tip' command. Use <CR>~. or <CR>~^D to break out. */ - -static struct ttystate ttystate; - -static void -cleanup_tty() -{ printf("\r\n[Exiting connect mode]\r\n"); - /*SERIAL_RESTORE(0, &ttystate);*/ -} - -static void -connect_command (args, fromtty) - char *args; - int fromtty; -{ - fd_set readfds; - int numfds; - int c; - char cur_esc = 0; - - dont_repeat(); - - if (monitor_desc == NULL) - error("monitor target not open."); - - if (args) - fprintf("This command takes no args. They have been ignored.\n"); - - printf("[Entering connect mode. Use ~. or ~^D to escape]\n"); - - serial_raw(0, &ttystate); - - make_cleanup(cleanup_tty, 0); - - FD_ZERO(&readfds); - - while (1) - { - do - - - { - FD_SET(0, &readfds); - FD_SET(monitor_desc, &readfds); - numfds = select(sizeof(readfds)*8, &readfds, 0, 0, 0); - } - while (numfds == 0); - - if (numfds < 0) - perror_with_name("select"); - - if (FD_ISSET(0, &readfds)) - { /* tty input, send to monitor */ - c = getchar(); - if (c < 0) - perror_with_name("connect"); - - printf_monitor("%c", c); - switch (cur_esc) - { - case 0: - if (c == '\r') - cur_esc = c; - break; - case '\r': - if (c == '~') - cur_esc = c; - else - cur_esc = 0; - break; - case '~': - if (c == '.' || c == '\004') - return; - else - cur_esc = 0; - } - } - - if (FD_ISSET(monitor_desc, &readfds)) - { - while (1) - { - c = readchar(0); - if (c < 0) - break; - putchar(c); - } - fflush(stdout); - } - } -} -#endif - -struct target_ops rom68k_ops = { - "rom68k", - "Integrated System's ROM68K remote debug monitor", - "Use a remote computer running the ROM68K debug monitor.\n\ -Specify the serial device it is connected to (e.g. /dev/ttya).", - rom68k_open, - monitor_close, - 0, - monitor_detach, - monitor_resume, - monitor_wait, - monitor_fetch_register, - monitor_store_register, - monitor_prepare_to_store, - monitor_xfer_inferior_memory, - monitor_files_info, - monitor_insert_breakpoint, - monitor_remove_breakpoint, /* Breakpoints */ - 0, - 0, - 0, - 0, - 0, /* Terminal handling */ - monitor_kill, - monitor_load, /* load */ - 0, /* lookup_symbol */ - monitor_create_inferior, - monitor_mourn_inferior, - 0, /* can_run */ - 0, /* notice_signals */ - 0, /* to_stop */ - process_stratum, - 0, /* next */ - 1, - 1, - 1, - 1, - 1, /* all mem, mem, stack, regs, exec */ - 0, - 0, /* Section pointers */ - OPS_MAGIC, /* Always the last thing */ -}; - -struct target_ops monitor_bug_ops = { - "bug", - "Motorola's BUG remote serial debug monitor", - "Use a remote computer running Motorola's BUG debug monitor.\n\ -Specify the serial device it is connected to (e.g. /dev/ttya).", - bug_open, - monitor_close, - 0, - monitor_detach, - monitor_resume, - monitor_wait, - monitor_fetch_register, - monitor_store_register, - monitor_prepare_to_store, - monitor_xfer_inferior_memory, - monitor_files_info, - monitor_insert_breakpoint, - monitor_remove_breakpoint, /* Breakpoints */ - 0, - 0, - 0, - 0, - 0, /* Terminal handling */ - monitor_kill, - monitor_load, /* load */ - 0, /* lookup_symbol */ - monitor_create_inferior, - monitor_mourn_inferior, - 0, /* can_run */ - 0, /* notice_signals */ - 0, /* to_stop */ - process_stratum, - 0, /* next */ - 1, - 1, - 1, - 1, - 1, /* all mem, mem, stack, regs, exec */ - 0, - 0, /* Section pointers */ - OPS_MAGIC, /* Always the last thing */ -}; - -struct target_ops mon68_ops = { - "mon68", - "Intermetric's MON68 remote serial debug monitor", - "Use a remote computer running the MON68 debug monitor.\n\ -Specify the serial device it is connected to (e.g. /dev/ttya).", - mon68_open, - monitor_close, - 0, - monitor_detach, - monitor_resume, - monitor_wait, - monitor_fetch_register, - monitor_store_register, - monitor_prepare_to_store, - monitor_xfer_inferior_memory, - monitor_files_info, - monitor_insert_breakpoint, - monitor_remove_breakpoint, /* Breakpoints */ - 0, - 0, - 0, - 0, - 0, /* Terminal handling */ - monitor_kill, - monitor_load, /* load */ - 0, /* lookup_symbol */ - monitor_create_inferior, - monitor_mourn_inferior, - 0, /* can_run */ - 0, /* notice_signals */ - 0, /* to_stop */ - process_stratum, - 0, /* next */ - 1, - 1, - 1, - 1, - 1, /* all mem, mem, stack, regs, exec */ - 0, - 0, /* Section pointers */ - OPS_MAGIC, /* Always the last thing */ -}; - - -/* - * Define the monitor command strings. Since these are passed directly - * through to a printf style function, we need can include formatting - * strings. We also need a CR or LF on the end. - */ -struct monitor_ops rom68k_cmds = { - 1, /* 1 is ascii, 0 is binary */ - "\n", /* monitor init string */ - "go \r", /* execute or usually GO command */ - "go \r", /* continue command */ - "st \r", /* single step */ - "db %x\r", /* set a breakpoint */ - "cb %x\r", /* clear a breakpoint */ - 0, /* 0 for number, 1 for address */ - { - "pm %x\r", /* set memory to a value */ - "", - "", - }, - { - "pm %x\r", /* display memory */ - "", - "", - }, - { - "pr %s %x\r", /* set a register */ - ": ", /* delimiter between registers */ - "", - }, - { - "pr %s\r", /* read a register */ - ": ", /* delimiter between registers */ - "", - }, - "dc \r", /* download command */ - "ROM68K :->", /* monitor command prompt */ - "=", /* end-of-command delimitor */ - ".\r", /* optional command terminator */ - &rom68k_ops, /* target operations */ - "-%08X ", /* prompt memory commands use */ -}; - -struct monitor_ops bug_cmds = { - 1, /* 1 is ascii, 0 is binary */ - "\n", /* monitor init string */ - "go \r", /* execute or usually GO command */ - "go \r", /* continue command */ - "gn \r", /* single step */ - "br %x\r", /* set a breakpoint */ - "nobr %x\r", /* clear a breakpoint */ - 0, /* 0 for number, 1 for address */ - { - "mm %x\r", /* set memory to a value */ - "", - "", -}, - { - "mm %x\r", /* display memory */ - "", - "", -}, - { - "rs %s %x\r", /* set a register */ - "=", /* delimiter between registers */ - "", -}, - { - "rm %s\r", /* read a register */ - "=", /* delimiter between registers */ - "", -}, - "lo 0\r", /* download command */ - "Bug>", /* monitor command prompt */ - "? ", /* end-of-command delimitor */ - ".\r", /* optional command terminator */ - &monitor_bug_ops, - "%08X", /* prompt memory commands use */ -}; - -#if 0 -/* Define the target subroutine names */ -struct monitor_ops mon68_cmds = { - 1, /* 1 is ascii, 0 is binary */ - "", /* execute or usually GO command */ - "", /* continue command */ - "", /* single step */ - "", /* set a breakpoint */ - "", /* clear a breakpoint */ - "", /* set memory to a value */ - "", /* display memory */ - "", /* set a register */ - "", /* delimiter between registers */ - "", /* read a register */ - "", /* download command */ - ">", /* monitor command prompt */ - "", /* end-of-command delimitor */ - "" /* optional command terminator */ - "" /* load types */ -}; -#endif - -void -_initialize_remote_monitors () -{ - add_show_from_set ( - add_set_cmd ("hash", no_class, var_boolean, - (char *)&hashmark, - "Set display of activity while downloading a file.\n\ -When enabled, a period \'.\' is displayed.", - &setlist), - &showlist); - - /* generic monitor command */ - add_com ("monitor <command>", class_obscure, monitor_command, - "Send a command to the debug monitor."); -#if 0 - add_com ("connect", class_obscure, connect_command, - "Connect the terminal directly up to a serial based command monitor.\n\ -Use <CR>~. or <CR>~^D to break out."); -#endif - - add_target (&rom68k_ops); -/* add_target (&mon68_ops); */ - add_target (&monitor_bug_ops); -} diff --git a/gdb/remote-sa.sparc.c b/gdb/remote-sa.sparc.c deleted file mode 100644 index f55d9fb..0000000 --- a/gdb/remote-sa.sparc.c +++ /dev/null @@ -1,1144 +0,0 @@ -/* THIS FILE HAS NOT HAD ITS COPYRIGHT CHECKED...FSF SHOULD NOT - DISTRIBUTE IT UNTIL THIS HAPPENS. */ - -/* Memory-access and commands for inferior process, for GDB. -*/ - -#include "defs.h" -#include <sys/errno.h> -#include <setjmp.h> -#include "frame.h" -#include "value.h" -#include "inferior.h" -#include "symtab.h" - -#undef WSTOPSIG -#undef WTERMSIG -#include "wait.h" - -#ifdef USG -#include <sys/types.h> -#include <fcntl.h> -#endif - -#include <signal.h> -#include <sys/file.h> - -#include <termios.h> -#define TERMINAL struct termios - -#define LONGTIMEOUT 5 -#define SHORTTIMEOUT 1 - -#define KD_MINUTAE 1 -#define KD_LINEDISCIPLINE 2 -#define KD_RETRY 4 -#define KD_BLOCKTRANSFER 8 - -#ifndef STDIN -#define STDIN 0 -#endif - -#define GL_READING 0 /* get line is reading data */ -#define GL_OK 1 /* Getline saw the "ok" string */ -#define GL_SUCCESS 2 /* Get line got data */ -#define GL_TIMEOUT 3 /* Get line timed out */ -#define GL_OVERRUN 4 /* Get line filled up the buffer */ -#define GL_EXCEPTION 5 /* Get line saw "Exception" */ -#define GL_PROMLINE 6 /* Get line saw prom specific info */ -#define GL_BLANKLINE 7 /* Get line saw a blank line */ - -static int kiodebug /* = KD_RETRY | KD_BLOCKTRANSFER */; - -static CORE_ADDR remote_pc = 0; -static CORE_ADDR remote_next_pc = 0; -static CORE_ADDR remove_thisbp_next_pc = 0; -static CORE_ADDR remove_thisbp_target = 0; - -enum showDrainage {DONTSHOW , SHOW} ; - - -/* Descriptor for I/O to remote machine. Initialize it to -1 so that - remote_open knows that we don't have a file open when the program - starts. */ -int remote_desc = -1; - -int dontskipcrs = 0; - -#define PBUFSIZ 400 - -unsigned char ignorebuf[PBUFSIZ]; -#define IGNORE &ignorebuf[0] - -/* Maximum number of bytes to read/write at once. The value here - is chosen to fill up a packet (the headers account for the 32). */ -#define MAXBUFBYTES ((PBUFSIZ-32)/2) - -static void remote_send (); -static void putpkt (); -static int getpkt (); - - -/* Open a connection to a remote debugger. - NAME is the filename used for communication. */ -CORE_ADDR breakpoint_regs_addr; - - -void -remote_open (name, from_tty) - char *name; - int from_tty; -{ - extern int frame_file_full_name; - unsigned char buf[PBUFSIZ]; - TERMINAL sg; - - remote_debugging = 0; - - if (remote_desc >= 0) - close (remote_desc); - - breakpoint_regs_addr = parse_and_eval_address("&breakpoint_regs"); - - dontskipcrs = !frame_file_full_name; /* if we are running inside of - emacs, this will be true. - then skip carriage returns */ - - remote_desc = open (name, O_RDWR); - if (remote_desc < 0) - perror_with_name (name); - - setup_remote(); - - if (from_tty) - printf ("Remote debugging using %s\n", name); - remote_debugging = 1; - - -} -static char *boot_cmd = 0; - -static print_boot_cmd() -{ - fprintf(stderr, "boot command set to be \"%s\"\n", boot_cmd); -} - -remote_start() -{ - WAITTYPE ignoredWaitType; - - if (boot_cmd) - { - sendbreak(); - remote_wait (&ignoredWaitType); - putpkt ("reset"); - sleep(10); - sendbreak(); - remote_wait (&ignoredWaitType); - sleep(10); - print_boot_cmd(); - putpkt(boot_cmd); - fprintf(stderr, "rgdb and nucleus synchronized, booting....\n"); - } - else - { - error("The boot command is null. Cannot start the remote kernel/nucleus"); - } -} - -/* Close the open connection to the remote debugger. - Use this when you want to detach and do something else - with your gdb. */ -void -remote_close (from_tty) - int from_tty; -{ - if (!remote_debugging) - error ("Can't close remote connection: not debugging remotely."); - - close (remote_desc); /* This should never be called if - there isn't something valid in - remote_desc. */ - - /* Do not try to close remote_desc again, later in the program. */ - remote_desc = -1; - - if (from_tty) - printf ("Ending remote debugging\n"); - - remote_debugging = 0; -} - -/* Convert hex digit A to a number. */ - -static int -fromhex (a) - int a; -{ - if (a >= '0' && a <= '9') - return a - '0'; - else if (a >= 'a' && a <= 'f') - return a - 'a' + 10; - else - error ("Reply contains invalid hex digit"); -} - -/* Convert number NIB to a hex digit. */ - -static int -tohex (nib) - int nib; -{ - if (nib < 10) - return '0'+nib; - else - return 'a'+nib-10; -} - -/* Tell the remote machine to resume. */ - -extern int one_stepped; /* From machine dependent code */ -static int remote_set_one_stepped; - -int -remote_resume (pid, step, signal) - int pid, step, signal; -{ - if (step) - { - remote_single_step(); - } - remote_set_one_stepped = step; - putpkt("go"); -} - -/* Wait until the remote machine stops, then return, - storing status in STATUS just as `wait' would. */ - -int -remote_wait (status) - WAITTYPE *status; -{ - char last, this; - int pend, saveTheOh = 0; - - user_terminal_raw(); - - WSETEXIT ((*status), 0177); - last = this = 0; - - while (1) - { - char buf[PBUFSIZ]; - int readUser, readProm, state; - - doselect(&readUser, &readProm); - if (readProm) - { - switch (state = getline(buf, PBUFSIZ, SHORTTIMEOUT)) - { - case GL_BLANKLINE: - if (remote_set_one_stepped) - break; - - /* fall through */ - - default: - case GL_READING: - case GL_SUCCESS: - case GL_OVERRUN: - case GL_TIMEOUT: - if (kiodebug & KD_LINEDISCIPLINE) - fprintf(stderr, "%d<%s>\n", state, buf); - else - { - fprintf(stderr, "%s", buf); - fflush(stderr); - } - break; - case GL_OK: - remote_cleanup_after_stop(); - WSETSTOP ((*status), SIGTRAP); - return; - case GL_PROMLINE: - break; - } - } - if (readUser) - shuffleFromUserToProm(); - } -} -static TERMINAL userterminal; - -user_terminal_restore() -{ -#if 0 - int in_desc = fileno (stdin); - ioctl (in_desc, TCSETS, &userterminal); -#endif -} -static void set_term_raw(); - -user_terminal_raw() -{ -#if 0 - TERMINAL tempterminal; - int in_desc = fileno (stdin); - ioctl (in_desc, TCGETS, &userterminal); - tempterminal = userterminal; - - tempterminal.c_lflag &= ~(ICANON|ISIG|IEXTEN); - tempterminal.c_cc[VMIN] = 1; - tempterminal.c_cc[VTIME] = 0; - tempterminal.c_iflag &= ~(INPCK|IXON|IXOFF); - tempterminal.c_oflag = 0; - - ioctl (in_desc, TCSETS, &tempterminal); -#endif -} - -doselect(pReadUser, pReadProm) - int *pReadUser, *pReadProm; -{ - extern FILE *instream; - int in_desc = fileno (stdin); - int instreammask = 1 << in_desc; - int remotemask = 1 << remote_desc; - int rfds = instreammask | remotemask; - - select (32, &rfds, 0, 0, (struct timeval *) 0); /* 0 = Block indefinitely */ - *pReadUser = (rfds & instreammask) == instreammask; - *pReadProm = (rfds & remotemask) == remotemask; -} - - - -/* Read the remote registers into the block pRegisters. -implementation copied largely from fetch_inferior_registers () -in sparc-dep.c */ - -void -remote_fetch_registers(ignored) -int *ignored; -{ - struct regs inferior_registers; - extern char registers[]; - CORE_ADDR breakpoint_regs_target; - - if (breakpoint_regs_addr == 0) - { - error("no address for breakpoint_regs\n"); - return; - } - remote_read_inferior_memory(breakpoint_regs_addr, &breakpoint_regs_target, - sizeof(breakpoint_regs_target)); - - bzero(registers, REGISTER_BYTES); - registers[REGISTER_BYTE (0)] = 0; - - if (breakpoint_regs_target) - { - remote_read_inferior_memory(breakpoint_regs_target, &inferior_registers, - sizeof(inferior_registers)); - registers[REGISTER_BYTE (0)] = 0; - bcopy (&inferior_registers.r_g1, ®isters[REGISTER_BYTE (1)], 15 * 4); - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; - *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)] = inferior_registers.r_npc; - *(int *)®isters[REGISTER_BYTE (Y_REGNUM)] = inferior_registers.r_y; - remote_pc = inferior_registers.r_pc; - remote_next_pc = inferior_registers.r_npc; - remote_read_inferior_memory (inferior_registers.r_sp, - ®isters[REGISTER_BYTE (16)], - 16*4); - } - else - { - error("breakpoint_regs == 0\n"); - } -} - - - - -/* Write memory data directly to the remote machine. - This does not inform the data cache; the data cache uses this. - MEMADDR is the address in the remote memory space. - MYADDR is the address of the buffer in our space. - LEN is the number of bytes. */ - -int -remote_write_bytes (memaddr, myaddr, len) - CORE_ADDR memaddr; - unsigned char *myaddr; - int len; -{ - char buf[PBUFSIZ]; - int i; - - /* Command describes registers byte by byte, - each byte encoded as two hex characters. */ - - for (i = 0; i < len; i++) - { - sprintf(buf, "%x %x c!", myaddr[i], memaddr + i); - remote_send (buf, buf); - if (strstr(buf, "Exception")) - { - return EFAULT; - } - } - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. Returns errno value. */ -int -remote_write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int xfersize; - int retval; - - while (len > 0) - { - if (len > MAXBUFBYTES) - xfersize = MAXBUFBYTES; - else - xfersize = len; - - retval = remote_write_bytes(memaddr, myaddr, xfersize); - if (retval) - return retval; /* error */ - - memaddr += xfersize; - myaddr += xfersize; - len -= xfersize; - } - return 0; /* no error */ -} - - -/* read a single character */ - -static int -readCharFromProm () -{ - char buf; - - buf = '\0'; - /* termio does the timeout for us. */ - read (remote_desc, &buf, 1); - return buf & 0x7f; -} - -/* Send the command in BUF to the remote machine, - and read the reply into BUF. - Report an error if we get an error reply. */ - -static void -remote_send (buf, buf2) - char *buf, *buf2; -{ - putpkt (buf); - getpkt (buf2); -} - -/* Send a single character out over the wire */ - -static void -putcharacter (ch) - char ch; -{ - - while (1) - { - int i; - - write(remote_desc, &ch, 1); - for (i = 0; i < 100; i++) - { - char nch = 0; - - if (read (remote_desc, &nch, 1) == 0) - i++; - if ((ch == nch) - || (ch == '\n' && nch == '\r') - || (ch == '\r' && nch == '\n')) - return; - if (kiodebug & KD_MINUTAE) - fprintf (stderr, "Sent %c(%d) Received %c(%d)\n", ch, ch, nch, nch); - } - } -} - -/* Send a packet to the remote machine, with error checking. - The data of the packet is in BUF. */ - -static void -putpkt (buf) - char *buf; -{ - int i; - int cnt = strlen (buf); - char ch; - - if (kiodebug & KD_LINEDISCIPLINE) - fprintf(stderr, "putpkt(%s)\n", buf); - - for (i = 0; i < cnt; i++) - putcharacter (buf[i]); - putcharacter ('\n'); -} - -jmp_buf getline_jmpbuf; - -/* Read a line from the remote machine, and store it in BUF. */ -getline_timer() -{ - alarm(0); - - if (kiodebug & KD_RETRY) - fprintf(stderr, "getline timed out\n"); - longjmp(getline_jmpbuf, 1); -} - -static int -getline (buf, size, timeout) - char *buf; - int size, timeout; -{ - int cnt = 0; - int state; - int isspace_state = 1; - - if ((void (*)) signal (SIGALRM, getline_timer) == (void (*)) -1) - perror ("remote_open: error in signal"); - - --size; /* back it up one so that we can read */ - - state = GL_READING; - - if (setjmp(getline_jmpbuf)) - state = GL_TIMEOUT; - else - { - alarm (timeout); - do - { - char ch = readCharFromProm(); - isspace_state = isspace_state && isspace(ch); - if (ch && (dontskipcrs || ch != '\r')) - { - buf[cnt++] = ch; - buf[cnt] = '\0'; - } - if (kiodebug & KD_MINUTAE) - fprintf (stderr,"letter received :%c\n", buf[cnt - 1]); - if (cnt >= 2 && buf[cnt - 2] == 'o' && buf[cnt - 1] == 'k') - state = GL_OK; - else if (buf[cnt - 1] == '\n' ) - state = isspace_state ? GL_BLANKLINE : GL_SUCCESS; - else if (cnt == size) - state = GL_OVERRUN; - else if (strstr(buf, "Type 'go' to resume")) - state = GL_PROMLINE; - else if (strstr(buf, "Type help for more information")) - state = GL_PROMLINE; - else if (strstr(buf, "Exception")) - state = GL_EXCEPTION; - } - while (state == GL_READING); - } - alarm (0); - - if (kiodebug & KD_LINEDISCIPLINE) - fprintf (stderr,"Line received :%s\n", buf); - return state; -} - - -/* Read a packet from the remote machine, and store it in BUF. */ - -static int -getpkt (buf) - char *buf; -{ - int cnt = 0; - - do - { - char ch = readCharFromProm(); - if (ch) - buf[cnt++] = ch; - if (kiodebug & KD_MINUTAE) - fprintf (stderr,"letter received :%c\n", buf[cnt - 1]); - } - while (cnt < 2 || - buf[cnt - 2] != 'o' && - buf[cnt - 1] != 'k'); - - buf[cnt] = '\0'; - if (kiodebug& KD_LINEDISCIPLINE) - fprintf (stderr,"Packet received :%s\n", buf); - return cnt; -} - -void remote_fetch_word (addr) - CORE_ADDR addr; -{ - error ("Internal error: remote_fetch_word is obsolete.\n"); -} -void remote_store_word (addr) - CORE_ADDR addr; -{ - error ("Internal error: remote_store_word is obsolete.\n"); -} -#include <termio.h> - -draininput(showit) -enum showDrainage showit; -{ - unsigned char buf[PBUFSIZ]; - int cnt; - - while ((cnt = read(remote_desc, buf, PBUFSIZ)) > 0) - { - buf[cnt] = 0; - if (kiodebug& KD_LINEDISCIPLINE) - fprintf (stderr,"Draining :%s\n", buf); - else - if (showit == SHOW) - fprintf (stderr,"%s", buf); - } - if (kiodebug& KD_LINEDISCIPLINE) - fprintf (stderr,"Drained\n"); -} -sendbreak() -{ - if (kiodebug & KD_RETRY) - fprintf (stderr,"rgdb sending break to target...\n"); - else - { - fprintf (stderr,"="); - fflush(stderr); - } - - ioctl (remote_desc, TCSBRK, 0); - sleep(5); -} - - -/* shuffle a character from the user to remote debugger */ - -int -shuffleFromUserToProm() -{ - char ch; - static int escape = 0; - - extern FILE *instream; - - ch = 0; - if (read(STDIN, &ch , 1) != 1 || ch == 0) - return; - - if (escape) { - if (ch == '#') - sendbreak(); - else if (ch == '.') - { - while (ch != '\n') - read(STDIN, &ch , 1); - return 1; - } - else { - static char tilde = '~'; - - putcharacter(tilde); - putcharacter(ch); - } - escape = 0; - } else /* not escape */ { - if (ch == '~') - escape = 1; - else - putcharacter(ch); - } - return 0; -} - - - -/* Tell the Prom put a breakpoint at memaddr */ -remote_insert_breakpoint(memaddr) - CORE_ADDR memaddr; -{ - char buf[PBUFSIZ]; - - /* Command describes registers byte by byte, - each byte encoded as two hex characters. */ - - sprintf(buf, "%x +bp", memaddr); - remote_send(buf, buf); - if (strstr(buf, "Exception")) - { - return EFAULT; - } - else - { - return 0; - } -} - -/* Tell the Prom remove the the breakpoint at memaddr */ -remote_remove_breakpoint(memaddr) - CORE_ADDR memaddr; -{ - char buf[PBUFSIZ]; - - /* Command describes registers byte by byte, - each byte encoded as two hex characters. */ - - sprintf(buf, "%x -bp", memaddr); - remote_send(buf, buf); - if (strstr(buf, "Exception")) - { - return EFAULT; - } - else - { - return 0; - } -} - - - - - -/* Read memory data directly from the remote machine. - This does not use the data cache; the data cache uses this. - MEMADDR is the address in the remote memory space. - MYADDR is the address of the buffer in our space. - LEN is the number of words. */ - -long -remote_read(memaddr, myaddr, len, increment, promcommand) - CORE_ADDR memaddr; - unsigned char *myaddr; - int len, increment; - char *promcommand; -{ - char buf[PBUFSIZ]; - char buf2[PBUFSIZ]; - int i; - unsigned long num; - - /* Command describes registers byte by byte, - each byte encoded as two hex characters. */ - - for (i = 0; i < len; i += increment) - { - sprintf(buf, promcommand, memaddr + i) ; - remote_send(buf, buf2); - remote_send(".", buf); - if (strstr(buf2, "Exception")) - { - bzero(&myaddr[i], len - i); - return -i; - } - else - { - char *pBuf; - for (pBuf = &buf[0]; *pBuf == '\r' || *pBuf == '\n'; pBuf++) - ; - sscanf(pBuf, "%x\n", &num); - switch (increment) - { - case 1: myaddr[i] = num; - if (num > 255) - fprintf(stderr, "number out of bounds %x truncating to %x\n", - num, myaddr[i]); - break; - case 4: {unsigned long *p; - p = (unsigned long *) &myaddr[i]; - *p = num; - } - break; - default: fprintf(stderr, "unknown increment\n"); break; - } - } - } - return i; -} - - - -/* Read LEN bytes from inferior memory at MEMADDR. Put the result - at debugger address MYADDR. Returns errno value. */ -int -remote_read_inferior_memory(memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int xfersize; - while (len > 0) - { - int mod; - - if (len > MAXBUFBYTES) - xfersize = MAXBUFBYTES; - else - xfersize = len; - - mod = memaddr % 4; - if (mod == 0 && xfersize >= 4) - if (mod == 0 && xfersize >= 16) - { - xfersize = remote_read_many(memaddr, myaddr, (len & ~3)); - getpkt(IGNORE); - } - else - xfersize = remote_read(memaddr, myaddr, 4, 4, "%x @"); - else - xfersize = remote_read(memaddr, myaddr, max(mod, 1), 1, "%x c@"); - if (xfersize <= 0) - return EFAULT; /* error */ - memaddr += xfersize; - myaddr += xfersize; - len -= xfersize; - } - return 0; /* no error */ -} -static int baud_rate=B38400; - -static void set_term_raw(pTermio) - TERMINAL *pTermio; -{ - pTermio->c_cflag &= (CREAD|HUPCL|CLOCAL); - pTermio->c_cflag |= baud_rate | CS8; - pTermio->c_iflag = ISTRIP /* | IXON | IXOFF */; - pTermio->c_oflag = 0; - pTermio->c_lflag = 0; - pTermio->c_cc[VMIN] = 0; - pTermio->c_cc[VTIME] = 1; -} - -/* setup the remote termio stream */ -setup_remote() -{ - TERMINAL temptempio; - - ioctl(remote_desc, TCGETS, &temptempio); - set_term_raw(&temptempio); - ioctl(remote_desc, TCSETS, &temptempio); -} - -/* step one machine instruction */ -remote_single_step () -{ - CORE_ADDR next_pc, npc4, target, pc; - typedef enum - { - Error, not_branch, bicc, bicca, ba, baa, ticc, ta - } branch_type; - branch_type br, isbranch (); - - npc4 = remote_next_pc + 4; /* branch not taken */ - - /* Always set breakpoint for NPC. */ - - remote_insert_breakpoint(remote_next_pc); - remove_thisbp_next_pc = remote_next_pc; - - /* printf ("set break at %x\n",remote_next_pc); */ - - br = isbranch (remote_pc, &target); - - if (br == bicca) - { - /* Conditional annulled branch will either end up at - npc (if taken) or at npc+4 (if not taken). - Trap npc+4. */ - remote_insert_breakpoint(npc4); - remove_thisbp_target = npc4; - } - else if (br == baa && target != remote_next_pc) - { - /* Unconditional annulled branch will always end up at - the target. */ - remote_insert_breakpoint(target); - remove_thisbp_target = target; - } -} - - - - -/* read many words of memory */ -long -remote_read_many(memaddr, myaddr, len) - CORE_ADDR memaddr; - unsigned char *myaddr; - int len; -{ -#define BLOCKSIZE 1024 - static int max_number_of_blocks = 24; - - char buf[PBUFSIZ]; - char buf2[PBUFSIZ]; - int i; - unsigned long *p; -/* Command describes registers byte by byte, - each byte encoded as two hex characters. */ - - len = min(len, max_number_of_blocks * BLOCKSIZE); - - sprintf(buf, "%x %x do i @ . cr 4 +loop", memaddr + len, memaddr); - putpkt(buf); - getline(buf2, PBUFSIZ, LONGTIMEOUT); /* I don't care */ - - p = (unsigned long *) myaddr; - for (i = 0; i < len; i += 4, p++) - { - extern int InspectIt; - - if (!InspectIt && ((i % BLOCKSIZE) == 0)) - fprintf(stderr, "+"); /* let 'em know that we are working */ - switch (getline(buf2, PBUFSIZ, LONGTIMEOUT)) - { - default: - case GL_PROMLINE: - case GL_READING: - case GL_OK: - case GL_OVERRUN: - case GL_TIMEOUT: - case GL_BLANKLINE: - /* resync and retry */ - max_number_of_blocks = max(1, i / BLOCKSIZE); - fprintf(stderr, "-"); /* let 'em know that we are working */ - - if (kiodebug & KD_BLOCKTRANSFER) - fprintf(stderr, "failed read_many %d %d/%d (%s)\n", - max_number_of_blocks, i, len, buf2); - sendbreak(); - return remote_read_many(memaddr, myaddr, len); - case GL_EXCEPTION: - return -i; - case GL_SUCCESS: - sscanf(buf2, "%x\n", p); - break; - } - } - if (kiodebug & KD_BLOCKTRANSFER) - fprintf(stderr, "success read_many %d %d/%d (%s)\n", max_number_of_blocks, - i, len, buf2); - return i; -} -/* - * allow the user to type directly to the prom ! - */ -prom_command() -{ - int readUser, readProm; - - user_terminal_raw(); - fprintf(stderr, "entering prom mode...\n"); - while (1) - { - doselect(&readUser, &readProm); - if (readUser) - if (shuffleFromUserToProm()) - { - fprintf(stderr, "exiting prom mode\n"); - user_terminal_restore(); - return; - } - if (readProm) - fprintf(stderr, "%c", readCharFromProm ()); - } -} -static char *boot_set_msg = "boot needs a string in quotes of the form \"boot vmunix\" "; -static char *baud_set_msg = "baud rate should be of the form \"set baud=9600\""; - -static void -set_boot (arg, from_tty) - char *arg; - int from_tty; -{ - int h, i; - - if (!arg) - { - print_boot_cmd(); - error_no_arg (boot_set_msg); - } - - arg = tilde_expand (arg); - make_cleanup (free, arg); - - i = strlen (arg) - 1; - - free (boot_cmd); - - h = 0; - while (*arg && h < i && (arg[h] == ' ' || arg[h] == '\t')) - { - h++; - arg++; - } - while (i > 0 && (arg[i] == ' ' || arg[i] == '\t')) - i--; - - if (h >= i || !*arg || arg[h] != '"' || arg[i] != '"') - error (boot_set_msg); - else - { - boot_cmd = savestring (++arg, i); - boot_cmd[i - 1] = '\0'; - } - if (from_tty) - print_boot_cmd(); -} - -static int bauds[] = { - 0, 50, 75, 110, 134, 150, 200, 300, 600, - 1200, 1800, 2400, 4800, 9600, 19200, 38400, -1 -}; - - -static int convert_to_baud_B(n) - int n; -{ - register int *p; - - for (p = bauds; *p != -1; p++) - if (*p != 0 && *p == n) - return (p - bauds); - return (NULL); -} - -static void print_acceptable_bauds() -{ - register int *p; - - for (p = bauds; *p != -1; p++) - if (*p != 0 ) - fprintf(stderr, "%d\n", *p); -} - -static void print_baud() -{ -fprintf(stderr, "the baud rate is now %d\n", bauds[baud_rate]); -} - -static void -set_baud (arg, from_tty) - char *arg; - int from_tty; -{ - int temp_baud_rate; - - if (!arg) - { - print_baud(); - print_acceptable_bauds(); - error_no_arg (baud_set_msg); - return; - } - - while (*arg && !isdigit(*arg)) - arg++; - - if (*arg && (temp_baud_rate = convert_to_baud_B(atoi(arg))) != NULL) - { - baud_rate = temp_baud_rate; - if (remote_debugging) - setup_remote(); - } - else - { - fprintf(stderr, "bad baud rate %s, acceptable values are\n", arg); - print_acceptable_bauds(); - } - - print_baud(); -} - - - - -void -_initialize_remote() -{ -/* Chain containing all defined set subcommands */ - -extern struct cmd_list_element *setlist; - - - add_com ("prom", class_obscure, prom_command, - "Conduct a dialogue directly with the prom. \ -only useful after an attach\n\ -Terminate by typing ~."); - - add_cmd ("boot_cmd", class_support, set_boot, boot_set_msg, &setlist); - - add_cmd ("baud", class_support, set_baud, baud_set_msg, &setlist); - - set_boot ("\"boot nucleus -d\"", 0); - } - - -/* Store the remote registers from the contents of the block REGS. */ - -void -remote_store_registers (registers) - char *registers; -{ - CORE_ADDR core; - struct regs inferior_registers; - - core = parse_and_eval_address("breakpoint_regs"); - - bcopy (®isters[REGISTER_BYTE (1)], - &inferior_registers.r_g1, 15 * 4); - - inferior_registers.r_ps = - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; - inferior_registers.r_pc = - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; - inferior_registers.r_npc = - *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)]; - inferior_registers.r_y = - *(int *)®isters[REGISTER_BYTE (Y_REGNUM)]; - - remote_write_inferior_memory (*(int *)®isters[REGISTER_BYTE (SP_REGNUM)], - ®isters[REGISTER_BYTE (16)], - 16*4); - remote_write_inferior_memory (core, - &inferior_registers, - sizeof(inferior_registers)); -} - - - -/* we have stopped. do some cleanup */ -remote_cleanup_after_stop() -{ - if (remove_thisbp_next_pc) - { - remote_remove_breakpoint (remove_thisbp_next_pc); - remove_thisbp_next_pc = 0; - } - if (remove_thisbp_target) - { - remote_remove_breakpoint (remove_thisbp_target); - remove_thisbp_target = 0; - } - user_terminal_restore(); - - one_stepped = remote_set_one_stepped; -} diff --git a/gdb/state.c b/gdb/state.c index 64f86d6..e69de29 100644 --- a/gdb/state.c +++ b/gdb/state.c @@ -1,775 +0,0 @@ -/* Support for dumping and reloading various pieces of GDB's internal state. - Copyright 1992 Free Software Foundation, Inc. - Contributed by Cygnus Support, using pieces from other GDB modules. - -This file is part of GDB. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This file provides support for dumping and then later reloading various - portions of gdb's internal state. It was originally implemented to - support a need for mapping in an image of gdb's symbol table from an - external file, where this image was created by an external program, such - as an incremental linker. However, it was generalized to enable future - support for dumping and reloading various other useful pieces of gdb's - internal state. - - State files have a fairly simple form which is intended to be easily - extensible. The basic format is: - - <file-header> <state-data> <form-tree> - - Where: - - file-header A simple file-header containing a magic number - so that gdb (and other readers) can quickly - determine what kind of file this is, and a file - offset to the root of the form-tree. - - state-data The "raw" state-data that is referenced by nodes - in the form-tree. - - form-tree A tree of arbitrarily sized nodes containing - information about gdb's internal state, and - possibly referencing data in the state-data section - of the file. Resembles DWARF in some respects. - - When writing a state file, a hole is left for the file-header at the - beginning of the file, the state data is written immediately after the - file header (while storing the file offsets and sizes back into the - internal form-tree along the way), the form-tree itself is written - at the end of the file, and then the file header is written by seeking - back to the beginning of the file. This order is required because - the form tree contains file offsets and sizes in the state data portion - of the file, and the file header contains the file offset to the start - of the form tree. - - Readers simply open the file, validate the magic number, seek to the - root of the form-tree, and walk the tree looking for the information that - they are interested in (and ignoring things that they aren't, or don't - understand). - - */ - - -#include "defs.h" -#include "symtab.h" -#include "bfd.h" -#include "symfile.h" -#include "state.h" - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -/* Inside the state file, the form-tree consists of a series of - form-tree entries (FTE's). The parent/child/sibling relationships - are implied by the ordering and by an explicit sibling reference - in FTE's that have siblings. - - Specifically, given two sequential FTE's, say A and B, if B immediately - follows A, and A does not have a sibling reference to B, then B is - the first child of A. Otherwise B must be a sibling of A and A must - have a sibling reference for it. - - Each FTE is simply an array of long integers, with at least three - members. This form was chosen over a packed data form for simplicity - in access, not having to worry about the relative sizes of the different - integers (short, int, long), and not having to worry about alignment - constraints. Also in the name of simplicity, every FTE has a sibling - reference slot reserved for it, even if there are no siblings. - - The first value in an FTE is the size of the FTE in bytes, including - the size value itself. The second entry contains a tag which indicates - the type of the FTE. The third entry is a sibling reference, which either - refers to a valid sibling node or is zero. Following is zero or more - attributes, each of which consists of one or more long values. */ - -/* Tag names and codes. */ - -#define TAG_padding 0x0000 /* Padding */ -#define TAG_objfile 0x0001 /* Dumped objfile */ - -/* Form names, codes, and macros. */ - -#define FORM_ABSREF 0x01 /* Next long is absolute file offset */ -#define FORM_RELREF 0x02 /* Next long is relative file offset */ -#define FORM_IVAL 0x03 /* Next long is int value */ -#define FORM_ADDR 0x04 /* Next long is mem addr */ - -#define FORM_MASK 0xFF -#define FORM_X(atr) ((atr) & FORM_MASK) - -/* Attribute names and codes. */ - -#define AT_sibling (0x0100 | FORM_RELREF) /* Reference to sibling node */ -#define AT_name (0x0200 | FORM_ABSREF) /* Reference to a string */ -#define AT_offset (0x0300 | FORM_ABSREF) /* Reference to generic data */ -#define AT_size (0x0400 | FORM_IVAL) -#define AT_addr (0x0500 | FORM_ADDR) -#define AT_aux_addr (0x0600 | FORM_ADDR) - -/* */ - -static void -load_symbols PARAMS ((FILE *)); - -static void -dump_state_command PARAMS ((char *, int)); - -static void -load_state_command PARAMS ((char *, int)); - -#ifdef HAVE_MMAP - -static void -write_header PARAMS ((sfd *)); - -static void -write_formtree PARAMS ((sfd *)); - -static void -write_objfile_state PARAMS ((sfd *)); - -static void -free_subtree PARAMS ((struct formnode *)); - -static void -size_subtree PARAMS ((struct formnode *)); - -#endif - -struct formnode *formtree = NULL; - -/* ARGSUSED */ -static void -load_symbols (statefile) - FILE *statefile; -{ - -#if 0 - /* Discard old symbols. FIXME: This is essentially symbol_file_command's - body when there is no name. Make it a common function that is - called from each place. */ - - if (symfile_objfile) - { - free_objfile (symfile_objfile); - } - symfile_objfile = NULL; -#endif - -#if 0 && defined (HAVE_MMAP) - if (mtop > mbase) - { - warning ("internal error: mbase (%08x) != mtop (%08x)", - mbase, mtop); - munmap (mbase, mtop - mbase); - } -#endif /* HAVE_MMAP */ - - /* Getting new symbols may change our opinion about what is frameless. */ - - reinit_frame_cache (); - -} - -#ifdef HAVE_MMAP - -/* Allocate a form node */ - -static struct formnode * -alloc_formnode () -{ - struct formnode *fnp; - fnp = (struct formnode *) xmalloc (sizeof (struct formnode)); - (void) memset (fnp, 0, sizeof (struct formnode)); - fnp -> sibling = formtree; - formtree = fnp; - return (fnp); -} - -/* Recursively walk a form-tree from the specified node, freeing - nodes from the bottom up. The concept is pretty simple, just free - all the child nodes, then all the sibling nodes, then the node - itself. */ - -static void -free_subtree (fnp) - struct formnode *fnp; -{ - if (fnp != NULL) - { - free_subtree (fnp -> child); - free_subtree (fnp -> sibling); - if (fnp -> nodedata != NULL) - { - free (fnp -> nodedata); - } - free (fnp); - } -} - -/* Recursively walk a form-tree from the specified node, computing the - size of each subtree from the bottom up. - - At each node, the file space that will be consumed by the subtree - rooted in that node is the sum of all the subtrees rooted in each - child node plus the size of the node itself. - - Thus for each node, we size the child subtrees, add to that our - size, contribute this size towards the size of any parent node, and - then ask any of our siblings to do the same. - - Also, once we know the size of any subtree rooted at this node, we - can initialize the offset to the sibling node (if any). - - Since every form-tree node must have valid nodedata at this point, - we detect and report a warning for any node that doesn't. */ - -static void -size_subtree (fnp) - struct formnode *fnp; -{ - long *lp; - - if (fnp != NULL) - { - if (fnp -> nodedata == NULL) - { - warning ("internal error -- empty form node"); - } - else - { - size_subtree (fnp -> child); - fnp -> treesize += *(long *) fnp -> nodedata; - if (fnp -> parent != NULL) - { - fnp -> parent -> treesize += fnp -> treesize; - } - if (fnp -> sibling) - { - size_subtree (fnp -> sibling); - lp = (long *) (fnp -> nodedata + 2 * sizeof (long)); - *lp = fnp -> treesize; - } - } - } -} - -/* Recursively walk a form-tree from the specified node, writing - nodes from the top down. */ - -static void -write_subtree (fnp, asfd) - struct formnode *fnp; - sfd *asfd; -{ - if (fnp != NULL) - { - if (fnp -> nodedata != NULL) - { - fwrite (fnp -> nodedata, *(long *) fnp -> nodedata, 1, asfd -> fp); - } - write_subtree (fnp -> child, asfd); - write_subtree (fnp -> sibling, asfd); - } -} - -/* Free the entire current formtree. Called via do_cleanups, regardless - of whether there is an error or not. */ - -static void -free_formtree () -{ - free_subtree (formtree); - formtree = NULL; -} - -/* Write out the file header. Generally this is done last, even though - it is located at the start of the file, since we need to have file - offset to where the annotated form tree was written, and it's size. */ - -static void -write_header (asfd) - sfd *asfd; -{ - fseek (asfd -> fp, 0L, SEEK_SET); - fwrite ((char *) &asfd -> hdr, sizeof (asfd -> hdr), 1, asfd -> fp); -} - -/* Write out the annotated form tree. We should already have written out - the state data, and noted the file offsets and sizes in each node of - the form tree that references part of the state data. - - The form tree can be written anywhere in the file where there is room - for it. Since there is always room at the end of the file, we write - it there. We also need to record the file offset to the start of the - form tree, and it's size, for future use when writing the file header. - - In order to compute the sibling references, we need to know, at - each node, how much space will be consumed when all of that node's - children nodes have been written. Thus we walk the tree, computing - the sizes of the subtrees from the bottom up. At any node, the - offset from the start of that node to the start of the sibling node - is simply the size of the node plus the size of the subtree rooted - in that node. */ - -static void -write_formtree (asfd) - sfd *asfd; -{ - size_subtree (formtree); - fseek (asfd -> fp, 0L, SEEK_END); - asfd -> hdr.sf_ftoff = ftell (asfd -> fp); - write_subtree (formtree, asfd); - asfd -> hdr.sf_ftsize = ftell (asfd -> fp) - asfd -> hdr.sf_ftoff; -} - -/* Note that we currently only support having one objfile with dumpable - state. */ - -static void -write_objfile_state (asfd) - sfd *asfd; -{ - struct objfile *objfile; - struct formnode *fnp; - PTR base; - PTR breakval; - long *lp; - unsigned int ftesize; - long ftebuf[64]; - long foffset; - - /* First walk through the objfile list looking for the first objfile - that is dumpable. */ - - for (objfile = object_files; objfile != NULL; objfile = objfile -> next) - { - if (objfile -> flags & OBJF_DUMPABLE) - { - break; - } - } - - if (objfile == NULL) - { - warning ("no dumpable objfile was found"); - } - else - { - fnp = alloc_formnode (); - lp = ftebuf; - - lp++; /* Skip FTE size slot, filled in at the end. */ - *lp++ = TAG_objfile; /* This is an objfile FTE */ - *lp++ = 0; /* Zero the sibling reference slot. */ - - /* Build an AT_name attribute for the objfile's name, and write - the name into the state data. */ - - *lp++ = AT_name; - *lp++ = (long) ftell (asfd -> fp); - fwrite (objfile -> name, strlen (objfile -> name) + 1, 1, asfd -> fp); - - /* Build an AT_addr attribute for the virtual address to which the - objfile data is mapped (and needs to be remapped when read in). */ - - base = mmap_base (); - *lp++ = AT_addr; - *lp++ = (long) base; - - /* Build an AT_aux_addr attribute for the address of the objfile - structure itself, within the dumpable data. When we read the objfile - back in, we use this address as the pointer the "struct objfile". */ - - *lp++ = AT_aux_addr; - *lp++ = (long) objfile; - - /* Reposition in state file to next paging boundry so we can mmap the - dumpable objfile data when we reload it. */ - - foffset = (long) mmap_page_align ((PTR) ftell (asfd -> fp)); - fseek (asfd -> fp, foffset, SEEK_SET); - - /* Build an AT_offset attribute for the offset in the state file to - the start of the dumped objfile data. */ - - *lp++ = AT_offset; - *lp++ = (long) ftell (asfd -> fp); - - /* Build an AT_size attribute for the size of the dumped objfile data. */ - - breakval = mmap_sbrk (0); - *lp++ = AT_size; - *lp++ = breakval - base; - - /* Write the dumpable data. */ - - fwrite ((char *) base, breakval - base, 1, asfd -> fp); - - /* Now finish up the FTE by filling in the size slot based on - how much of the ftebuf we have used, allocate some memory for - it hung off the form tree node, and copy it there. */ - - ftebuf[0] = (lp - ftebuf) * sizeof (ftebuf[0]); - fnp -> nodedata = (char *) xmalloc (ftebuf[0]); - memcpy (fnp -> nodedata, ftebuf, ftebuf[0]); - } -} - -static void -load_state_command (arg_string, from_tty) - char *arg_string; - int from_tty; -{ - char *filename; - char **argv; - FILE *fp; - struct cleanup *cleanups; - - dont_repeat (); - - if (arg_string == NULL) - { - error ("load-state takes a file name and optional state specifiers"); - } - else if ((argv = buildargv (arg_string)) == NULL) - { - fatal ("virtual memory exhausted.", 0); - } - cleanups = make_cleanup (freeargv, argv); - - filename = tilde_expand (*argv); - make_cleanup (free, filename); - - if ((fp = fopen (filename, FOPEN_RB)) == NULL) - { - perror_with_name (filename); - } - make_cleanup (fclose, fp); - immediate_quit++; - - while (*++argv != NULL) - { - if (STREQ (*argv, "symbols")) - { - if (from_tty - && !query ("load symbol table state from file \"%s\"? ", - filename)) - { - error ("Not confirmed."); - } - load_symbols (fp); - } - else - { - error ("unknown state specifier '%s'", *argv); - } - } - immediate_quit--; - do_cleanups (cleanups); -} - -/* ARGSUSED */ -static void -dump_state_command (arg_string, from_tty) - char *arg_string; - int from_tty; -{ - char *filename; - char **argv; - sfd *asfd; - struct cleanup *cleanups; - - dont_repeat (); - - if (arg_string == NULL) - { - error ("dump-state takes a file name and state specifiers"); - } - else if ((argv = buildargv (arg_string)) == NULL) - { - fatal ("virtual memory exhausted.", 0); - } - cleanups = make_cleanup (freeargv, argv); - - filename = tilde_expand (*argv); - make_cleanup (free, filename); - - /* Now attempt to create a fresh state file. */ - - if ((asfd = sfd_fopen (filename, FOPEN_WB)) == NULL) - { - perror_with_name (filename); - } - make_cleanup (sfd_fclose, asfd); - make_cleanup (free_formtree, NULL); - immediate_quit++; - - /* Now that we have an open and initialized state file, seek to the - proper offset to start writing state data and the process the - arguments. For each argument, write the state data and initialize - a form-tree node for each piece of state data. */ - - fseek (asfd -> fp, sizeof (sf_hdr), SEEK_SET); - while (*++argv != NULL) - { - if (STREQ (*argv, "objfile")) - { - write_objfile_state (asfd); - } - else - { - error ("unknown state specifier '%s'", *argv); - } - - } - - /* We have written any state data. All that is left to do now is - write the form-tree and the file header. */ - - write_formtree (asfd); - write_header (asfd); - - immediate_quit--; - do_cleanups (cleanups); -} - -static char * -find_fte_by_walk (thisfte, endfte, tag) - char *thisfte; - char *endfte; - long tag; -{ - char *found = NULL; - char *nextfte; - long thistag; - long thissize; - long siboffset; - - while (thisfte < endfte) - { - if ((thistag = *(long *)(thisfte + sizeof (long))) == tag) - { - found = thisfte; - break; - } - else - { - thissize = *(long *)(thisfte); - siboffset = *(long *)(thisfte + (2 * sizeof (long))); - nextfte = thisfte + (siboffset != 0 ? siboffset : thissize); - found = find_fte_by_walk (thisfte + thissize, nextfte, tag); - thisfte = nextfte; - } - } - return (found); -} - -/* Walk the form-tree looking for a specific FTE type. Returns the first - one found that matches the specified tag. */ - -static char * -find_fte (asfd, tag) - sfd *asfd; - long tag; -{ - char *ftbase; - char *ftend; - char *ftep; - char *found = NULL; - - if (fseek (asfd -> fp, asfd -> hdr.sf_ftoff, SEEK_SET) == 0) - { - ftbase = xmalloc (asfd -> hdr.sf_ftsize); - ftend = ftbase + asfd -> hdr.sf_ftsize; - if (fread (ftbase, asfd -> hdr.sf_ftsize, 1, asfd -> fp) == 1) - { - ftep = find_fte_by_walk (ftbase, ftend, tag); - if (ftep != NULL) - { - found = xmalloc (*(long *)ftep); - memcpy (found, ftep, (int) *(long *)ftep); - } - } - free (ftbase); - } - return (found); -} - -struct objfile * -objfile_from_statefile (asfd) - sfd *asfd; -{ - struct objfile *objfile = NULL; - char *ftep; - long *thisattr; - long *endattr; - PTR base; - long foffset; - long mapsize; - - ftep = find_fte (asfd, TAG_objfile); - thisattr = (long *) (ftep + 3 * sizeof (long)); - endattr = (long *) (ftep + *(long *)ftep); - while (thisattr < endattr) - { - switch (*thisattr++) - { - case AT_name: - /* Ignore for now */ - thisattr++; - break; - case AT_addr: - base = (PTR) *thisattr++; - break; - case AT_aux_addr: - objfile = (struct objfile *) *thisattr++; - break; - case AT_offset: - foffset = *thisattr++; - break; - case AT_size: - mapsize = *thisattr++; - break; - } - } - if (mmap_remap (base, mapsize, (int) fileno (asfd -> fp), foffset) != base) - { - print_sys_errmsg (asfd -> filename, errno); - error ("mapping failed"); - } - - return (objfile); -} - -#else - -struct objfile * -objfile_from_statefile (asfd) - sfd *asfd; -{ - error ("this version of gdb doesn't support reloading symtabs from state files"); -} - -#endif /* HAVE_MMAP */ - -/* Close a state file, freeing all memory that was used by the state - file descriptor, closing the raw file pointer, etc. */ - -void -sfd_fclose (asfd) - sfd *asfd; -{ - if (asfd != NULL) - { - if (asfd -> fp != NULL) - { - fclose (asfd -> fp); - } - if (asfd -> filename != NULL) - { - free (asfd -> filename); - } - free (asfd); - } -} - -/* Given the name of a possible statefile, and flags to use to open it, - try to open the file and prepare it for use. - - If the flags contain 'r', then we want to read an existing state - file, so attempt to read in the state file header and determine if this - is a valid state file. If not, return NULL. - - Returns a pointer to a properly initialized state file descriptor if - successful. */ - -sfd * -sfd_fopen (name, flags) - char *name; - char *flags; -{ - int success = 0; - sfd *asfd; - - asfd = (sfd *) xmalloc (sizeof (sfd)); - (void) memset (asfd, 0, sizeof (sfd)); - asfd -> filename = xmalloc (strlen (name) + 1); - (void) strcpy (asfd -> filename, name); - - if ((asfd -> fp = fopen (asfd -> filename, flags)) != NULL) - { - /* We have the file, now see if we are reading an existing file - or writing to a new file. We don't currently support "rw". */ - if (strchr (flags, 'r') != NULL) - { - if (fread ((char *) &asfd -> hdr, sizeof (asfd -> hdr), 1, - asfd -> fp) == 1) - { - if (SF_GOOD_MAGIC (asfd)) - { - success = 1; - } - } - } - else - { - /* This is a new state file. Initialize various things. */ - asfd -> hdr.sf_mag0 = SF_MAG0; - asfd -> hdr.sf_mag1 = SF_MAG1; - asfd -> hdr.sf_mag2 = SF_MAG2; - asfd -> hdr.sf_mag3 = SF_MAG3; - success = 1; - } - } - - if (!success) - { - sfd_fclose (asfd); - asfd = NULL; - } - return (asfd); - -} - - -void -_initialize_state () -{ - -#ifdef HAVE_MMAP - - add_com ("load-state", class_support, load_state_command, - "Load some saved gdb state from FILE.\n\ -Select and load some portion of gdb's saved state from the specified file.\n\ -The dump-state command may be used to save various portions of gdb's\n\ -internal state."); - - add_com ("dump-state", class_support, dump_state_command, - "Dump some of gdb's state to FILE.\n\ -Select and dump some portion of gdb's internal state to the specified file.\n\ -The load-state command may be used to reload various portions of gdb's\n\ -internal state from the file."); - -#endif /* HAVE_MMAP */ - -} diff --git a/gdb/state.h b/gdb/state.h index 9a8f972..e69de29 100644 --- a/gdb/state.h +++ b/gdb/state.h @@ -1,85 +0,0 @@ -/* Support for dumping and reloading various pieces of GDB's internal state. - Copyright 1992 Free Software Foundation, Inc. - Contributed by Cygnus Support, using pieces from other GDB modules. - -This file is part of GDB. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This file provides definitions used for reading and writing gdb - state files. State files have a fairly simple form which is intended - to be easily extensible. See state.c for further documentation. */ - -#if !defined (_STATE_H) -#define _STATE_H - -/* State file-header */ - -typedef struct { - unsigned char sf_mag0; /* Magic number byte 0 */ - unsigned char sf_mag1; /* Magic number byte 1 */ - unsigned char sf_mag2; /* Magic number byte 2 */ - unsigned char sf_mag3; /* Magic number byte 3 */ - unsigned long sf_ftoff; /* File offset to start of form-tree */ - unsigned long sf_ftsize; /* Size of the form-tree, in bytes */ -} sf_hdr; - - -#define SF_MAG0 'g' /* Magic number byte 0 value */ -#define SF_MAG1 'd' /* Magic number byte 1 value */ -#define SF_MAG2 'b' /* Magic number byte 2 value */ -#define SF_MAG3 '\000' /* Magic number byte 3 value */ - -#define SF_GOOD_MAGIC(asfd) ((asfd) -> hdr.sf_mag0 == SF_MAG0 && \ - (asfd) -> hdr.sf_mag1 == SF_MAG1 && \ - (asfd) -> hdr.sf_mag2 == SF_MAG2 && \ - (asfd) -> hdr.sf_mag3 == SF_MAG3) - -/* The internal form-tree is formed from nodes that contain pointers - to the first sibling, the first child, a backpointer to the parent, - and a pointer to the actual data for the node. This allows all - tree nodes to have the same sized structure, but support variable - numbers of child nodes per parent node. The backpointer for the - parent is required for simplier tree walks. */ - -struct formnode -{ - struct formnode *sibling; /* Pointer to first sibling */ - struct formnode *child; /* Pointer to first child */ - struct formnode *parent; /* Backpointer to parent */ - char *nodedata; /* Pointer to the nodes data */ - unsigned long treesize; /* Size of subtree rooted here */ -}; - -/* A state file descriptor is defined by the following structure. */ - -typedef struct -{ - char *filename; /* Full pathname of the state file */ - FILE *fp; /* Open file pointer for the state file */ - sf_hdr hdr; /* Copy of the state file-header */ - char *formtree; /* Pointer to in-memory copy of form-tree */ -} sfd; - -extern sfd * -sfd_fopen PARAMS ((char *, char *)); - -extern void -sfd_fclose PARAMS ((sfd *)); - -extern struct objfile * -objfile_from_statefile PARAMS ((sfd *)); - -#endif /* !defined (_STATE_H) */ |