From: Stu Grossman Date: Tue, 15 Sep 1992 06:27:18 +0000 (+0000) Subject: * breakpoint.c, core.c, exec.c, language.c, main.c, printcmd.c, X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a8e033f2a2dca7a104e66ab1351c46fc2c2baf03;p=binutils-gdb.git * breakpoint.c, core.c, exec.c, language.c, main.c, printcmd.c, symfile.c, target.c, valprint.c: Use _filtered form of *printf. defs.h, utils.c: Make vfprintf_filtered global. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f849f44f9b0..8cf1319cf13 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ Mon Sep 14 19:20:43 1992 Stu Grossman (grossman at cygnus.com) + * breakpoint.c, core.c, exec.c, language.c, main.c, printcmd.c, + symfile.c, target.c, valprint.c: Use _filtered form of *printf. + defs.h, utils.c: Make vfprintf_filtered global. + * energize.c (send_location): New routine to consolidate all places where we must notify kernel of where the given pc is. (cplus_demangle): Put single-quotes around demangled names. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 6ae795bb2b8..95e26047b93 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -445,8 +445,8 @@ insert_breakpoints () b->enable = disabled; if (!disabled_breaks) { - fprintf (stderr, - "Cannot insert breakpoint %d:\n", b->number); + fprintf_filtered (stderr, "Cannot insert breakpoint %d:\n", + b->number); printf_filtered ("Disabling shared library breakpoints:\n"); } disabled_breaks = 1; @@ -455,10 +455,11 @@ insert_breakpoints () else #endif { - fprintf (stderr, "Cannot insert breakpoint %d:\n", b->number); + fprintf_filtered (stderr, "Cannot insert breakpoint %d:\n", + b->number); #ifdef ONE_PROCESS_WRITETEXT - fprintf (stderr, - "The same program may be running in another process.\n"); + fprintf_filtered (stderr, + "The same program may be running in another process.\n"); #endif memory_error (val, b->address); /* which bombs us out */ } @@ -478,7 +479,7 @@ remove_breakpoints () int val; #ifdef BREAKPOINT_DEBUG - printf ("Removing breakpoints.\n"); + printf_filtered ("Removing breakpoints.\n"); #endif /* BREAKPOINT_DEBUG */ ALL_BREAKPOINTS (b) @@ -489,12 +490,12 @@ remove_breakpoints () 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])); + 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 */ } @@ -1141,17 +1142,18 @@ describe_other_breakpoints (pc) others++; if (others > 0) { - printf ("Note: breakpoint%s ", (others > 1) ? "s" : ""); + printf_filtered ("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_filtered ("%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)); + printf_filtered ("also set at pc %s.\n", local_hex_string(pc)); } } @@ -1550,8 +1552,8 @@ break_command_1 (arg, tempflag, from_tty) if (sals.nelts > 1) { - printf ("Multiple breakpoints were set.\n"); - printf ("Use the \"delete\" command to delete unwanted breakpoints.\n"); + printf_filtered ("Multiple breakpoints were set.\n"); + printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n"); } free ((PTR)sals.sals); } @@ -1769,7 +1771,7 @@ map_catch_names (args, function) goto win; } #endif - printf ("No catch clause for exception %s.\n", p); + printf_filtered ("No catch clause for exception %s.\n", p); #if 0 win: #endif @@ -1970,16 +1972,18 @@ catch_command_1 (arg, tempflag, from_tty) b->enable = enabled; b->disposition = tempflag ? delete : donttouch; - printf ("Breakpoint %d at %s", b->number, local_hex_string(b->address)); + printf_filtered ("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"); + printf_filtered (": file %s, line %d.", + b->symtab->filename, b->line_number); + printf_filtered ("\n"); } if (sals.nelts > 1) { - printf ("Multiple breakpoints were set.\n"); - printf ("Use the \"delete\" command to delete unwanted breakpoints.\n"); + printf_filtered ("Multiple breakpoints were set.\n"); + printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n"); } free ((PTR)sals.sals); } @@ -2086,10 +2090,11 @@ clear_command (arg, from_tty) } if (found->next) from_tty = 1; /* Always report if deleted more than one */ - if (from_tty) printf ("Deleted breakpoint%s ", found->next ? "s" : ""); + if (from_tty) printf_filtered ("Deleted breakpoint%s ", + found->next ? "s" : ""); while (found) { - if (from_tty) printf ("%d ", found->number); + if (from_tty) printf_filtered ("%d ", found->number); b1 = found->next; delete_breakpoint (found); found = b1; @@ -2144,7 +2149,7 @@ delete_breakpoint (bpt) free ((PTR)bpt->addr_string); if (xgdb_verbose && bpt->type == bp_breakpoint) - printf ("breakpoint #%d deleted\n", bpt->number); + 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. */ @@ -2257,19 +2262,14 @@ breakpoint_re_set () /* If we have no current source symtab, and we have any breakpoints, go through the work of making a source context. */ - if (current_source_symtab == NULL) + if (current_source_symtab == NULL && breakpoint_chain != 0) { - ALL_BREAKPOINTS (b) - { - select_source_symtab (NULL); - break; /* We only care if there are any, and - don't need to do it N times. */ - } + select_source_symtab (NULL); } ALL_BREAKPOINTS_SAFE (b, temp) { - sprintf (message, message1, b->number); /* Format possible error msg */ + printf_filtered (message, message1, b->number); /* Format possible error msg */ catch_errors (breakpoint_re_set_one, (char *) b, message); } @@ -2382,7 +2382,7 @@ map_breakpoint_numbers (args, function) function (b); goto win; } - printf ("No breakpoint number %d.\n", num); + printf_filtered ("No breakpoint number %d.\n", num); win: p = p1; } @@ -2395,7 +2395,7 @@ enable_breakpoint (bpt) bpt->enable = enabled; if (xgdb_verbose && bpt->type == bp_breakpoint) - printf ("breakpoint #%d enabled\n", bpt->number); + printf_filtered ("breakpoint #%d enabled\n", bpt->number); check_duplicates (bpt->address); if (bpt->type == bp_watchpoint) diff --git a/gdb/core.c b/gdb/core.c index 9c7d27ea6a8..032ddb929de 100644 --- a/gdb/core.c +++ b/gdb/core.c @@ -167,11 +167,11 @@ core_open (filename, from_tty) p = bfd_core_file_failing_command (core_bfd); if (p) - printf ("Core was generated by `%s'.\n", p); + printf_filtered ("Core was generated by `%s'.\n", p); siggy = bfd_core_file_failing_signal (core_bfd); if (siggy > 0) - printf ("Program terminated with signal %d, %s.\n", siggy, + printf_filtered ("Program terminated with signal %d, %s.\n", siggy, safe_strsignal (siggy)); if (ontop) { @@ -204,7 +204,7 @@ core_detach (args, from_tty) error ("Too many arguments"); unpush_target (&core_ops); if (from_tty) - printf ("No core file now.\n"); + printf_filtered ("No core file now.\n"); } /* Backward compatability with old way of specifying core files. */ @@ -405,7 +405,7 @@ get_core_registers (regno) else { cant: - fprintf (stderr, "Couldn't fetch registers from core file: %s\n", + fprintf_filtered (stderr, "Couldn't fetch registers from core file: %s\n", bfd_errmsg (bfd_error)); } @@ -422,7 +422,7 @@ cant: } else { - fprintf (stderr, "Couldn't fetch register set 2 from core file: %s\n", + fprintf_filtered (stderr, "Couldn't fetch register set 2 from core file: %s\n", bfd_errmsg (bfd_error)); } } diff --git a/gdb/defs.h b/gdb/defs.h index d093646475e..a685675e03d 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -194,12 +194,21 @@ fputs_filtered PARAMS ((const char *, FILE *)); extern void puts_filtered PARAMS ((char *)); +extern void +vfprintf_filtered PARAMS ((FILE *, char *, va_list)); + extern void fprintf_filtered (); +extern void +fprintfi_filtered (); + extern void printf_filtered (); +extern void +printfi_filtered (); + extern void print_spaces PARAMS ((int, FILE *)); @@ -584,7 +593,7 @@ extern char * basename PARAMS ((char *)); extern char * -getenv PARAMS ((CONST char *)); +getenv PARAMS ((const char *)); extern char ** buildargv PARAMS ((char *)); diff --git a/gdb/exec.c b/gdb/exec.c index eb6a85a12ce..79b07e499e5 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -35,6 +35,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include +#ifndef O_BINARY +#define O_BINARY 0 +#endif /* Prototypes for local functions */ @@ -135,7 +138,7 @@ exec_file_command (args, from_tty) make_cleanup (free, filename); scratch_chan = openp (getenv ("PATH"), 1, filename, - write_files? O_RDWR: O_RDONLY, 0, + write_files? O_RDWR|O_BINARY: O_RDONLY|O_BINARY, 0, &scratch_pathname); if (scratch_chan < 0) perror_with_name (filename); @@ -177,7 +180,7 @@ exec_file_command (args, from_tty) (*exec_file_display_hook) (filename); } else if (from_tty) - printf ("No exec file now.\n"); + printf_filtered ("No exec file now.\n"); } /* Set both the exec file and the symbol file, in one command. @@ -233,8 +236,6 @@ build_section_table (some_bfd, start, end) unsigned count; count = bfd_count_sections (some_bfd); - if (count == 0) - abort(); /* return 1? */ if (*start) free ((PTR)*start); *start = (struct section_table *) xmalloc (count * sizeof (**start)); diff --git a/gdb/language.c b/gdb/language.c index 2ecb1502264..32ed779cd7e 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -156,7 +156,7 @@ set_language_command (ignore, from_tty) /* FIXME -- do this from the list, with HELP. */ if (!language || !language[0]) { - printf("The currently understood settings are:\n\n\ + printf_filtered ("The currently understood settings are:\n\n\ local or auto Automatic setting based on source file\n\ c Use the C language\n\ c++ Use the C++ language\n\ @@ -204,7 +204,7 @@ show_type_command(ignore, from_tty) int from_tty; { if (type_check != current_language->la_type_check) - printf( + printf_filtered( "Warning: the current type check setting does not match the language.\n"); } @@ -250,7 +250,7 @@ show_range_command(ignore, from_tty) { if (range_check != current_language->la_range_check) - printf( + printf_filtered( "Warning: the current range check setting does not match the language.\n"); } @@ -399,11 +399,11 @@ language_info (quietly) int quietly; { /* FIXME: quietly is ignored at the moment. */ - printf("Current Language: %s\n",language); + printf_filtered("Current Language: %s\n",language); show_language_command((char *)0, 1); - printf("Type checking: %s\n",type); + printf_filtered("Type checking: %s\n",type); show_type_command((char *)0, 1); - printf("Range checking: %s\n",range); + printf_filtered("Range checking: %s\n",range); show_range_command((char *)0, 1); } @@ -929,14 +929,14 @@ type_error (va_alist) char *string; if (type_check==type_check_warn) - fprintf(stderr,warning_pre_print); + fprintf_filtered(stderr,warning_pre_print); else target_terminal_ours(); va_start (args); string = va_arg (args, char *); - vfprintf (stderr, string, args); - fprintf (stderr, "\n"); + vfprintf_filtered (stderr, string, args); + fprintf_filtered (stderr, "\n"); va_end (args); if (type_check==type_check_on) return_to_top_level(); @@ -950,14 +950,14 @@ range_error (va_alist) char *string; if (range_check==range_check_warn) - fprintf(stderr,warning_pre_print); + fprintf_filtered(stderr,warning_pre_print); else target_terminal_ours(); va_start (args); string = va_arg (args, char *); - vfprintf (stderr, string, args); - fprintf (stderr, "\n"); + vfprintf_filtered (stderr, string, args); + fprintf_filtered (stderr, "\n"); va_end (args); if (range_check==range_check_on) return_to_top_level(); @@ -986,7 +986,7 @@ set_check (ignore, from_tty) char *ignore; int from_tty; { - printf( + printf_filtered( "\"set check\" must be followed by the name of a check subcommand.\n"); help_list(setchecklist, "set check ", -1, stdout); } @@ -1007,7 +1007,7 @@ add_language (lang) { if (lang->la_magic != LANG_MAGIC) { - fprintf(stderr, "Magic number of %s language struct wrong\n", + fprintf_filtered(stderr, "Magic number of %s language struct wrong\n", lang->la_name); abort(); } diff --git a/gdb/main.c b/gdb/main.c index 0eb254f6647..54332490aaa 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -256,6 +256,12 @@ struct cmd_list_element *maintenancelist; struct cmd_list_element *maintenanceinfolist; #endif +/* Chain containing all defined "maintenance print" subcommands. */ + +#if MAINTENANCE_CMDS +struct cmd_list_element *maintenanceprintlist; +#endif + struct cmd_list_element *setprintlist; struct cmd_list_element *showprintlist; @@ -590,7 +596,7 @@ main (argc, argv) ADDITIONAL_OPTION_CASES #endif case '?': - fprintf (stderr, + fprintf_filtered (stderr, "Use `%s +help' for a complete list of options.\n", argv[0]); exit (1); @@ -647,7 +653,7 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); corearg = argv[optind]; break; case 3: - fprintf (stderr, + fprintf_filtered (stderr, "Excess command line arguments ignored. (%s%s)\n", argv[optind], (optind == argc - 1) ? "" : " ..."); break; @@ -1004,7 +1010,7 @@ gdb_readline (prrompt) if (prrompt) { - printf (prrompt); + printf_filtered (prrompt); fflush (stdout); } @@ -1048,7 +1054,16 @@ static char *history_filename; /* Variables which are necessary for fancy command line editing. */ char *gdb_completer_word_break_characters = - " \t\n!@#$%^&*()-+=|~`}{[]\"';:?/>.<,"; + " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,-"; + +/* When completing on command names, we remove '-' from the list of + word break characters, since we use it in command names. If the + readline library sees one in any of the current completion strings, + it thinks that the string needs to be quoted and automatically supplies + a leading quote. */ +char *gdb_completer_command_word_break_characters = + " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,"; + /* Characters that can be used to quote completion strings. Note that we can't include '"' because the gdb C parser treats such quoted sequences as strings. */ @@ -1112,6 +1127,16 @@ symbol_completion_function (text, matches) list = 0; index = 0; + /* Choose the default set of word break characters to break completions. + If we later find out that we are doing completions on command strings + (as opposed to strings supplied by the individual command completer + functions, which can be any string) then we will switch to the + special word break set for command strings, which leaves out the + '-' character used in some commands. */ + + rl_completer_word_break_characters = + gdb_completer_word_break_characters; + /* Decide whether to complete on a list of gdb commands or on symbols. */ tmp_command = (char *) alloca (rl_point + 1); p = tmp_command; @@ -1146,26 +1171,17 @@ symbol_completion_function (text, matches) { /* If we didn't recognize everything up to the thing that needs completing, and we don't know what command it is - yet, we are in trouble. Part of the trouble might be - that the list of delimiters used by readline includes - '-', which we use in commands. Check for this. */ + yet, we are in trouble. */ if (p + strlen(text) != tmp_command + rl_point) { - if (tmp_command[rl_point - strlen(text) - 1] == '-') - { - text = p; - } - else - { - /* This really should not produce an error. Better would - be to pretend to hit RETURN here; this would produce a - response like "Ambiguous command: foo, foobar, etc", - and leave the line available for re-entry with ^P. - Instead, this error blows away the user's typed input - without any way to get it back. */ - error (" Unrecognized command."); - } + /* This really should not produce an error. Better would + be to pretend to hit RETURN here; this would produce a + response like "Ambiguous command: foo, foobar, etc", + and leave the line available for re-entry with ^P. + Instead, this error blows away the user's typed input + without any way to get it back. */ + error (" Unrecognized command."); } /* He's typed something ambiguous. This is easier. */ @@ -1177,6 +1193,8 @@ symbol_completion_function (text, matches) { list = complete_on_cmdlist (cmdlist, text); } + rl_completer_word_break_characters = + gdb_completer_command_word_break_characters; } else { @@ -1193,12 +1211,16 @@ symbol_completion_function (text, matches) { /* Always (might be longer versions of thie command). */ list = complete_on_cmdlist (result_list, text); + rl_completer_word_break_characters = + gdb_completer_command_word_break_characters; } else if (!*p && !*text) { if (c->prefixlist) { list = complete_on_cmdlist (*c->prefixlist, ""); + rl_completer_word_break_characters = + gdb_completer_command_word_break_characters; } else { @@ -1289,7 +1311,7 @@ int signo; #else signal (STOP_SIGNAL, stop_sig); #endif - printf ("%s", prompt); + printf_filtered ("%s", prompt); fflush (stdout); /* Forget about any previous command -- null line now will do nothing. */ @@ -1435,7 +1457,7 @@ command_line_input (prrompt, repeat) if (expanded) { /* Print the changes. */ - printf ("%s\n", history_value); + printf_filtered ("%s\n", history_value); /* If there was an error, call this function again. */ if (expanded < 0) @@ -1633,7 +1655,7 @@ info_command (arg, from_tty) char *arg; int from_tty; { - printf ("\"info\" must be followed by the name of an info command.\n"); + printf_filtered ("\"info\" must be followed by the name of an info command.\n"); help_list (infolist, "info ", -1, stdout); } @@ -1749,7 +1771,7 @@ define_command (comname, from_tty) if (from_tty) { - printf ("Type commands for definition of \"%s\".\n\ + printf_filtered ("Type commands for definition of \"%s\".\n\ End with a line saying just \"end\".\n", comname); fflush (stdout); } @@ -1782,7 +1804,7 @@ document_command (comname, from_tty) error ("Command \"%s\" is built-in.", comname); if (from_tty) - printf ("Type documentation for \"%s\".\n\ + printf_filtered ("Type documentation for \"%s\".\n\ End with a line saying just \"end\".\n", comname); doclines = read_command_lines (); @@ -1813,7 +1835,7 @@ End with a line saying just \"end\".\n", comname); static void print_gnu_advertisement() { - printf ("\ + 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\ @@ -1846,7 +1868,7 @@ show_version (args, from_tty) void print_prompt () { - printf ("%s", prompt); + printf_filtered ("%s", prompt); fflush (stdout); } @@ -1889,10 +1911,10 @@ pwd_command (args, from_tty) getcwd (dirbuf, sizeof (dirbuf)); if (strcmp (dirbuf, current_directory)) - printf ("Working directory %s\n (canonically %s).\n", + printf_filtered ("Working directory %s\n (canonically %s).\n", current_directory, dirbuf); else - printf ("Working directory %s.\n", current_directory); + printf_filtered ("Working directory %s.\n", current_directory); } static void @@ -2129,7 +2151,7 @@ set_history (args, from_tty) char *args; int from_tty; { - printf ("\"set history\" must be followed by the name of a history subcommand.\n"); + printf_filtered ("\"set history\" must be followed by the name of a history subcommand.\n"); help_list (sethistlist, "set history ", -1, stdout); } @@ -2204,6 +2226,7 @@ initialize_cmd_lists () #if MAINTENANCE_CMDS maintenancelist = NULL; maintenanceinfolist = NULL; + maintenanceprintlist = NULL; #endif setprintlist = NULL; showprintlist = NULL; diff --git a/gdb/symfile.c b/gdb/symfile.c index 740c4c10e52..21ead48d518 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -332,6 +332,27 @@ init_entry_point_info (objfile) } } +/* Remember the lowest-addressed loadable section we've seen. + This function is called via bfd_map_over_sections. */ + +#if 0 /* Not used yet */ +static void +find_lowest_section (abfd, sect, obj) + bfd *abfd; + asection *sect; + PTR obj; +{ + asection **lowest = (asection **)obj; + + if (0 == (bfd_get_section_flags (abfd, sect) & SEC_LOAD)) + return; + if (!*lowest) + *lowest = sect; /* First loadable section */ + else if (bfd_section_vma (abfd, *lowest) >= bfd_section_vma (abfd, sect)) + *lowest = sect; /* A lower loadable section */ +} +#endif + /* Process a symbol file, as either the main file or as a dynamically loaded file. @@ -351,7 +372,8 @@ syms_from_objfile (objfile, addr, mainline, verbo) int mainline; int verbo; { - asection *text_sect; + struct section_offsets *section_offsets; + asection *lowest_sect; /* There is a distinction between having no symbol table (we refuse to read the file, leaving the old set of symbols around) @@ -382,12 +404,40 @@ syms_from_objfile (objfile, addr, mainline, verbo) } (*objfile -> sf -> sym_new_init) (objfile); + } - /* For mainline, caller didn't know the specified address of the - text section. We fix that here. */ + /* Convert addr into an offset rather than an absolute address. + We find the lowest address of a loaded segment in the objfile, + and assume that is where that got loaded. Due to historical + precedent, we warn if that doesn't happen to be the ".text" + segment. */ - text_sect = bfd_get_section_by_name (objfile -> obfd, ".text"); - addr = bfd_section_vma (objfile -> obfd, text_sect); + if (mainline) + { + addr = 0; /* No offset from objfile addresses. */ + } + else + { + lowest_sect = bfd_get_section_by_name (objfile->obfd, ".text"); +#if 0 + lowest_sect = 0; + bfd_map_over_sections (objfile->obfd, find_lowest_section, + (PTR) &lowest_sect); +#endif + + if (lowest_sect == 0) + warning ("no loadable sections found in added symbol-file %s", + objfile->name); + else if (0 == bfd_get_section_name (objfile->obfd, lowest_sect) + || 0 != strcmp(".text", + bfd_get_section_name (objfile->obfd, lowest_sect))) + warning ("Lowest section in %s is %s at 0x%x", + objfile->name, + bfd_section_name (objfile->obfd, lowest_sect), + bfd_section_vma (objfile->obfd, lowest_sect)); + + if (lowest_sect) + addr -= bfd_section_vma (objfile->obfd, lowest_sect); } /* Initialize symbol reading routines for this objfile, allow complaints to @@ -396,7 +446,8 @@ syms_from_objfile (objfile, addr, mainline, verbo) (*objfile -> sf -> sym_init) (objfile); clear_complaints (1, verbo); - (*objfile -> sf -> sym_read) (objfile, addr, mainline); + section_offsets = (*objfile -> sf -> sym_offsets) (objfile, addr); + (*objfile -> sf -> sym_read) (objfile, section_offsets, mainline); /* Don't allow char * to have a typename (else would get caddr_t.) */ /* Ditto void *. FIXME should do this for all the builtin types. */ @@ -491,6 +542,11 @@ symbol_file_add (name, from_tty, addr, mainline, mapped, readnow) && !query ("Load new symbol table from \"%s\"? ", name)) error ("Not confirmed."); + /* Getting new symbols may change our opinion about what is + frameless. */ + + reinit_frame_cache (); + objfile = allocate_objfile (abfd, mapped); /* If the objfile uses a mapped symbol file, and we have a psymtab for @@ -583,9 +639,11 @@ symbol_file_command (args, from_tty) error ("Not confirmed."); free_all_objfiles (); symfile_objfile = NULL; + current_source_symtab = NULL; + current_source_line = 0; if (from_tty) { - printf ("No symbol file now.\n"); + printf_filtered ("No symbol file now.\n"); } } else @@ -622,9 +680,6 @@ symbol_file_command (args, from_tty) } else { - /* Getting new symbols may change our opinion about what is - frameless. */ - reinit_frame_cache (); symbol_file_add (name, from_tty, (CORE_ADDR)0, 1, mapped, readnow); } do_cleanups (cleanups); @@ -798,11 +853,6 @@ add_symbol_file_command (args, from_tty) name, local_hex_string (text_addr))) error ("Not confirmed."); - /* Getting new symbols may change our opinion about what is - frameless. */ - - reinit_frame_cache (); - symbol_file_add (name, 0, text_addr, 0, mapped, readnow); } @@ -1078,7 +1128,7 @@ clear_symtab_users_once () return; clear_symtab_users_done = clear_symtab_users_queued; - printf ("Resetting debugger state after updating old symbol tables\n"); + 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. */ @@ -1252,10 +1302,10 @@ again2: struct partial_symtab * -start_psymtab_common (objfile, addr, +start_psymtab_common (objfile, section_offsets, filename, textlow, global_syms, static_syms) struct objfile *objfile; - CORE_ADDR addr; + struct section_offsets *section_offsets; char *filename; CORE_ADDR textlow; struct partial_symbol *global_syms; @@ -1264,7 +1314,7 @@ start_psymtab_common (objfile, addr, struct partial_symtab *psymtab; psymtab = allocate_psymtab (filename, objfile); - psymtab -> addr = addr; + psymtab -> section_offsets = section_offsets; psymtab -> textlow = textlow; psymtab -> texthigh = psymtab -> textlow; /* default */ psymtab -> globals_offset = global_syms - objfile -> global_psymbols.list; diff --git a/gdb/target.c b/gdb/target.c index d2536232365..93bb64e89ba 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -123,7 +123,7 @@ add_target (t) { if (t->to_magic != OPS_MAGIC) { - fprintf(stderr, "Magic number of %s target struct wrong\n", + fprintf_filtered(stderr, "Magic number of %s target struct wrong\n", t->to_shortname); abort(); } @@ -202,7 +202,7 @@ default_terminal_info (args, from_tty) char *args; int from_tty; { - printf("No saved terminal information.\n"); + printf_filtered("No saved terminal information.\n"); } #if 0 @@ -245,7 +245,7 @@ kill_or_be_killed (from_tty) { if (target_has_execution) { - printf ("You are already running a program:\n"); + printf_filtered ("You are already running a program:\n"); target_files_info (); if (query ("Kill it? ")) { target_kill (); @@ -290,7 +290,7 @@ cleanup_target (t) the struct definition, but not all the places that initialize one. */ if (t->to_magic != OPS_MAGIC) { - fprintf(stderr, "Magic number of %s target struct wrong\n", + fprintf_filtered(stderr, "Magic number of %s target struct wrong\n", t->to_shortname); abort(); } @@ -522,7 +522,7 @@ target_xfer_memory (memaddr, myaddr, len, write) /* If this address is for nonexistent memory, read zeros if reading, or do nothing if writing. Return error. */ if (!write) - (void) memset (myaddr, 0, len); + memset (myaddr, 0, len); if (errno == 0) return EIO; else @@ -547,7 +547,7 @@ target_info (args, from_tty) int has_all_mem = 0; if (symfile_objfile != NULL) - printf ("Symbols from \"%s\".\n", symfile_objfile->name); + printf_filtered ("Symbols from \"%s\".\n", symfile_objfile->name); #ifdef FILES_INFO_HOOK if (FILES_INFO_HOOK ()) @@ -561,8 +561,8 @@ target_info (args, from_tty) if ((int)(t->to_stratum) <= (int)dummy_stratum) continue; if (has_all_mem) - printf("\tWhile running this, gdb does not access memory from...\n"); - printf("%s:\n", t->to_longname); + printf_filtered("\tWhile running this, gdb does not access memory from...\n"); + printf_filtered("%s:\n", t->to_longname); (t->to_files_info)(t); has_all_mem = t->to_has_all_memory; } diff --git a/gdb/utils.c b/gdb/utils.c index b99e4f94246..e61b3d68aea 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -52,9 +52,6 @@ prompt_for_continue PARAMS ((void)); static void set_width_command PARAMS ((char *, int, struct cmd_list_element *)); -static void -vfprintf_filtered PARAMS ((FILE *, char *, va_list)); - /* If this definition isn't overridden by the header files, assume that isatty and fileno exist on this system. */ #ifndef ISATTY @@ -1175,7 +1172,7 @@ fputs_demangled (linebuffer, stream, arg_mode) (since prompt_for_continue may do so) so this routine should not be called when cleanups are not in place. */ -static void +void vfprintf_filtered (stream, format, args) FILE *stream; char *format;