diff options
author | Stan Shebs <shebs@codesourcery.com> | 1999-09-09 00:02:17 +0000 |
---|---|---|
committer | Stan Shebs <shebs@codesourcery.com> | 1999-09-09 00:02:17 +0000 |
commit | d4f3574e777abfa65c9ba134e582228f3f32a8d6 (patch) | |
tree | 408b74c26833555087f04f4ec466afd488af6087 /gdb | |
parent | 325188ecac3a52d92d359c70f9b730470760e1d7 (diff) | |
download | gdb-d4f3574e777abfa65c9ba134e582228f3f32a8d6.zip gdb-d4f3574e777abfa65c9ba134e582228f3f32a8d6.tar.gz gdb-d4f3574e777abfa65c9ba134e582228f3f32a8d6.tar.bz2 |
import gdb-1999-09-08 snapshot
Diffstat (limited to 'gdb')
145 files changed, 5043 insertions, 1698 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5e0dbf9..e3b0c40 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,462 @@ +1999-09-07 J.T. Conklin <jtc@redback.com> + + * i386-stub.c (exceptionHook, oldExceptionHook): Removed. + (handle_exception): Removed #if'd out exception hook code. + + * i386-stub.c, m68k-stub.c (error): Removed unused variable. + + * i386-stub.c, m68k-stub.c, sh-stub.c, sparc-stub.c, + sparcl-stub.c, sparclet-stub.c (remcomInBuffer, remcomOutBuffer): + Make static. + +Tue Sep 7 14:06:22 1999 Kevin Buettner <kevinb@cygnus.com> + + * config/i386/tm-linux.h (SOFUN_ADDRESS_MAYBE_MISSING): + Define. + +Tue Sep 7 08:18:01 1999 Kevin Buettner <kevinb@cygnus.com> + + From Jim Blandy <jimb@cygnus.com>: + + Step into calls to functions in shared libraries properly. See + the comments for SKIP_SOLIB_RESOLVER atop infrun.c for details. + * infrun.c (SKIP_SOLIB_RESOLVER): New macro. + +1999-09-05 Fred Fish <fnf@cygnus.com> + + * elfread.c (elf_symtab_read): Remove separately passed bfd + pointer and offset. Pick up bfd pointer from objfile, and + get offset from objfile's section_offsets. + +Fri Sep 3 22:29:39 1999 Kevin Buettner <kevinb@cygnus.com> + + * config/i386/tm-linux.h (REGISTER_NAMES): Changed register + named "foo" to "fopo" which more accurately describes the FPU + Operand Pointer Offset. The real reason for this change, of + course, is that many programmers use $foo as a convenience + variable and are likely to be unpleasantly surprised to find + that they're unwittingly changing the state of their ia32 FPU. + +1999-09-03 Jason Molenda (jsm@bugshack.cygnus.com) + + * monitor.c (monitor_supply_register): Stop scanning val string + if a newline is encountered. + +1999-09-03 Jason Molenda (jsm@bugshack.cygnus.com) + + monitor.c (TARGET_BUF_SIZE): New macro, defined to 2048. + (monitor_expect_regexp, monitor_wait, monitor_dump_reg_block, + monitor_dump_reg_block): Dump hard-coded constants in favor + of TARGET_BUF_SIZE. + + (readchar): Re-enable output of characters read from monitor when + remotedebug is set. + + (monitor_supply_register): Use ULONGEST to hold value. + Replace strtoul() call with hand-coded loop to handle values + larger than 'long'. + + (monitor_store_register): Use ULONGEST to hold value. + +Fri Sep 3 00:47:44 1999 Kevin Buettner <kevinb@cygnus.com> + + [Merged linux/x86 floating point code from Bill Metzenthen, + Jim Blandy, Anthony Green, H. J. Liu, and possibly others. The + following remarks are Jim Blandy's.] + + * findvar.c (extract_floating): Call TARGET_EXTRACT_FLOATING, if + #defined. + (store_floating): Call TARGET_STORE_FLOATING, if #defined. + + * i386-tdep.c (i386_print_register, i386_do_registers_info): New + functions. + (i386_extract_return_value): GNU/Linux returns floating point + values in a floating point register too. + (set_disassembly_flavor): Add prototype. + (i386_extract_return_value): Use FPDATA_REGNUM, not FP0_REGNUM ( + which wasn't the first FP data register). + (i386_do_registers_info): Use FPSTART_REGNUM and FPEND_REGNUM as + the limits of the FPU-related registers. + (i386_extract_return_value): Tell GDB how to find return values + larger than four bytes. (Thanks to Paul N. Hilfinger for the bug + report.) + + * i387-tdep.c (print_387_control_word): Break out bit-splitting into... + (print_387_control_bits): New function. + (print_387_status_word): Break out bit-splitting into... + (print_387_status_bits): New function. + (i387_print_register, i387_float_info, i387_hex_float_input): New + functions. + (i387_extract_floating, i387_store_floating): New functions. + + * valprint.c (print_floating): Use macro TARGET_ANALYZE_FLOATING, + if it's #defined. Tolerate values of `nonnegative' other than + zero and one. + + * i386-linux-nat.c: New file. + * Makefile.in (ALLDEPFILES): Mention i386-linux-nat.c. + (i386-linux-nat.o): New rule, listing dependencies. + * config/i386/linux.mh (NATDEPFILES): Use i386-linux-nat.o, not + the plain i386v4-nat.o. + * config/i386/nm-linux.h (FETCH_INFERIOR_REGISTERS): Define. + * config/i386/xm-linux.h: Define HOST_I386. + + * config/i386/tm-linux.h (FP0_REGNUM): Replaced by... + (FPSTART_REGNUM, FPCONTROL_REGNUM, FPSTATUS_REGNUM, FPTAG_REGNUM, + FPDATA_REGNUM, FPEND_REGNUM): New definitions. + (REGISTER_BYTES): Changed accordingly. + (SKIP_SOLIB_RESOLVER): #define this. + (i386_linux_skip_solib_resolver): New declaration. + (i387_float_info): Added extern decl for this function. + (TARGET_EXTRACT_FLOATING, TARGET_STORE_FLOATING, + TARGET_ANALYZE_FLOATING): Define. + (i387_extract_floating, i387_store_floating): New extern decls. + (I386_GNULINUX_TARGET): Define. + (NUM_REGS, NUM_FREGS, REGISTER_NAMES, FP0_REGNUM, FPDATA_REGNUM, + FPENV_BYTES, FPREG_RAW_SIZE, FPREG_BYTES, REGISTER_BYTES, + REGISTER_BYTE, REGISTER_RAW_SIZE, REGISTER_VIRTUAL_SIZE, + MAX_REGISTER_RAW_SIZE, MAX_REGISTER_VIRTUAL_SIZE, + TARGET_LONG_DOUBLE_BIT, FLOAT_INFO, DO_REGISTERS_INFO): New + definitions, perhaps overriding those inherited from + config/i386/tm-i386.h. + (i386_do_registers_info, i387_print_register, double_to_i387, + i387_to_double): New declarations. + (LD_I387): Define iff both the host and target are using i387 + FPU's. + (HEX_FLOAT_INPUT, REGISTER_CONVERTIBLE, + REGISTER_CONVERT_TO_VIRTUAL, REGISTER_CONVERT_TO_RAW, + REGISTER_VIRTUAL_TYPE): Define these if LD_I387 is defined. + + * source.c (list_command): List the right number of source lines, + even if we're at the top of the file. + +1999-09-02 Stan Shebs <shebs@andros.cygnus.com> + + * infrun.c (step_over_function): New function, broken out from the + step_over_function label in handle_inferior_event. + (handle_inferior_event): Change a goto into a function call. + +Thu Sep 2 18:26:04 1999 Andrew Cagney <cagney@b1.cygnus.com> + + * Makefile.in (GDB_WERROR_CFLAGS, GBB_WARN_CFLAGS): Define. + (INTERNAL_CFLAGS): Update + * configure.in (WERROR_CFLAGS, WARN_CFLAGS): Sync with + ../sim/common/aclocal.m4. + * configure: Re-generate. + +Thu Sep 2 00:27:36 1999 Andrew Cagney <cagney@b1.cygnus.com> + + * Makefile.in (z8k-tdep.o): For moment, don't try to compile with + -Werror. See Makefile.in. + * z8k-tdep.c (z8k_set_pointer_size): Document problem. + + * config/z8k/tm-z8k.h (z8k_print_register_hook, z8k_frame_chain, + z8k_saved_pc_after_call, z8k_frame_saved_pc, + z8k_set_pointer_size): Declare. + (z8k_skip_prologue): Fix typo. Was mz8k_skip_prologue. + (FRAME_CHAIN, PRINT_REGISTER_HOOK, FRAME_SAVED_PC, + SAVED_PC_AFTER_CALL): Update. + * z8k-tdep.c (z8k_print_register_hook): Rename + z8k_print_register_hook. + (z8k_frame_chain): Rename frame_chain. + (z8k_saved_pc_after_call): Rename saved_pc_after_call. + (z8k_frame_saved_pc): Rename frame_saved_pc. + (z8k_print_register_hook): Fix printf. + (read_memory_pointer): Add declaration. + ("value.h"): Include. + * Makefile.in (z8k-tdep.o): Add dependency on value.h. + + * config/sparc/tm-sparc.h (PRINT_EXTRA_FRAME_INFO): Fix + printf. calls + * Makefile.in (remote-e7000.o): For moment, don't try to compile + with -Werror. See Makefile.in. + * sh-tdep.c (sh_show_regs): Fix printf calls. + * xcoffsolib.c (solib_info): Fix Printf calls. + * dink32-rom.c: #include "symfile.h" for generic_load and + "inferior.h" for write_pc. + * Makefile.in (dink32-rom.o): Update. + + * config/mn10300/tm-mn10300.h (mn10300_store_struct_return), + config/mn10200/tm-mn10200.h (mn10200_store_struct_return): Add + declarations. + +Tue Aug 31 00:48:27 1999 Andrew Cagney <cagney@amy.cygnus.com> + + * config/mips/tm-tx49el.h (REGISTER_SIM_REGNO): Define. + + * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register): + Pass REGISTER_SIM_REGNO converted register number to the + simulator. + +1999-09-01 Tom Tromey <tromey@cygnus.com> + + * config/i386/nm-linux.h (PREPARE_TO_PROCEED): Added argument. + +1999-09-01 Elena Zannoni <ezannoni@kwikemart.cygnus.com> + + * values.c (value_virtual_fn_field): Remove unused var(s). + * thread.c (prune_threads): Ditto. + * symtab.c (lookup_transparent_type): Ditto. + (decode_line_1): Ditto. + (make_symbol_overload_list): Ditto. + * rs6000-tdep.c (frame_get_saved_regs): Ditto. + (set_processor): Ditto. + * remote.c (remote_remove_breakpoint): Ditto. + (remote_query): Ditto. + (readtty): Ditto. + * remote-sds.c (sds_fetch_registers): Ditto. + (putmessage): Ditto. + * ppcbug-rom.c (ppcbug_supply_register): Ditto. + (ppcbug_open): Remove unused prototype. + * parse.c (parse_nested_classes_for_hpacc): Remove unused var(s). + * ocd.c (ocd_open): Ditto. + (ocd_get_packet): Ditto. + * monitor.c (monitor_error): Ditto. + (monitor_wait_srec_ack): Ditto. + * main.c (main): Ditto. + * gdbtypes.c (count_virtual_fns): Ditto. + * exec.c (exec_file_command): Ditto. + + * event-top.c: Include handle_sigwinch() function prototype within + appropriate #ifdef. + + * eval.c (evaluate_subexp_standard): Remove unused variable. + (evaluate_subexp_standard): Remove unused variables. + * dink32-rom.c (dink32_supply_register): Remove unused variable. + * dbxread.c (elfstab_build_psymtabs): Ditto. + * command.c (do_setshow_command): Ditto. + * breakpoint.c (solib_load_unload_1): Remove unused variables 'i' + and 'sal'. + (until_break_command): Remove unused variables 'arg1' and 'arg2'. + (create_exception_catchpoint): Remove unused variable 'i'. + * ax-gdb.c (gen_sub): Remove unused variable. + (_initialize_ax_gdb): Ditto. + + * ser-pipe.c (pipe_readchar): If timeout is expired return + SERIAL_TIMEOUT. + * ser-tcp.c (tcp_readchar): If timeout is expired return + SERIAL_TIMEOUT. + +Wed Sep 1 15:07:25 1999 Andrew Cagney <cagney@b1.cygnus.com> + + * version.h: New file. + * Makefile.in (version_h): Define. + (version.o): Add target. + + * remote-array.c: #include "version.h". + (version): Delete extern declarations. + * Makefile.in (remote-array.o): Add dependency on version.h. + + * top.c: #include "version.h". + (version, host_name, target_name): Delete extern declarations. + * Makefile.in (top.o): Add dependency on version.h. + + * remote.c (remote_remove_watchpoint, remote_insert_watchpoint), + remote-array.c (array_open), remote-mips.c (send_srec), + dve3900-rom.c (store_bitmapped_register): Fix Printfs. + + * mips-tdep.c (mips_print_extra_frame_info, print_unpack), + m32r-rom.c (m32r_load_section), m32r-tdep.c (m32r_frame_chain), + dsrec.c (load_srec): Fix printf problems. + +Wed Sep 1 13:16:49 1999 Andrew Cagney <cagney@b1.cygnus.com> + + * Makefile.in (monitor.o): For moment, don't try to compile with + -Werror. monitor.c has -Wformat problems. See Makefile.in for + more info. + +Tue Aug 31 21:23:38 1999 Jeffrey A Law (law@cygnus.com) + + * hppa-tdep.c (prologue_inst_adjust_sp): Correct offset computation + for doubleword store instructions. + (hppa_frame_find_saved_regs): Similarly. + +Wed Sep 1 09:22:50 1999 Andrew Cagney <cagney@b1.cygnus.com> + + * d30v-tdep.c (d30v_print_register): + (tdisassemble_command): + + * d10v-tdep.c (show_regs, trace_info, tdisassemble_command): Fix + printf problems. + + * remote-sim.c (dump_mem), remote-rdi.c (arm_rdi_create_inferior): + Fix printf arguments. + + * remote-mips.c, mips-tdep.c: Move declaration of + ``mips_set_processor_type_command'' from here. + * config/mips/tm-mips.h: To here. + * remote-array.c: #include "inferior.h". + * config/mips/tm-embed.h (remote_mips_stopped_by_watchpoint): Add + declaration. + * remote-mips.c (remote_mips_stopped_by_watchpoint): Define using + ISO-C prototype. + (monitor_supports_breakpoints): Integer variable. + + * m32r-rom.c: #include "inferior.h" and <ctype.h> + * config/m32r/tm-m32r.h (m32r_write_sp): Add declaration. + + * config/i960/tm-i960.h (leafproc_return, i960_pop_frame): Add + declaration. + (POP_FRAME): Call i960_pop_frame. + * i960-tdep.c (i960_pop_frame): Rename pop_frame. + * mon960-rom.c: #include "inferior.h" for declaration of write_pc. + +1999-08-15 Fred Fish <fnf@cygnus.com> + + * objfiles.c (objfile_relocate): Use SIZEOF_SECTION_OFFSETS when + allocating section_offsets array. + * remote-os9k.c (rombug_wait): Ditto. + * remote-vx.c (vx_add_symbols): Ditto. + * remote.c (get_offsets): Ditto. + (remote_cisco_objfile_relocate): Ditto. + * rs6000-nat.c (vmap_symtab): Ditto. + + * dstread.c (dst_symfile_offsets): Set section_offsets directly instead + of returning a pointer to section offsets. + * somread.c (som_symfile_offsets): Ditto. + * xcoffread.c (xcoff_symfile_offsets): Ditto. + * symfile.c (default_symfile_offsets): Ditto. + (syms_from_objfile): The sym_offsets function has already set section + offsets and no longer returns a value. + + * xcoffread.c (scan_xcoff_symtab): Eliminate section_offsets passed + separate from objfile. + (xcoff_start_psymtab): Ditto. + (START_PSYMTAB): Ditto. + * os9kread.c (read_minimal_symbols): Ditto. + (read_os9k_psymtab): Ditto. + (os9k_start_psymtab): Ditto. + (record_minimal_symbol): Ditto. + * dbxread.c (START_PSYMTAB): Ditto. + (start_psymtab): Ditto. + * mdebugread.c (START_PSYMTAB): Ditto. + (elfmdebug_build_psymtabs): Ditto. + (mdebug_build_psymtabs): Ditto. + (parse_partial_symbols): Ditto. + (new_psymtab): Ditto. + * dwarfread.c (dwarf_build_psymtabs): Ditto. + * partial-stab.h (START_PSYMTAB): Ditto. + * stabsread.h (start_psymtab): Ditto. + * dwarf2read.c (dwarf2_build_psymtabs): Ditto. + (dwarf2_build_psymtabs_easy): Ditto. + (dwarf2_build_psymtabs_hard): Ditto. + * hp-psymtab-read.c (hpread_build_psymtabs): Ditto. + (hpread_quick_traverse): Ditto. + (hpread_start_psymtab): Ditto. + (scan_procs): Ditto. + * hpread.c (hpread_build_psymtabs): Ditto. + * symfile.h (dwarf2_build_psymtabs): Ditto. + + * dbxread.c (read_dbx_symtab): Use ANOFFSET to access section + offsets. + * core-cisco.c (get_seg_info): Make static. + * coffread.c (enter_linenos): Pass objfile instead of section + offsets. + * jv-vm.c (jv_vm_internal_lookup_symbol): Call allocate_objfile + with the right number of arguments. + + * dbxread.c (dbx_symfile_read): No need to explicitly pass + text addr and size. Let read_dbx_symtab find them. + (read_dbx_symtab): Get text addr and size from objfile. + (dbx_symfile_read): Remove dead code (call to strlen); + +1999-08-31 Michael Snyder <msnyder@cleaver.cygnus.com> + + * Makefile.in: add rule for sol-thread.o. + Add rule for linux-thread.o. + +1999-08-13 Jim Kingdon <kingdon@redhat.com> + + Threads code from gdb 4.18-codefusion-990706 + [Thanks to Eric Paire, H. J. Liu, Jim Blandy and others] + * infrun.c (signal_stop_update, signal_print_update, + signal_pass_update): new functions. + * inferior.h: new prototypes for above functions. + * target.h (enum strata): add thread stratum. + * linux-thread.c: new file. Support for debugging linux threads. + * config/i386/nm-linux.h: several new prototypes for above. + * config/i386/linux.mh: add linux-thread.o to NATDEPFILES. + + More threads code from the same place: + * config/i386/tm-linux.h (REALTIME_LO, REALTIME_HI): Add + definitions. + * target.h (enum target_signal): Add TARGET_SIGNAL_REALTIME_32. + * target.c (signals, target_signal_from_host, + target_signal_to_host): Add clauses for + TARGET_SIGNAL_REALTIME_32. + +1999-08-31 Neil Schellenberger <neil.schellenberger@crosskeys.com> + + * sol-thread.c (sol_thread_detach): strip thread-id out of + inferior_pid, so that procfs_detach can't choke on it. + +1999-08-31 J.T. Conklin <jtc@redback.com> + + * i386-stub.c, m32r-stub.c, m68k-stub.c, sh-stub.c, sparc-stub.c, + sparcl-stub.c, sparclet-stub.c (getpacket): Remove 'buffer' arg, + define it as a pointer to &remcomInBuffer[0]. + (handle_exception): Update. + + * sparc-stub.c, sparcl-stub.c, sparclet-stub.c (handle_exception): + Removed #ifdef'd out code which implements the non-standard 'b' + (set baud rate) command. + +1999-08-31 Stan Shebs <shebs@andros.cygnus.com> + + * infrun.c (keep_going): New function, broken out from the + keep_going label in handle_inferior_event. + (handle_inferior_event): Change more gotos into function calls. + +Tue Aug 31 02:29:27 1999 Jeffrey A Law (law@cygnus.com) + + * hppa-tdep.c (read_unwind_info): Handle multiple unwind sections. + +Tue Aug 31 15:28:44 1999 Andrew Cagney <cagney@b1.cygnus.com> + + * config/alpha/tm-alpha.h (PRINT_EXTRA_FRAME_INFO): Fix printf + format argument. + * alpha-tdep.c (heuristic_proc_start): Ditto. + + From Stan Shebs <shebs@andros.cygnus.com>: + * defs.h (strlen_paddr): Fix prototype - add void argument list. + +Tue Aug 31 14:02:12 1999 Andrew Cagney <cagney@b1.cygnus.com> + + * defs.h (gdb_print_host_address), utils.c + (gdb_print_host_address): Rename gdb_print_address. + + * expprint.c, gdbtypes.c, symmisc.c: Update. + + *expprint.c: Use gdb_print_host_address when displaying native + pointers. + +Sat Aug 28 14:23:29 1999 Andrew Cagney <cagney@b1.cygnus.com> + + * scm-valprint.c (scm_ipruk), jv-valprint.c (java_value_print), + cp-valprint.c (cp_print_class_member), exec.c (exec_files_info), + remote.c (putpkt_binary, compare_sections_command, + remote_cisco_section_offsets), dcache.c (dcache_info), + breakpoint.c (break_at_finish_at_depth_command_1, + break_at_finish_command_1), symfile.c (generic_load), + (report_transfer_performance), top.c (get_prompt_1), f-valprint.c + (f_val_print), maint.c (maintenance_translate_address): Fix printf + -Wformat warnings. Use paddr, paddr_nz, sizeof_paddr, paddr_u and + paddr_d to print addresses. Change ``d'' to ``ld''. + + * utils.c (strlen_paddr): New function. + +Tue Aug 31 01:36:44 1999 Andrew Cagney <cagney@b1.cygnus.com> + + * config/d30v/tm-d30v.h (d30v_frame_chain, + d30v_init_frame_pc): Add declaration. + + * arc-tdep.c (arc_pop_frame): Rename pop_frame. + (arc_push_dummy_frame): Rename push_dummy_frame. + (arc_set_cpu_type_command): Add declaration. + + * config/arc/tm-arc.h (arc_pop_frame, arc_push_dummy_frame): Add + declaration. + 1999-08-30 Stan Shebs <shebs@andros.cygnus.com> * infrun.c (prepare_to_wait): New function, broken out from the diff --git a/gdb/Makefile.in b/gdb/Makefile.in index a2652aa..22edeb9 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -126,6 +126,8 @@ READLINE_CFLAGS = -I$(READLINE_SRC)/.. WARN_CFLAGS = @WARN_CFLAGS@ WERROR_CFLAGS = @WERROR_CFLAGS@ +GDB_WARN_CFLAGS = $(WARN_CFLAGS) +GDB_WERROR_CFLAGS = $(WERROR_CFLAGS) # Where is the INTL library? Typically in ../intl. INTL_DIR = ../intl @@ -188,8 +190,8 @@ INTERNAL_WARN_CFLAGS = \ $(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \ $(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) \ $(BFD_CFLAGS) $(MMALLOC_CFLAGS) $(INCLUDE_CFLAGS) \ - $(INTL_CFLAGS) $(TUI_CFLAGS) $(ENABLE_CFLAGS) $(WARN_CFLAGS) -INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS) $(WERROR_CFLAGS) + $(INTL_CFLAGS) $(TUI_CFLAGS) $(ENABLE_CFLAGS) $(GDB_WARN_CFLAGS) +INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS) $(GDB_WERROR_CFLAGS) # LDFLAGS is specifically reserved for setting from the command line # when running make. @@ -227,7 +229,7 @@ CDEPS = $(XM_CDEPS) $(TM_CDEPS) $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE) \ ADD_FILES = $(REGEX) $(XM_ADD_FILES) $(TM_ADD_FILES) $(NAT_ADD_FILES) ADD_DEPS = $(REGEX1) $(XM_ADD_FILES) $(TM_ADD_FILES) $(NAT_ADD_FILES) -VERSION = 19990830 +VERSION = 19990908 DIST=gdb LINT=/usr/5bin/lint @@ -453,6 +455,7 @@ inferior_h = inferior.h $(breakpoint_h) tracepoint_h = tracepoint.h ax_h = ax.h event_loop_h = event-loop.h +version_h = version.h # Header files that need to have srcdir added. Note that in the cases # where we use a macro like $(gdbcmd_h), things are carefully arranged @@ -829,9 +832,12 @@ copying.c: COPYING copying.awk awk -f $(srcdir)/copying.awk < $(srcdir)/COPYING > copying.c version.c: Makefile - echo 'char *version = "$(VERSION)";' >version.c - echo 'char *host_name = "$(host_alias)";' >> version.c - echo 'char *target_name = "$(target_alias)";' >> version.c + rm -f version.c + echo '#include "version.h"' >> version.c + echo 'const char version[] = "$(VERSION)";' >> version.c + echo 'const char host_name[] = "$(host_alias)";' >> version.c + echo 'const char target_name[] = "$(target_alias)";' >> version.c +version.o: version.c $(version_h) # c-exp.tab.c is generated in objdir from c-exp.y if it doesn't exist # in srcdir, then compiled in objdir to c-exp.tab.o. @@ -942,7 +948,7 @@ ALLDEPFILES = 29k-share/udi/udip2soc.c 29k-share/udi/udr.c \ gould-tdep.c gould-xdep.c h8300-tdep.c h8500-tdep.c \ hp300ux-nat.c hppa-tdep.c hppab-nat.c hppah-nat.c \ hp-psymtab-read.c hp-symtab-read.c \ - i386-tdep.c i386b-nat.c i386mach-nat.c i386v-nat.c \ + i386-tdep.c i386b-nat.c i386mach-nat.c i386v-nat.c i386-linux-nat.c \ i386aix-nat.c i386m3-nat.c i386v4-nat.c i386ly-tdep.c \ i387-tdep.c \ i960-tdep.c \ @@ -1092,7 +1098,7 @@ delta68-nat.o: delta68-nat.c $(defs_h) demangle.o: demangle.c $(defs_h) $(gdbcmd_h) gdb_string.h dink32-rom.o: dink32-rom.c monitor.h $(bfd_h) $(wait_h) $(defs_h) $(gdbcmd_h) \ - $(inferior_h) target.h serial.h terminal.h + $(inferior_h) target.h serial.h terminal.h symfile.h dpx2-nat.o: dpx2-nat.c $(defs_h) $(gdbcore_h) gdb_string.h @@ -1190,6 +1196,9 @@ i386mach-nat.o: i386mach-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) i386v-nat.o: i386v-nat.c $(floatformat_h) $(defs_h) $(gdbcore_h) \ $(inferior_h) language.h target.h +i386-linux-nat.o: i386-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \ + $(symtab_h) $(frame_h) $(symfile_h) $(objfiles_h) + i386v4-nat.o: i386v4-nat.c $(defs_h) i387-tdep.o: i387-tdep.c $(floatformat_h) $(defs_h) $(gdbcore_h) \ @@ -1309,8 +1318,14 @@ mipsread.o: mipsread.c buildsym.h complaints.h $(bfd_h) $(defs_h) \ mipsv4-nat.o: mipsv4-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) target.h +# FIXME: Monitor.c has -Wformat problems. The code using the macros +# RDEBUG and EXTRA_RDEBUG needs be replaced with something that: +# doesn't cause -Wformat errors; sends all output to gdb_stdlog +# instead of stdout; and controls the output throug a ``set +# monitordebug'' command/variable. cagney, 1999-09-01. monitor.o: monitor.c monitor.h $(bfd_h) $(wait_h) $(defs_h) $(gdbcmd_h) \ $(inferior_h) target.h serial.h terminal.h gdb_string.h + $(CC) -c $(INTERNAL_WARN_CFLAGS) $(NO_WERROR_CFLAGS) $< news-xdep.o: news-xdep.c @@ -1382,6 +1397,12 @@ printcmd.o: printcmd.c $(breakpoint_h) $(defs_h) $(expression_h) \ procfs.o: procfs.c $(command_h) $(defs_h) $(gdbcore_h) $(inferior_h) \ target.h gdb_string.h +sol-thread.o: sol-thread.c $(defs_h) gdbthread.h target.h $(inferior_h) \ + $(gdbcmd_h) + +linux-thread.o: linux-thread.c $(breakpoint_h) $(gdbcmd_h) $(wait_h) \ + gdbthread.h $(gdbcore_h) $(inferior_h) target.h $(defs_h) + # OBSOLETE pyr-tdep.o: pyr-tdep.c $(defs_h) # OBSOLETE pyr-xdep.o: pyr-xdep.c $(defs_h) $(gdbcore_h) $(inferior_h) @@ -1392,7 +1413,8 @@ remote-adapt.o: remote-adapt.c $(wait_h) $(defs_h) $(gdbcore_h) \ $(inferior_h) target.h terminal.h gdb_string.h remote-array.o: remote-array.c $(wait_h) $(defs_h) $(gdbcore_h) target.h \ - gdb_string.h $(command_h) serial.h monitor.h $(remote_utils_h) + gdb_string.h $(command_h) serial.h monitor.h $(remote_utils_h) \ + $(version_h) remote-rdi.o: remote-rdi.c $(wait_h) $(defs_h) $(gdbcore_h) \ $(inferior_h) gdb_string.h @@ -1416,8 +1438,13 @@ remote-rdp.o: remote-rdp.c $(wait_h) $(defs_h) $(gdbcore_h) \ remote-bug.o: remote-bug.c $(wait_h) $(defs_h) $(gdbcore_h) \ $(inferior_h) target.h terminal.h $(remote_utils_h) gdb_string.h +# FIXME: For the SH target, remote-e7000 contains numerous -Wformat +# warnings. Since the fixes involve modifications to the code that +# handles the SH remote protocol the changes need to be tested against +# an SH board before they can be committed. cagney 1999-09-01. remote-e7000.o: remote-e7000.c $(defs_h) $(gdbcore_h) target.h \ $(wait_h) serial.h gdb_string.h + $(CC) -c $(INTERNAL_WARN_CFLAGS) $(NO_WERROR_CFLAGS) $< remote-eb.o: remote-eb.c $(wait_h) $(srcdir)/config/a29k/tm-a29k.h \ $(defs_h) $(gdbcore_h) $(inferior_h) symfile.h target.h terminal.h \ @@ -1587,7 +1614,7 @@ thread.o: thread.c $(defs_h) gdbthread.h $(gdbcmd_h) target.h top.o: top.c top.h $(bfd_h) $(getopt_h) $(readline_headers) call-cmds.h \ $(defs_h) $(gdbcmd_h) $(inferior_h) language.h signals.h \ - $(remote_utils_h) gdb_string.h $(event_loop_h) + $(remote_utils_h) gdb_string.h $(event_loop_h) $(version_h) typeprint.o: typeprint.c $(defs_h) $(expression_h) $(gdbcmd_h) \ $(gdbcore_h) $(gdbtypes_h) language.h $(symtab_h) target.h \ @@ -1645,8 +1672,12 @@ xcoffread.o: xcoffread.c $(bfd_h) $(INCLUDE_DIR)/aout/stab.def \ xcoffsolib.o: xcoffsolib.c $(bfd_h) $(defs_h) xcoffsolib.h +# FIXME: z8k-tdep.c calls _initialize_gdbtypes(). Since that isn't +# declared -Wimplicit fails. It should be using the GDBARCH framework. +# cagney 1999-09-02. z8k-tdep.o: z8k-tdep.c $(bfd_h) $(dis-asm_h) $(defs_h) $(frame_h) \ - $(gdbcmd_h) $(gdbtypes_h) $(symtab_h) $(gdbcore_h) + $(gdbcmd_h) $(gdbtypes_h) $(symtab_h) $(gdbcore_h) $(value_h) + $(CC) -c $(INTERNAL_WARN_CFLAGS) $(NO_WERROR_CFLAGS) $< c-exp.tab.o: c-exp.tab.c c-lang.h $(defs_h) $(expression_h) \ $(gdbtypes_h) language.h parser-defs.h $(symtab_h) $(value_h) \ diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 664b131..e4962d0 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -465,7 +465,7 @@ heuristic_proc_start (pc) else warning ("Hit heuristic-fence-post without finding"); - warning ("enclosing function for address 0x%lx", pc); + warning ("enclosing function for address 0x%s", paddr_nz (pc)); if (!blurb_printed) { printf_filtered ("\ diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index 6e0cf8d..c8e4cc7 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -27,6 +27,10 @@ #include "symtab.h" #include "gdbcmd.h" +/* Local functions */ + +static int arc_set_cpu_type (char *str); + /* Current CPU, set with the "set cpu" command. */ static int arc_bfd_mach_type; char *arc_cpu_type; @@ -404,7 +408,7 @@ frame_find_saved_regs (fip, fsrp) } void -push_dummy_frame () +arc_push_dummy_frame (void) { CORE_ADDR sp = read_register (SP_REGNUM); int regnum; @@ -425,7 +429,7 @@ push_dummy_frame () } void -pop_frame () +arc_pop_frame (void) { struct frame_info *frame = get_current_frame (); CORE_ADDR fp; @@ -641,9 +645,7 @@ arc_print_insn (vma, info) /* Command to set cpu type. */ void -arc_set_cpu_type_command (args, from_tty) - char *args; - int from_tty; +arc_set_cpu_type_command (char *args, int from_tty) { int i; @@ -677,7 +679,7 @@ arc_show_cpu_type_command (args, from_tty) /* Modify the actual cpu type. Result is a boolean indicating success. */ -int +static int arc_set_cpu_type (str) char *str; { diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 6dea775..8b3d133 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1049,8 +1049,6 @@ gen_sub (ax, value, value1, value2) struct agent_expr *ax; struct axs_value *value, *value1, *value2; { - struct type *element; - if (value1->type->code == TYPE_CODE_PTR) { /* Is it PTR - INT? */ @@ -1943,8 +1941,6 @@ void _initialize_ax_gdb PARAMS ((void)); void _initialize_ax_gdb () { - struct cmd_list_element *c; - add_cmd ("agent", class_maintenance, agent_command, "Translate an expression into remote agent bytecode.", &maintenancelist); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 46f5a72..e61fab3 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3415,10 +3415,8 @@ solib_load_unload_1 (hookname, tempflag, dll_pathname, cond_string, bp_kind) { struct breakpoint *b; struct symtabs_and_lines sals; - struct symtab_and_line sal; struct cleanup *old_chain; struct cleanup *canonical_strings_chain = NULL; - int i; char *addr_start = hookname; char *addr_end = NULL; char **canonical = (char **) NULL; @@ -4101,9 +4099,9 @@ break_at_finish_at_depth_command_1 (arg, flag, from_tty) { addr_string = (char *) xmalloc (26 + extra_args_len); if (extra_args_len) - sprintf (addr_string, "*0x%x %s", high, extra_args); + sprintf (addr_string, "*0x%s %s", paddr_nz (high), extra_args); else - sprintf (addr_string, "*0x%x", high); + sprintf (addr_string, "*0x%s", paddr_nz (high)); break_command_1 (addr_string, flag, from_tty); free (addr_string); } @@ -4138,7 +4136,7 @@ break_at_finish_command_1 (arg, flag, from_tty) if (selected_frame) { addr_string = (char *) xmalloc (15); - sprintf (addr_string, "*0x%x", selected_frame->pc); + sprintf (addr_string, "*0x%s", paddr_nz (selected_frame->pc)); if (arg) if_arg = 1; } @@ -4186,9 +4184,9 @@ break_at_finish_command_1 (arg, flag, from_tty) { break_string = (char *) xmalloc (extra_args_len + 26); if (extra_args_len) - sprintf (break_string, "*0x%x %s", high, extra_args); + sprintf (break_string, "*0x%s %s", paddr_nz (high), extra_args); else - sprintf (break_string, "*0x%x", high); + sprintf (break_string, "*0x%s", paddr_nz (high)); break_command_1 (break_string, flag, from_tty); free (break_string); } @@ -4666,7 +4664,6 @@ until_break_command (arg, from_tty) struct frame_info *prev_frame = get_prev_frame (selected_frame); struct breakpoint *breakpoint; struct cleanup *old_chain; - struct continuation_arg *arg1, *arg2; clear_proceed_status (); @@ -5238,7 +5235,6 @@ create_exception_catchpoint (tempflag, cond_string, ex_event, sal) struct symtab_and_line *sal; { struct breakpoint *b; - int i; int thread = -1; /* All threads. */ if (!sal) /* no exception support? */ diff --git a/gdb/coffread.c b/gdb/coffread.c index 3ec0b70..b98e8ce 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -201,7 +201,7 @@ static void patch_opaque_types PARAMS ((struct symtab *)); static void patch_type PARAMS ((struct type *, struct type *)); -static void enter_linenos PARAMS ((long, int, int, struct section_offsets *)); +static void enter_linenos PARAMS ((long, int, int, struct objfile *)); static void free_linetab PARAMS ((void)); @@ -1081,7 +1081,7 @@ coff_symtab_read (symtab_offset, nsyms, objfile) fcn_first_line_addr); else enter_linenos (fcn_line_ptr, fcn_first_line, fcn_last_line, - objfile->section_offsets); + objfile); finish_block (new->name, &local_symbols, new->old_blocks, new->start_addr, @@ -1389,11 +1389,11 @@ free_linetab () #endif static void -enter_linenos (file_offset, first_line, last_line, section_offsets) +enter_linenos (file_offset, first_line, last_line, objfile) long file_offset; register int first_line; register int last_line; - struct section_offsets *section_offsets; + struct objfile *objfile; { register char *rawptr; struct internal_lineno lptr; @@ -1423,7 +1423,7 @@ enter_linenos (file_offset, first_line, last_line, section_offsets) if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line) record_line (current_subfile, first_line + L_LNNO32 (&lptr), lptr.l_addr.l_paddr - + ANOFFSET (section_offsets, SECT_OFF_TEXT)); + + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT)); else break; } diff --git a/gdb/command.c b/gdb/command.c index 28d07fc..cb04541 100644 --- a/gdb/command.c +++ b/gdb/command.c @@ -1374,8 +1374,6 @@ do_setshow_command (arg, from_tty, c) { case var_string: { - unsigned char *p; - fputs_filtered ("\"", gdb_stdout); if (*(unsigned char **) c->var) fputstr_filtered (*(unsigned char **) c->var, '"', gdb_stdout); diff --git a/gdb/config/alpha/tm-alpha.h b/gdb/config/alpha/tm-alpha.h index f7e8a79..8b3c5ba 100644 --- a/gdb/config/alpha/tm-alpha.h +++ b/gdb/config/alpha/tm-alpha.h @@ -408,7 +408,7 @@ init_extra_frame_info PARAMS ((struct frame_info *)); #define PRINT_EXTRA_FRAME_INFO(fi) \ { \ if (fi && fi->proc_desc && fi->proc_desc->pdr.framereg < NUM_REGS) \ - printf_filtered (" frame pointer is at %s+%d\n", \ + printf_filtered (" frame pointer is at %s+%ld\n", \ REGISTER_NAME (fi->proc_desc->pdr.framereg), \ fi->proc_desc->pdr.frameoffset); \ } diff --git a/gdb/config/arc/tm-arc.h b/gdb/config/arc/tm-arc.h index 90949e3..34fabaf 100644 --- a/gdb/config/arc/tm-arc.h +++ b/gdb/config/arc/tm-arc.h @@ -309,12 +309,14 @@ extern void frame_find_saved_regs (); /* See arc-tdep.c */ /* Things needed for making calls to functions in the inferior process */ +void arc_push_dummy_frame (void); #define PUSH_DUMMY_FRAME \ - push_dummy_frame () + arc_push_dummy_frame () /* Discard from the stack the innermost frame, restoring all registers. */ +void arc_pop_frame (void); #define POP_FRAME \ - pop_frame () + arc_pop_frame () /* This sequence of words is the instructions bl xxxx, flag 1 */ #define CALL_DUMMY { 0x28000000, 0x1fbe8001 } diff --git a/gdb/config/d30v/tm-d30v.h b/gdb/config/d30v/tm-d30v.h index 2c6131b..ac7940f 100644 --- a/gdb/config/d30v/tm-d30v.h +++ b/gdb/config/d30v/tm-d30v.h @@ -215,6 +215,7 @@ extern void d30v_init_extra_frame_info PARAMS ((int fromleaf, struct frame_info #define FRAMELESS_FUNCTION_INVOCATION(FI) \ (frameless_look_for_prologue (FI)) +CORE_ADDR d30v_frame_chain (struct frame_info *frame); #define FRAME_CHAIN(FRAME) d30v_frame_chain(FRAME) extern int d30v_frame_chain_valid PARAMS ((CORE_ADDR, struct frame_info *)); #define FRAME_CHAIN_VALID(chain, thisframe) d30v_frame_chain_valid (chain, thisframe) @@ -222,6 +223,7 @@ extern int d30v_frame_chain_valid PARAMS ((CORE_ADDR, struct frame_info *)); #define FRAME_ARGS_ADDRESS(fi) (fi)->frame #define FRAME_LOCALS_ADDRESS(fi) (fi)->frame +void d30v_init_frame_pc (int fromleaf, struct frame_info *prev); #define INIT_FRAME_PC_FIRST(fromleaf, prev) d30v_init_frame_pc(fromleaf, prev) #define INIT_FRAME_PC(fromleaf, prev) /* nada */ diff --git a/gdb/config/i386/linux.mh b/gdb/config/i386/linux.mh index 30de91d..1fe1e36 100644 --- a/gdb/config/i386/linux.mh +++ b/gdb/config/i386/linux.mh @@ -4,4 +4,5 @@ XM_FILE= xm-linux.h XDEPFILES= ser-tcp.o NAT_FILE= nm-linux.h -NATDEPFILES= infptrace.o solib.o inftarg.o fork-child.o corelow.o core-aout.o core-regset.o i386v-nat.o i386v4-nat.o +NATDEPFILES= infptrace.o solib.o inftarg.o fork-child.o corelow.o \ + core-aout.o core-regset.o i386v-nat.o i386-linux-nat.o linux-thread.o diff --git a/gdb/config/i386/nm-linux.h b/gdb/config/i386/nm-linux.h index d323838..df964f4 100644 --- a/gdb/config/i386/nm-linux.h +++ b/gdb/config/i386/nm-linux.h @@ -64,6 +64,9 @@ extern int kernel_u_size PARAMS ((void)); #include "solib.h" /* Support for shared libraries. */ #endif +/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ +#define FETCH_INFERIOR_REGISTERS + extern CORE_ADDR i386_stopped_by_watchpoint PARAMS ((int)); extern int @@ -71,4 +74,22 @@ i386_insert_watchpoint PARAMS ((int pid, CORE_ADDR addr, int len, int rw)); extern int i386_remove_watchpoint PARAMS ((int pid, CORE_ADDR addr, int len)); +/* Support for the glibc linuxthreads package. */ + +#ifdef __STDC__ +struct objfile; +#endif + +extern void +linuxthreads_new_objfile PARAMS ((struct objfile *objfile)); +#define target_new_objfile(OBJFILE) linuxthreads_new_objfile (OBJFILE) + +extern char * +linuxthreads_pid_to_str PARAMS ((int pid)); +#define target_pid_to_str(PID) linuxthreads_pid_to_str (PID) + +extern int +linuxthreads_prepare_to_proceed PARAMS ((int step)); +#define PREPARE_TO_PROCEED(select_it) linuxthreads_prepare_to_proceed (1) + #endif /* #ifndef NM_LINUX_H */ diff --git a/gdb/config/i386/tm-linux.h b/gdb/config/i386/tm-linux.h index 0767bd9..e4f70a2 100644 --- a/gdb/config/i386/tm-linux.h +++ b/gdb/config/i386/tm-linux.h @@ -21,8 +21,7 @@ #ifndef TM_LINUX_H #define TM_LINUX_H -/* FIXME: If nothing else gets added to this file, it could be removed - and configure could just use tm-i386.h instead. -fnf */ +#define I386_GNULINUX_TARGET #include "i386/tm-i386.h" @@ -39,9 +38,196 @@ #include "tm-sysv4.h" +/* copy of tm-cygwin32.h */ +#undef REGISTER_RAW_SIZE +#undef REGISTER_VIRTUAL_SIZE +#undef REGISTER_VIRTUAL_TYPE +#undef REGISTER_NAMES +#undef REGISTER_BYTES +#undef REGISTER_BYTE +#undef MAX_REGISTER_VIRTUAL_SIZE +#undef NUM_REGS +#undef NUM_FREGS + +/* Number of machine registers */ + +#define NUM_REGS 31 +#define NUM_FREGS 15 + +/* Initializer for an array of names of registers. + There should be NUM_REGS strings in this initializer. */ + +/* the order of the first 8 registers must match the compiler's + * numbering scheme (which is the same as the 386 scheme) + * also, this table must match regmap in i386-pinsn.c. + */ + +#define REGISTER_NAMES { "eax", "ecx", "edx", "ebx", \ + "esp", "ebp", "esi", "edi", \ + "eip", "eflags","cs", "ss", \ + "ds", "es", "fs", "gs", \ + "cwd", "swd", "twd", "fip", \ + "fcs", "fopo", "fos", \ + "st", "st1", "st2", "st3", \ + "st4", "st5", "st6", "st7",} + +#define LOW_RETURN_REGNUM 0 /* holds low four bytes of result */ +#define HIGH_RETURN_REGNUM 2 /* holds high four bytes of result */ + +#define FPSTART_REGNUM 16 /* start of FPU registers */ +#define FPCONTROL_REGNUM 16 /* FPU control register */ +#define FPSTATUS_REGNUM 17 /* FPU status register */ +#define FPTAG_REGNUM 18 /* FPU tag register */ +#define FPDATA_REGNUM 23 /* actual floating-point values */ +#define FPEND_REGNUM (FPSTART_REGNUM + 14) /* last FPU register */ + +#define FPENV_BYTES (7 * 4) + +#define FPREG_RAW_SIZE (10) + +/* Total amount of space needed to store our copies of the machine's + FPU state. */ + +#define FPREG_BYTES (FPENV_BYTES + 8 * FPREG_RAW_SIZE) + +/* Total amount of space needed to store our copies of the machine's + register state, the array `registers'. */ + +#define REGISTER_BYTES (FPSTART_REGNUM * 4 + FPREG_BYTES) + +/* Index within `registers' of the first byte of the space for + register N. */ + +#define REGISTER_BYTE(N) (((N) < FPDATA_REGNUM) ? \ + (N) * 4 : \ + (((N) - FPDATA_REGNUM) * FPREG_RAW_SIZE) \ + + (FPDATA_REGNUM * 4)) + +/* Number of bytes of storage in the actual machine representation + for register N. */ + +#define REGISTER_RAW_SIZE(N) (((N) < FPDATA_REGNUM) ? 4 : FPREG_RAW_SIZE) + +/* Number of bytes of storage in the program's representation + for register N. */ + +#define REGISTER_VIRTUAL_SIZE(N) (((N) < FPDATA_REGNUM) ? 4 : FPREG_RAW_SIZE) + +/* Largest value REGISTER_RAW_SIZE can have. */ + +#undef MAX_REGISTER_RAW_SIZE +#define MAX_REGISTER_RAW_SIZE FPREG_RAW_SIZE + +/* Largest value REGISTER_VIRTUAL_SIZE can have. */ + +#define MAX_REGISTER_VIRTUAL_SIZE FPREG_RAW_SIZE + +#if defined(HAVE_LONG_DOUBLE) && defined(HOST_I386) +/* The host and target are i386 machines and the compiler supports + long doubles. Long doubles on the host therefore have the same + layout as a 387 FPU stack register. */ +#define LD_I387 +#endif + +#define TARGET_LONG_DOUBLE_BIT 80 + +#ifdef LD_I387 +extern int i387_extract_floating (PTR addr, int len, long double *dretptr); +extern int i387_store_floating (PTR addr, int len, long double val); + +#define TARGET_EXTRACT_FLOATING i387_extract_floating +#define TARGET_STORE_FLOATING i387_store_floating + +#define TARGET_ANALYZE_FLOATING \ + do \ + { \ + unsigned expon; \ + \ + low = extract_unsigned_integer (valaddr, 4); \ + high = extract_unsigned_integer (valaddr + 4, 4); \ + expon = extract_unsigned_integer (valaddr + 8, 2); \ + \ + nonnegative = ((expon & 0x8000) == 0); \ + is_nan = ((expon & 0x7fff) == 0x7fff) \ + && ((high & 0x80000000) == 0x80000000) \ + && (((high & 0x7fffffff) | low) != 0); \ + } \ + while (0) +#endif + +#ifndef LD_I387 +/* Nonzero if register N requires conversion + from raw format to virtual format. */ +#define REGISTER_CONVERTIBLE(N) \ + ((N < FPDATA_REGNUM) ? 0 : 1) +#endif + +#ifdef LD_I387 +#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \ +{ \ + long double val = *((long double *)FROM); \ + store_floating ((TO), TYPE_LENGTH (TYPE), val); \ +} +#else +/* Convert data from raw format for register REGNUM in buffer FROM + to virtual format with type TYPE in buffer TO. */ +extern void +i387_to_double PARAMS ((char *, char *)); + +#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \ +{ \ + double val; \ + i387_to_double ((FROM), (char *)&val); \ + store_floating ((TO), TYPE_LENGTH (TYPE), val); \ +} +#endif + +#ifdef LD_I387 +#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \ +{ \ + long double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \ + *((long double *)TO) = val; \ +} +#else +extern void +double_to_i387 PARAMS ((char *, char *)); + +#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \ +{ \ + double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \ + double_to_i387((char *)&val, (TO)); \ +} +#endif + +/* Return the GDB type object for the "standard" data type + of data in register N. */ + +#ifdef LD_I387 +#define REGISTER_VIRTUAL_TYPE(N) \ + ((N < FPDATA_REGNUM) ? builtin_type_int : \ + builtin_type_long_double) +#else +#define REGISTER_VIRTUAL_TYPE(N) \ + ((N < FPDATA_REGNUM) ? builtin_type_int : \ + builtin_type_double) +#endif + +/* end of copy */ + +extern void i387_float_info(void); +#define FLOAT_INFO { i387_float_info (); } + /* The following works around a problem with /usr/include/sys/procfs.h */ #define sys_quotactl 1 +/* Define DO_REGISTERS_INFO() to do machine-specific formatting + of register dumps. */ + +#define DO_REGISTERS_INFO(_regnum, fp) i386_do_registers_info(_regnum, fp) +extern void i386_do_registers_info PARAMS ((int, int)); + +extern void i387_print_register PARAMS ((char *, int)); + /* When the i386 Linux kernel calls a signal handler, the return address points to a bit of code on the stack. These definitions are used to identify this bit of code as a signal trampoline in @@ -104,4 +290,29 @@ extern CORE_ADDR i386_linux_sigtramp_saved_pc PARAMS ((struct frame_info *)); extern CORE_ADDR i386_linux_sigtramp_saved_sp PARAMS ((struct frame_info *)); +/* Some versions of Linux have real-time signal support in the C library, and + some don't. We have to include this file to find out. */ +#include <signal.h> + +#ifdef __SIGRTMIN +#define REALTIME_LO __SIGRTMIN +#define REALTIME_HI (__SIGRTMAX + 1) +#else +#define REALTIME_LO 32 +#define REALTIME_HI 64 +#endif + +/* When we call a function in a shared library, and the PLT sends us + into the dynamic linker to find the function's real address, we + need to skip over the dynamic linker call. This function decides + when to skip, and where to skip to. See the comments for + SKIP_SOLIB_RESOLVER at the top of infrun.c. */ +#define SKIP_SOLIB_RESOLVER i386_linux_skip_solib_resolver +extern CORE_ADDR i386_linux_skip_solib_resolver (CORE_ADDR pc); + +/* N_FUN symbols in shared libaries have 0 for their values and need + to be relocated. */ +#define SOFUN_ADDRESS_MAYBE_MISSING + #endif /* #ifndef TM_LINUX_H */ + diff --git a/gdb/config/i386/xm-linux.h b/gdb/config/i386/xm-linux.h index b788b67..fb07b42 100644 --- a/gdb/config/i386/xm-linux.h +++ b/gdb/config/i386/xm-linux.h @@ -21,6 +21,8 @@ #ifndef XM_LINUX_H #define XM_LINUX_H +#define HOST_I386 + #define HOST_BYTE_ORDER LITTLE_ENDIAN #define HAVE_TERMIOS diff --git a/gdb/config/i960/tm-i960.h b/gdb/config/i960/tm-i960.h index 3a6e234..73bb8db 100644 --- a/gdb/config/i960/tm-i960.h +++ b/gdb/config/i960/tm-i960.h @@ -287,6 +287,7 @@ extern use_struct_convention_fn i960_use_struct_convention; by FI does not have a frame on the stack associated with it. If it does not, FRAMELESS is set to 1, else 0. */ +CORE_ADDR leafproc_return (CORE_ADDR ip); #define FRAMELESS_FUNCTION_INVOCATION(FI) \ (leafproc_return ((FI)->pc) != 0) @@ -341,8 +342,10 @@ error("Function calls into the inferior process are not supported on the i960") /* Discard from the stack the innermost frame, restoring all registers. */ + +void i960_pop_frame (void); #define POP_FRAME \ - pop_frame () + i960_pop_frame () /* This sequence of words is the instructions diff --git a/gdb/config/m32r/tm-m32r.h b/gdb/config/m32r/tm-m32r.h index 7898f66..97f0880 100644 --- a/gdb/config/m32r/tm-m32r.h +++ b/gdb/config/m32r/tm-m32r.h @@ -168,6 +168,7 @@ extern CORE_ADDR m32r_skip_prologue PARAMS ((CORE_ADDR pc)); #define COERCE_FLOAT_TO_DOUBLE 1 +extern void m32r_write_sp (CORE_ADDR val); #define TARGET_WRITE_SP m32r_write_sp diff --git a/gdb/config/mips/tm-embed.h b/gdb/config/mips/tm-embed.h index af51a7f..9e0ac86 100644 --- a/gdb/config/mips/tm-embed.h +++ b/gdb/config/mips/tm-embed.h @@ -43,6 +43,7 @@ int remote_mips_remove_watchpoint PARAMS ((CORE_ADDR addr, int len, int type)); #define HAVE_NONSTEPPABLE_WATCHPOINT +int remote_mips_stopped_by_watchpoint (void); #define STOPPED_BY_WATCHPOINT(w) remote_mips_stopped_by_watchpoint () #define TARGET_CAN_USE_HARDWARE_WATCHPOINT(type, cnt, ot) \ diff --git a/gdb/config/mips/tm-mips.h b/gdb/config/mips/tm-mips.h index fecdea6..6e7e72c 100644 --- a/gdb/config/mips/tm-mips.h +++ b/gdb/config/mips/tm-mips.h @@ -579,3 +579,7 @@ typedef unsigned long t_inst; /* Integer big enough to hold an instruction */ (((long) MSYMBOL_INFO (msym) & 0x80000000) != 0) #define MSYMBOL_SIZE(msym) \ ((long) MSYMBOL_INFO (msym) & 0x7fffffff) + + +/* Command to set the processor type. */ +extern void mips_set_processor_type_command (char *, int); diff --git a/gdb/config/mn10200/tm-mn10200.h b/gdb/config/mn10200/tm-mn10200.h index 8816de0..cb2a57f 100644 --- a/gdb/config/mn10200/tm-mn10200.h +++ b/gdb/config/mn10200/tm-mn10200.h @@ -161,6 +161,8 @@ extern CORE_ADDR mn10200_frame_saved_pc PARAMS ((struct frame_info *)); } \ } + +extern CORE_ADDR mn10200_store_struct_return (CORE_ADDR addr, CORE_ADDR sp); #define STORE_STRUCT_RETURN(STRUCT_ADDR, SP) \ (SP) = mn10200_store_struct_return (STRUCT_ADDR, SP) diff --git a/gdb/config/mn10300/tm-mn10300.h b/gdb/config/mn10300/tm-mn10300.h index f9e38e0..4bc76fd 100644 --- a/gdb/config/mn10300/tm-mn10300.h +++ b/gdb/config/mn10300/tm-mn10300.h @@ -104,6 +104,8 @@ void mn10300_store_return_value PARAMS ((struct type * type, char *valbuf)); #define STORE_RETURN_VALUE(TYPE, VALBUF) \ mn10300_store_return_value (TYPE, VALBUF) + +extern CORE_ADDR mn10300_store_struct_return (CORE_ADDR addr, CORE_ADDR sp); #define STORE_STRUCT_RETURN(STRUCT_ADDR, SP) \ (mn10300_store_struct_return (STRUCT_ADDR, SP)) diff --git a/gdb/config/sparc/tm-sparc.h b/gdb/config/sparc/tm-sparc.h index a8db2f5..635a693 100644 --- a/gdb/config/sparc/tm-sparc.h +++ b/gdb/config/sparc/tm-sparc.h @@ -339,8 +339,8 @@ extern void sparc_init_extra_frame_info PARAMS ((int, struct frame_info *)); #define PRINT_EXTRA_FRAME_INFO(fi) \ { \ if ((fi) && (fi)->flat) \ - printf_filtered (" flat, pc saved at 0x%x, fp saved at 0x%x\n", \ - (fi)->pc_addr, (fi)->fp_addr); \ + printf_filtered (" flat, pc saved at 0x%s, fp saved at 0x%s\n", \ + paddr_nz ((fi)->pc_addr), paddr_nz ((fi)->fp_addr)); \ } #define FRAME_CHAIN(thisframe) (sparc_frame_chain (thisframe)) diff --git a/gdb/config/z8k/tm-z8k.h b/gdb/config/z8k/tm-z8k.h index bf6d4c9..f781e0a 100644 --- a/gdb/config/z8k/tm-z8k.h +++ b/gdb/config/z8k/tm-z8k.h @@ -42,7 +42,7 @@ to reach some "real" code. */ #define SKIP_PROLOGUE(ip) (z8k_skip_prologue (ip)) -extern CORE_ADDR mz8k_skip_prologue PARAMS ((CORE_ADDR ip)); +extern CORE_ADDR z8k_skip_prologue PARAMS ((CORE_ADDR ip)); /* Immediately after a function call, return the saved pc. @@ -50,7 +50,9 @@ extern CORE_ADDR mz8k_skip_prologue PARAMS ((CORE_ADDR ip)); the new frame is not set up until the new function executes some instructions. */ -#define SAVED_PC_AFTER_CALL(frame) saved_pc_after_call(frame) + +extern int z8k_saved_pc_after_call (struct frame_info *frame); +#define SAVED_PC_AFTER_CALL(frame) z8k_saved_pc_after_call(frame) /* Stack grows downward. */ @@ -167,7 +169,8 @@ extern CORE_ADDR mz8k_skip_prologue PARAMS ((CORE_ADDR ip)); is the address of a ptr sized byte word containing the calling frame's address. */ -#define FRAME_CHAIN(thisframe) frame_chain(thisframe); +extern CORE_ADDR z8k_frame_chain (struct frame_info *thisframe); +#define FRAME_CHAIN(thisframe) z8k_frame_chain(thisframe); @@ -179,7 +182,8 @@ extern CORE_ADDR mz8k_skip_prologue PARAMS ((CORE_ADDR ip)); #define FRAMELESS_FUNCTION_INVOCATION(FI) \ (frameless_look_for_prologue (FI)) -#define FRAME_SAVED_PC(FRAME) frame_saved_pc(FRAME) +extern CORE_ADDR z8k_frame_saved_pc (struct frame_info *frame); +#define FRAME_SAVED_PC(FRAME) z8k_frame_saved_pc(FRAME) #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) @@ -276,9 +280,11 @@ int sim_z8001_mode; #define NO_STD_REGS -#define PRINT_REGISTER_HOOK(regno) print_register_hook(regno) +extern void z8k_print_register_hook (int regno); +#define PRINT_REGISTER_HOOK(regno) z8k_print_register_hook(regno) +extern void z8k_set_pointer_size (int newsize); #define INIT_EXTRA_SYMTAB_INFO \ z8k_set_pointer_size(objfile->obfd->arch_info->bits_per_address); diff --git a/gdb/configure b/gdb/configure index 6701bd1..778cdef 100755 --- a/gdb/configure +++ b/gdb/configure @@ -5163,10 +5163,9 @@ case "${enableval}" in build_warnings="${t} ${build_warnings}";; *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;; esac -else - build_warnings="" +if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then + echo "Setting warning flags = $build_warnings" 6>&1 fi - WARN_CFLAGS="" WERROR_CFLAGS="" if test "x${build_warnings}" != x -a "x$GCC" = xyes @@ -5180,6 +5179,10 @@ then esac done fi +else + build_warnings="" +fi + @@ -5216,12 +5219,12 @@ fi # In the Cygwin environment, we need some additional flags. echo $ac_n "checking for cygwin""... $ac_c" 1>&6 -echo "configure:5343: checking for cygwin" >&5 +echo "configure:5346: checking for cygwin" >&5 if eval "test \"`echo '$''{'gdb_cv_os_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5348 "configure" +#line 5351 "configure" #include "confdefs.h" #if defined (__CYGWIN__) || defined (__CYGWIN32__) @@ -5255,7 +5258,7 @@ if test x$gdb_cv_os_cygwin = xyes; then else TERM_LIB= echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6 -echo "configure:5382: checking for tgetent in -lncurses" >&5 +echo "configure:5385: checking for tgetent in -lncurses" >&5 ac_lib_var=`echo ncurses'_'tgetent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5263,7 +5266,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lncurses $LIBS" cat > conftest.$ac_ext <<EOF -#line 5390 "configure" +#line 5393 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -5274,7 +5277,7 @@ int main() { tgetent() ; return 0; } EOF -if { (eval echo configure:5401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5404: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5293,7 +5296,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for tgetent in -lHcurses""... $ac_c" 1>&6 -echo "configure:5420: checking for tgetent in -lHcurses" >&5 +echo "configure:5423: checking for tgetent in -lHcurses" >&5 ac_lib_var=`echo Hcurses'_'tgetent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5301,7 +5304,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lHcurses $LIBS" cat > conftest.$ac_ext <<EOF -#line 5428 "configure" +#line 5431 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -5312,7 +5315,7 @@ int main() { tgetent() ; return 0; } EOF -if { (eval echo configure:5439: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5442: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5331,7 +5334,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for tgetent in -ltermlib""... $ac_c" 1>&6 -echo "configure:5458: checking for tgetent in -ltermlib" >&5 +echo "configure:5461: checking for tgetent in -ltermlib" >&5 ac_lib_var=`echo termlib'_'tgetent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5339,7 +5342,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ltermlib $LIBS" cat > conftest.$ac_ext <<EOF -#line 5466 "configure" +#line 5469 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -5350,7 +5353,7 @@ int main() { tgetent() ; return 0; } EOF -if { (eval echo configure:5477: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5480: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5369,7 +5372,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6 -echo "configure:5496: checking for tgetent in -ltermcap" >&5 +echo "configure:5499: checking for tgetent in -ltermcap" >&5 ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5377,7 +5380,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ltermcap $LIBS" cat > conftest.$ac_ext <<EOF -#line 5504 "configure" +#line 5507 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -5388,7 +5391,7 @@ int main() { tgetent() ; return 0; } EOF -if { (eval echo configure:5515: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5518: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5407,7 +5410,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6 -echo "configure:5534: checking for tgetent in -lcurses" >&5 +echo "configure:5537: checking for tgetent in -lcurses" >&5 ac_lib_var=`echo curses'_'tgetent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5415,7 +5418,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcurses $LIBS" cat > conftest.$ac_ext <<EOF -#line 5542 "configure" +#line 5545 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -5426,7 +5429,7 @@ int main() { tgetent() ; return 0; } EOF -if { (eval echo configure:5553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5556: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5445,7 +5448,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for tgetent in -lterminfo""... $ac_c" 1>&6 -echo "configure:5572: checking for tgetent in -lterminfo" >&5 +echo "configure:5575: checking for tgetent in -lterminfo" >&5 ac_lib_var=`echo terminfo'_'tgetent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5453,7 +5456,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lterminfo $LIBS" cat > conftest.$ac_ext <<EOF -#line 5580 "configure" +#line 5583 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -5464,7 +5467,7 @@ int main() { tgetent() ; return 0; } EOF -if { (eval echo configure:5591: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5516,7 +5519,7 @@ fi # Uses ac_ vars as temps to allow command line to override cache and checks. # --without-x overrides everything else, but does not touch the cache. echo $ac_n "checking for X""... $ac_c" 1>&6 -echo "configure:6727: checking for X" >&5 +echo "configure:6730: checking for X" >&5 # Check whether --with-x or --without-x was given. if test "${with_x+set}" = set; then @@ -5578,12 +5581,12 @@ if test "$ac_x_includes" = NO; then # First, try using that file with no special directory specified. cat > conftest.$ac_ext <<EOF -#line 6789 "configure" +#line 6792 "configure" #include "confdefs.h" #include <$x_direct_test_include> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:6794: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6797: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5652,14 +5655,14 @@ if test "$ac_x_libraries" = NO; then ac_save_LIBS="$LIBS" LIBS="-l$x_direct_test_library $LIBS" cat > conftest.$ac_ext <<EOF -#line 6863 "configure" +#line 6866 "configure" #include "confdefs.h" int main() { ${x_direct_test_function}() ; return 0; } EOF -if { (eval echo configure:6870: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6873: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* LIBS="$ac_save_LIBS" # We can link X programs with no special library path. @@ -5939,12 +5942,12 @@ fi echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:7221: checking for Cygwin environment" >&5 +echo "configure:7224: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 7226 "configure" +#line 7229 "configure" #include "confdefs.h" int main() { @@ -5955,7 +5958,7 @@ int main() { return __CYGWIN__; ; return 0; } EOF -if { (eval echo configure:7237: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7240: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -5972,19 +5975,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:7254: checking for mingw32 environment" >&5 +echo "configure:7257: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 7259 "configure" +#line 7262 "configure" #include "confdefs.h" int main() { return __MINGW32__; ; return 0; } EOF -if { (eval echo configure:7266: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7269: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -6003,7 +6006,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=yes echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:7285: checking for executable suffix" >&5 +echo "configure:7288: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6013,7 +6016,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:7295: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:7298: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj) ;; diff --git a/gdb/configure.in b/gdb/configure.in index f558110..ac2620a 100644 --- a/gdb/configure.in +++ b/gdb/configure.in @@ -399,8 +399,10 @@ case "${enableval}" in *,) t=`echo "${enableval}" | sed -e "s/,/ /g"` build_warnings="${t} ${build_warnings}";; *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;; -esac],[build_warnings=""])dnl - +esac +if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then + echo "Setting warning flags = $build_warnings" 6>&1 +fi WARN_CFLAGS="" WERROR_CFLAGS="" if test "x${build_warnings}" != x -a "x$GCC" = xyes @@ -413,7 +415,8 @@ then *) WARN_CFLAGS="${WARN_CFLAGS} $w" esac done -fi +fi],[build_warnings=""])dnl + AC_SUBST(WARN_CFLAGS) AC_SUBST(WERROR_CFLAGS) diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index ff2bec8..4ec0853 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -726,7 +726,7 @@ cp_print_class_member (valaddr, domain, stream, prefix) fprintf_filtered (stream, " (offset in bits)"); } else - fprintf_filtered (stream, "%d", val >> 3); + fprintf_filtered (stream, "%ld", (long) (val >> 3)); } diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c index 902f36b..e545f21 100644 --- a/gdb/d10v-tdep.c +++ b/gdb/d10v-tdep.c @@ -729,34 +729,35 @@ show_regs (args, from_tty) int from_tty; { int a; - printf_filtered ("PC=%04x (0x%x) PSW=%04x RPT_S=%04x RPT_E=%04x RPT_C=%04x\n", - read_register (PC_REGNUM), D10V_MAKE_IADDR (read_register (PC_REGNUM)), - read_register (PSW_REGNUM), - read_register (24), - read_register (25), - read_register (23)); - printf_filtered ("R0-R7 %04x %04x %04x %04x %04x %04x %04x %04x\n", - read_register (0), - read_register (1), - read_register (2), - read_register (3), - read_register (4), - read_register (5), - read_register (6), - read_register (7)); - printf_filtered ("R8-R15 %04x %04x %04x %04x %04x %04x %04x %04x\n", - read_register (8), - read_register (9), - read_register (10), - read_register (11), - read_register (12), - read_register (13), - read_register (14), - read_register (15)); - printf_filtered ("IMAP0 %04x IMAP1 %04x DMAP %04x\n", - read_register (IMAP0_REGNUM), - read_register (IMAP1_REGNUM), - read_register (DMAP_REGNUM)); + printf_filtered ("PC=%04lx (0x%lx) PSW=%04lx RPT_S=%04lx RPT_E=%04lx RPT_C=%04lx\n", + (long) read_register (PC_REGNUM), + (long) D10V_MAKE_IADDR (read_register (PC_REGNUM)), + (long) read_register (PSW_REGNUM), + (long) read_register (24), + (long) read_register (25), + (long) read_register (23)); + printf_filtered ("R0-R7 %04lx %04lx %04lx %04lx %04lx %04lx %04lx %04lx\n", + (long) read_register (0), + (long) read_register (1), + (long) read_register (2), + (long) read_register (3), + (long) read_register (4), + (long) read_register (5), + (long) read_register (6), + (long) read_register (7)); + printf_filtered ("R8-R15 %04lx %04lx %04lx %04lx %04lx %04lx %04lx %04lx\n", + (long) read_register (8), + (long) read_register (9), + (long) read_register (10), + (long) read_register (11), + (long) read_register (12), + (long) read_register (13), + (long) read_register (14), + (long) read_register (15)); + printf_filtered ("IMAP0 %04lx IMAP1 %04lx DMAP %04lx\n", + (long) read_register (IMAP0_REGNUM), + (long) read_register (IMAP1_REGNUM), + (long) read_register (DMAP_REGNUM)); printf_filtered ("A0-A1"); for (a = A0_REGNUM; a <= A0_REGNUM + 1; a++) { @@ -1129,10 +1130,11 @@ trace_info (args, from_tty) for (i = 0; i < trace_data.size; ++i) { - printf_filtered ("%d: %d instruction%s at 0x%x\n", - i, trace_data.counts[i], + printf_filtered ("%d: %d instruction%s at 0x%s\n", + i, + trace_data.counts[i], (trace_data.counts[i] == 1 ? "" : "s"), - trace_data.addrs[i]); + paddr_nz (trace_data.addrs[i])); } } else @@ -1261,7 +1263,7 @@ tdisassemble_command (arg, from_tty) high = low; } - printf_filtered ("Dump of trace from %d to %d:\n", low, high); + printf_filtered ("Dump of trace from %s to %s:\n", paddr_u (low), paddr_u (high)); display_trace (low, high); diff --git a/gdb/d30v-tdep.c b/gdb/d30v-tdep.c index 862566f..d66fefbbe 100644 --- a/gdb/d30v-tdep.c +++ b/gdb/d30v-tdep.c @@ -34,6 +34,8 @@ #include "symfile.h" #include "objfiles.h" +#include "language.h" /* For local_hex_string() */ + void d30v_frame_find_saved_regs PARAMS ((struct frame_info * fi, struct frame_saved_regs * fsr)); void d30v_frame_find_saved_regs_offsets PARAMS ((struct frame_info * fi, @@ -727,10 +729,11 @@ d30v_print_register (regnum, tabular) if (regnum < A0_REGNUM) { if (tabular) - printf_filtered ("%08x", read_register (regnum)); + printf_filtered ("%08lx", (long) read_register (regnum)); else - printf_filtered ("0x%x %d", read_register (regnum), - read_register (regnum)); + printf_filtered ("0x%lx %ld", + (long) read_register (regnum), + (long) read_register (regnum)); } else { @@ -1162,10 +1165,10 @@ trace_info (args, from_tty) for (i = 0; i < trace_data.size; ++i) { - printf_filtered ("%d: %d instruction%s at 0x%x\n", + printf_filtered ("%d: %d instruction%s at 0x%s\n", i, trace_data.counts[i], (trace_data.counts[i] == 1 ? "" : "s"), - trace_data.addrs[i]); + paddr_nz (trace_data.addrs[i])); } } else @@ -1294,7 +1297,9 @@ tdisassemble_command (arg, from_tty) high = low; } - printf_filtered ("Dump of trace from %d to %d:\n", low, high); + printf_filtered ("Dump of trace from %s to %s:\n", + paddr_u (low), + paddr_u (high)); display_trace (low, high); diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 73eb3f4..d9ad040 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -289,7 +289,7 @@ static void read_dbx_dynamic_symtab PARAMS ((struct objfile * objfile)); static void -read_dbx_symtab PARAMS ((struct objfile *, CORE_ADDR, int)); +read_dbx_symtab PARAMS ((struct objfile *)); static void free_bincl_list PARAMS ((struct objfile *)); @@ -333,6 +333,10 @@ add_old_header_file PARAMS ((char *, int)); static void add_this_object_header_file PARAMS ((int)); +static struct partial_symtab * +start_psymtab PARAMS ((struct objfile *, char *, CORE_ADDR, int, + struct partial_symbol **, struct partial_symbol **)); + /* Free up old header file tables */ static void @@ -571,8 +575,6 @@ record_minimal_symbol (name, address, type, objfile) put all the relevant info into a "struct dbx_symfile_info", hung off the objfile structure. - SECTION_OFFSETS contains offsets relative to which the symbols in the - various sections are (depending where the sections were actually loaded). MAINLINE is true if we are reading the main symbol table (as opposed to a shared lib or dynamically loaded file). */ @@ -585,8 +587,6 @@ dbx_symfile_read (objfile, mainline) int val; struct cleanup *back_to; - val = strlen (objfile->name); - sym_bfd = objfile->obfd; /* .o and .nlm files are relocatables with text, data and bss segs based at @@ -625,12 +625,9 @@ dbx_symfile_read (objfile, mainline) init_minimal_symbol_collection (); make_cleanup ((make_cleanup_func) discard_minimal_symbols, 0); - /* Now that the symbol table data of the executable file are all in core, - process them and define symbols accordingly. */ + /* Read stabs data from executable file and define symbols. */ - read_dbx_symtab (objfile, - DBX_TEXT_ADDR (objfile), - DBX_TEXT_SIZE (objfile)); + read_dbx_symtab (objfile); /* Add the dynamic symbols. */ @@ -1239,21 +1236,17 @@ read_dbx_dynamic_symtab (objfile) do_cleanups (back_to); } -/* Given pointers to an a.out symbol table in core containing dbx - style data, setup partial_symtab's describing each source file for - which debugging information is available. - SYMFILE_NAME is the name of the file we are reading from - and SECTION_OFFSETS is the set of offsets for the various sections - of the file (a set of zeros if the mainline program). */ +/* Setup partial_symtab's describing each source file for which + debugging information is available. */ static void -read_dbx_symtab (objfile, text_addr, text_size) +read_dbx_symtab (objfile) struct objfile *objfile; - CORE_ADDR text_addr; - int text_size; { register struct external_nlist *bufp = 0; /* =0 avoids gcc -Wall glitch */ struct internal_nlist nlist; + CORE_ADDR text_addr; + int text_size; register char *namestring; int nsl; @@ -1276,6 +1269,9 @@ read_dbx_symtab (objfile, text_addr, text_size) struct partial_symtab **dependency_list; int dependencies_used, dependencies_allocated; + text_addr = DBX_TEXT_ADDR (objfile); + text_size = DBX_TEXT_SIZE (objfile); + /* FIXME. We probably want to change stringtab_global rather than add this while processing every symbol entry. FIXME. */ file_string_table_offset = 0; @@ -1361,8 +1357,8 @@ read_dbx_symtab (objfile, text_addr, text_size) #define CUR_SYMBOL_VALUE nlist.n_value #define CUR_SYMBOL_STRX nlist.n_strx #define DBXREAD_ONLY -#define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms)\ - start_psymtab(ofile, secoff, fname, low, symoff, global_syms, static_syms) +#define START_PSYMTAB(ofile,fname,low,symoff,global_syms,static_syms)\ + start_psymtab(ofile, fname, low, symoff, global_syms, static_syms) #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set)\ end_psymtab(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set) @@ -1385,7 +1381,7 @@ read_dbx_symtab (objfile, text_addr, text_size) /* Don't set pst->texthigh lower than it already is. */ CORE_ADDR text_end = (lowest_text_address == (CORE_ADDR) -1 - ? (text_addr + objfile->section_offsets->offsets[SECT_OFF_TEXT]) + ? (text_addr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT)) : lowest_text_address) + text_size; @@ -1406,11 +1402,9 @@ read_dbx_symtab (objfile, text_addr, text_size) (normal). */ -struct partial_symtab * -start_psymtab (objfile, section_offsets, - filename, textlow, ldsymoff, global_syms, static_syms) +static struct partial_symtab * +start_psymtab (objfile, filename, textlow, ldsymoff, global_syms, static_syms) struct objfile *objfile; - struct section_offsets *section_offsets; char *filename; CORE_ADDR textlow; int ldsymoff; @@ -1418,7 +1412,7 @@ start_psymtab (objfile, section_offsets, struct partial_symbol **static_syms; { struct partial_symtab *result = - start_psymtab_common (objfile, section_offsets, + start_psymtab_common (objfile, objfile->section_offsets, filename, textlow, global_syms, static_syms); result->read_symtab_private = (char *) @@ -2635,7 +2629,6 @@ elfstab_build_psymtabs (objfile, mainline, bfd *sym_bfd = objfile->obfd; char *name = bfd_get_filename (sym_bfd); struct dbx_symfile_info *info; - asection *text_sect; /* There is already a dbx_symfile_info allocated by our caller. It might even contain some info from the ELF symtab to help us. */ diff --git a/gdb/dcache.c b/gdb/dcache.c index 821eb13..a184498 100644 --- a/gdb/dcache.c +++ b/gdb/dcache.c @@ -525,8 +525,8 @@ dcache_info (exp, tty) for (p = last_cache->valid_head; p; p = p->p) { int j; - printf_filtered ("Line at %08xd, referenced %d times\n", - p->addr, p->refs); + printf_filtered ("Line at %s, referenced %d times\n", + paddr (p->addr), p->refs); for (j = 0; j < LINE_SIZE; j++) printf_filtered ("%02x", p->data[j] & 0xFF); @@ -517,12 +517,13 @@ extern void fputstr_unfiltered PARAMS ((const char *str, int quotr, GDB_FILE *st extern void fputstrn_unfiltered PARAMS ((const char *str, int n, int quotr, GDB_FILE *stream)); -extern void gdb_print_address PARAMS ((void *, GDB_FILE *)); +/* Display the host ADDR on STREAM formatted as ``0x%x''. */ +extern void gdb_print_host_address (void *addr, struct gdb_file *stream); /* Convert a CORE_ADDR into a HEX string. paddr() is like %08lx. paddr_nz() is like %lx. paddr_u() is like %lu. paddr_width() is for ``%*''. */ -extern int strlen_paddr (); +extern int strlen_paddr (void); extern char* paddr (CORE_ADDR addr); extern char* paddr_nz (CORE_ADDR addr); extern char* paddr_u (CORE_ADDR addr); diff --git a/gdb/dink32-rom.c b/gdb/dink32-rom.c index 2d60d67..2bd004d 100644 --- a/gdb/dink32-rom.c +++ b/gdb/dink32-rom.c @@ -24,6 +24,8 @@ #include "target.h" #include "monitor.h" #include "serial.h" +#include "symfile.h" /* For generic_load() */ +#include "inferior.h" /* For write_pc() */ static void dink32_open PARAMS ((char *args, int from_tty)); @@ -34,7 +36,7 @@ dink32_supply_register (regname, regnamelen, val, vallen) char *val; int vallen; { - int regno = 0, base = 0; + int regno = 0; if (regnamelen < 2 || regnamelen > 4) return; diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 9217a4b..090f58c 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,25 @@ +1999-09-07 Stan Shebs <shebs@andros.cygnus.com> + + * gdb.texinfo: Fiks speling errers. + + * gdb.texinfo: Fix uses of @multitable. + + From Eli Zaretskii <eliz@is.elta.co.il>: + * gdb.texinfo: Include details specific to DOS host, clarify + some confusing language, fix @ref/@xref/@pxref usages, add + comments about using with optimization, add more indexing, + fix info about disassembly-flavor. + +Tue Sep 7 09:11:24 1999 Kevin Buettner <kevinb@cygnus.com> + + * gdbint.texinfo (IN_SOLIB_DYNSYM_RESOLVE_CODE, + SKIP_SOLIB_RESOLVER): Define. + +Fri Sep 3 18:05:14 1999 Andrew Cagney <cagney@b1.cygnus.com> + + * gdb.texinfo (Protocol): Review. Add tables describing ``q'' and + ``g'' packets. + 1999-08-30 Stan Shebs <shebs@andros.cygnus.com> * gdb.texinfo: Create a new "Configurations" chapter with diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index bfa9cc4..4259095 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -808,7 +808,7 @@ This makes startup slower, but makes future operations faster. The @code{-mapped} and @code{-readnow} options are typically combined in order to build a @file{.syms} file that contains complete symbol information. (@xref{Files,,Commands to specify files}, for -information on @file{.syms} files.) A simple @value{GDBN} invocation to do +information on @file{.syms} files.) A simple @value{GDBN} invocation to do nothing but build a @file{.syms} file for future use is: @example @@ -932,7 +932,8 @@ just use the @code{shell} command. @item shell @var{command string} Invoke a standard shell to execute @var{command string}. If it exists, the environment variable @code{SHELL} determines which -shell to run. Otherwise @value{GDBN} uses @code{/bin/sh}. +shell to run. Otherwise @value{GDBN} uses the default shell +(@file{/bin/sh} on Unix systems, @file{COMMAND.COM} on MS-DOS, etc.). @end table The utility @code{make} is often needed in development environments. @@ -1118,10 +1119,10 @@ In general, @value{GDBN} can tell that a quote is needed (and inserts it) if you have not yet started typing the argument list when you ask for completion on an overloaded symbol. -For more information about overloaded functions, @pxref{C plus plus +For more information about overloaded functions, see @ref{C plus plus expressions, ,C++ expressions}. You can use the command @code{set overload-resolution off} to disable overload resolution; -@pxref{Debugging C plus plus, ,@value{GDBN} features for C++}. +see @ref{Debugging C plus plus, ,@value{GDBN} features for C++}. @node Help @@ -1432,7 +1433,12 @@ They are passed to a shell, which expands wildcard characters and performs redirection of I/O, and thence to your program. Your @code{SHELL} environment variable (if it exists) specifies what shell @value{GDBN} uses. If you do not define @code{SHELL}, @value{GDBN} uses -@code{/bin/sh}. +the default shell (@file{/bin/sh} on Unix). + +On non-Unix systems, the program is usually invoked directly by +@value{GDBN}, which emulates I/O redirection via the appropriate system +calls, and the wildcard characters are expanded by the startup code of +the program, not by the shell. @code{run} with no arguments uses the same arguments used by the previous @code{run}, or those set by the @code{set args} command. @@ -1468,9 +1474,10 @@ environment without having to start @value{GDBN} over again. @item path @var{directory} Add @var{directory} to the front of the @code{PATH} environment variable (the search path for executables), for both @value{GDBN} and your program. -You may specify several directory names, separated by @samp{:} or -whitespace. If @var{directory} is already in the path, it is moved to -the front, so it is searched sooner. +You may specify several directory names, separated by whitespace or by a +system-dependent separator character (@samp{:} on Unix, @samp{;} on +MS-DOS and MS-Windows). If @var{directory} is already in the path, it +is moved to the front, so it is searched sooner. You can use the string @samp{$cwd} to refer to whatever is the current working directory at the time @value{GDBN} searches the path. If you @@ -1511,7 +1518,7 @@ set env USER = foo @end example @noindent -tells a Unix program, when subsequently run, that its user is named +tells the debugged program, when subsequently run, that its user is named @samp{foo}. (The spaces around @samp{=} are used for clarity here; they are not actually required.) @@ -1523,7 +1530,8 @@ program. This is different from @samp{set env @var{varname} =}; rather than assigning it an empty value. @end table -@emph{Warning:} @value{GDBN} runs your program using the shell indicated +@emph{Warning:} On Unix systems, @value{GDBN} runs your program using +the shell indicated by your @code{SHELL} environment variable if it exists (or @code{/bin/sh} if not). If your @code{SHELL} variable names a shell that runs an initialization file---such as @file{.cshrc} for C-shell, or @@ -1930,7 +1938,7 @@ so that the delay need not occur when you don't want to run @value{GDBN} on the child. While the child is sleeping, use the @code{ps} program to get its process ID. Then tell @value{GDBN} (a new invocation of @value{GDBN} if you are also debugging the parent process) to attach to -the child process (see @ref{Attach}). From that point on you can debug +the child process (@pxref{Attach}). From that point on you can debug the child process just like any other process which you attached to. On HP-UX (11.x and later only?), @value{GDBN} provides support for @@ -2056,7 +2064,7 @@ exception or the loading of a library. As with watchpoints, you use a different command to set a catchpoint (@pxref{Set Catchpoints, ,Setting catchpoints}), but aside from that, you can manage a catchpoint like any other breakpoint. (To stop when your program receives a signal, use the -@code{handle} command; @pxref{Signals, ,Signals}.) +@code{handle} command; see @ref{Signals, ,Signals}.) @cindex breakpoint numbers @cindex numbers for breakpoints @@ -2077,8 +2085,7 @@ enable it again. * Conditions:: Break conditions * Break Commands:: Breakpoint command lists * Breakpoint Menus:: Breakpoint menus - -@c * Error in Breakpoints:: ``Cannot insert breakpoints'' +* Error in Breakpoints:: ``Cannot insert breakpoints'' @end menu @node Set Breaks @@ -2111,12 +2118,13 @@ C++, @var{function} may refer to more than one possible place to break. @item break +@var{offset} @itemx break -@var{offset} Set a breakpoint some number of lines forward or back from the position -at which execution stopped in the currently selected frame. +at which execution stopped in the currently selected @dfn{stack frame}. +(@xref{Frames, , Frames}, for a description of stack frames.) @item break @var{linenum} Set a breakpoint at line @var{linenum} in the current source file. -That file is the last file whose source text was printed. This -breakpoint stops your program just before it executes any of the +The current source file is the last file whose source text was printed. +The breakpoint will stop your program just before it executes any of the code on that line. @item break @var{filename}:@var{linenum} @@ -2168,18 +2176,20 @@ program stops there. @xref{Disabling, ,Disabling breakpoints}. @kindex hbreak @item hbreak @var{args} -Set a hardware-assisted breakpoint. @var{args} are the same as for the -@code{break} command and the breakpoint is set in the same way, but the +Set a hardware-assisted breakpoint. @var{args} are the same as for the +@code{break} command and the breakpoint is set in the same way, but the breakpoint requires hardware support and some target hardware may not have this support. The main purpose of this is EPROM/ROM code -debugging, so you can set a breakpoint at an instruction without -changing the instruction. This can be used with the new trap-generation -provided by SPARClite DSU. DSU will generate traps when a program accesses -some data or instruction address that is assigned to the debug registers. -However the hardware breakpoint registers can only take two data breakpoints, -and @value{GDBN} will reject this command if more than two are used. -Delete or disable unused hardware breakpoints before setting -new ones. @xref{Conditions, ,Break conditions}. +debugging, so you can set a breakpoint at an instruction without +changing the instruction. This can be used with the new trap-generation +provided by SPARClite DSU and some x86-based targets. These targets +will generate traps when a program accesses some data or instruction +address that is assigned to the debug registers. However the hardware +breakpoint registers can take a limited number of breakpoints. For +example, on the DSU, only two data breakpoints can be set at a time, and +@value{GDBN} will reject this command if more than two are used. Delete +or disable unused hardware breakpoints before setting new ones +(@pxref{Disabling, ,Disabling}). @xref{Conditions, ,Break conditions}. @kindex thbreak @item thbreak @var{args} @@ -2190,7 +2200,7 @@ the breakpoint is automatically deleted after the first time your program stops there. Also, like the @code{hbreak} command, the breakpoint requires hardware support and some target hardware may not have this support. @xref{Disabling, ,Disabling breakpoints}. -Also @xref{Conditions, ,Break conditions}. +See also @ref{Conditions, ,Break conditions}. @kindex rbreak @cindex regular expression @@ -2322,7 +2332,8 @@ times slower than normal execution. (But this may still be worth it, to catch errors where you have no clue what part of your program is the culprit.) -On some systems, such as HP-UX and Linux, GDB includes support for +On some systems, such as HP-UX, Linux and some other x86-based targets, +GDB includes support for hardware watchpoints, which do not slow down the running of your program. @@ -2338,7 +2349,7 @@ Set a watchpoint that will break when watch @var{expr} is read by the program. @kindex awatch @item awatch @var{expr} -Set a watchpoint that will break when @var{args} is read and written into +Set a watchpoint that will break when @var{args} is either read or written into by the program. @kindex info watchpoints @@ -2435,6 +2446,7 @@ can become current), then you can use watchpoints as usual. However, @value{GDBN} may not notice when a non-current thread's activity changes the expression. +@c FIXME: this is almost identical to the previous paragraph. @emph{HP-UX Warning:} In multi-thread programs, software watchpoints have only limited usefulness. If @value{GDBN} creates a software watchpoint, it can only watch the value of an expression @emph{in a @@ -2448,7 +2460,7 @@ watchpoints, in contrast, watch an expression in all threads.) @node Set Catchpoints @subsection Setting catchpoints -@cindex catchpoints +@cindex catchpoints, setting @cindex exception handlers @cindex event handling @@ -2538,8 +2550,8 @@ which has the following ANSI C interface: @example /* @var{addr} is where the exception identifier is stored. - ID is the exception identifier. */ - void __raise_exception (void **@var{addr}, void *@var{id}); + @var{id} is the exception identifier. */ + void __raise_exception (void **addr, void *id); @end example @noindent @@ -2626,11 +2638,11 @@ with the @code{break} command starts out in this state. Disabled. The breakpoint has no effect on your program. @item Enabled once. The breakpoint stops your program, but then becomes -disabled. A breakpoint set with the @code{tbreak} command starts out in -this state. +disabled. @item Enabled for deletion. The breakpoint stops your program, but -immediately after it does so it is deleted permanently. +immediately after it does so it is deleted permanently. A breakpoint +set with the @code{tbreak} command starts out in this state. @end itemize You can use the following commands to enable or disable breakpoints, @@ -2662,6 +2674,8 @@ Enable the specified breakpoints to work once, then die. @value{GDBN} deletes any of these breakpoints as soon as your program stops there. @end table +@c FIXME: I think the following ``Except for [...] @code{tbreak}'' is +@c confusing: tbreak is also initially enabled. Except for a breakpoint set with @code{tbreak} (@pxref{Set Breaks, ,Setting breakpoints}), breakpoints that you set are initially enabled; subsequently, they become disabled or enabled only when you use one of @@ -2703,7 +2717,8 @@ format special data structures. The effects are completely predictable unless there is another enabled breakpoint at the same address. (In that case, @value{GDBN} might see the other breakpoint first and stop your program without checking the condition of this one.) Note that -breakpoint commands are usually more convenient and flexible for the +breakpoint commands are usually more convenient and flexible than break +conditions for the purpose of performing side effects when a breakpoint is reached (@pxref{Break Commands, ,Breakpoint command lists}). @@ -2726,12 +2741,19 @@ breakpoint @var{bnum} stops your program only if the value of @var{expression} is true (nonzero, in C). When you use @code{condition}, @value{GDBN} checks @var{expression} immediately for syntactic correctness, and to determine whether symbols in it have -referents in the context of your breakpoint. -@c FIXME so what does GDB do if there is no referent? Moreover, what -@c about watchpoints? +referents in the context of your breakpoint. If @var{expression} uses +symbols not referenced in the context of the breakpoint, @value{GDBN} +prints an error message: + +@example +No symbol "foo" in current context. +@end example + +@noindent @value{GDBN} does not actually evaluate @var{expression} at the time the @code{condition} -command is given, however. @xref{Expressions, ,Expressions}. +command (or a command that sets a breakpoint with a condition, like +@code{break if @dots{}}) is given, however. @xref{Expressions, ,Expressions}. @item condition @var{bnum} Remove the condition from breakpoint number @var{bnum}. It becomes @@ -2907,35 +2929,59 @@ Use the "delete" command to delete unwanted @end smallexample @c @ifclear BARETARGET -@c @node Error in Breakpoints -@c @subsection ``Cannot insert breakpoints'' +@node Error in Breakpoints +@subsection ``Cannot insert breakpoints'' @c @c FIXME!! 14/6/95 Is there a real example of this? Let's use it. @c -@c Under some operating systems -@c any other process is running that program. In this situation, -@c attempting to run or continue a program with a breakpoint causes -@c @value{GDBN} to stop the other process. -@c -@c When this happens, you have three ways to proceed: -@c -@c @enumerate -@c @item -@c Remove or disable the breakpoints, then continue. -@c -@c @item -@c Suspend @value{GDBN}, and copy the file containing your program to a new -@c name. Resume @value{GDBN} and use the @code{exec-file} command to specify -@c that @value{GDBN} should run your program under that name. -@c Then start your program again. -@c -@c @item -@c Relink your program so that the text segment is nonsharable, using the -@c linker option @samp{-N}. The operating system limitation may not apply -@c to nonsharable executables. -@c @end enumerate +Under some operating systems, breakpoints cannot be used in a program if +any other process is running that program. In this situation, +attempting to run or continue a program with a breakpoint causes +@value{GDBN} to print an error message: + +@example +Cannot insert breakpoints. +The same program may be running in another process. +@end example + +When this happens, you have three ways to proceed: + +@enumerate +@item +Remove or disable the breakpoints, then continue. + +@item +Suspend @value{GDBN}, and copy the file containing your program to a new +name. Resume @value{GDBN} and use the @code{exec-file} command to specify +that @value{GDBN} should run your program under that name. +Then start your program again. + +@item +Relink your program so that the text segment is nonsharable, using the +linker option @samp{-N}. The operating system limitation may not apply +to nonsharable executables. +@end enumerate @c @end ifclear +A similar message can be printed if you request too many active +hardware-assisted breakpoints and watchpoints: + +@c FIXME: the precise wording of this message may change; the relevant +@c source change is not committed yet (Sep 3, 1999). +@smallexample +Stopped; cannot insert breakpoints. +You may have requested too many hardware breakpoints and watchpoints. +@end smallexample + +@noindent +This message is printed when you attempt to resume the program, since +only then @value{GDBN} knows exactly how many hardware breakpoints and +watchpoints it needs to insert. + +When this message is printed, you need to disable or remove some of the +hardware-assisted breakpoints and watchpoints, and then continue. + + @node Continuing and Stepping @section Continuing and stepping @@ -2948,8 +2994,8 @@ one more ``step'' of your program, where ``step'' may mean either one line of source code, or one machine instruction (depending on what particular command you use). Either when continuing or when stepping, your program may stop even sooner, due to a breakpoint or a signal. (If -due to a signal, you may want to use @code{handle}, or use @samp{signal -0} to resume execution. @xref{Signals, ,Signals}.) +it stops due to a signal, you may want to use @code{handle}, or use +@samp{signal 0} to resume execution. @xref{Signals, ,Signals}.) @table @code @kindex continue @@ -2968,8 +3014,10 @@ The argument @var{ignore-count} is meaningful only when your program stopped due to a breakpoint. At other times, the argument to @code{continue} is ignored. -The synonyms @code{c} and @code{fg} are provided purely for convenience, -and have exactly the same behavior as @code{continue}. +The synonyms @code{c} and @code{fg} (for @dfn{foreground}, as the +debugged program is deemed to be the foreground program) are provided +purely for convenience, and have exactly the same behavior as +@code{continue}. @end table To resume execution at a different place, you can use @code{return} @@ -3006,13 +3054,15 @@ without debugging information, use the @code{stepi} command, described below. @end quotation -The @code{step} command now only stops at the first instruction of a -source line. This prevents the multiple stops that used to occur in +The @code{step} command only stops at the first instruction of a +source line. This prevents the multiple stops that could otherwise occur in switch statements, for loops, etc. @code{step} continues to stop if a function that has debugging information is called within the line. +In other words, @code{step} @emph{steps inside} any functions called +within the line. -Also, the @code{step} command now only enters a subroutine if there is line -number information for the subroutine. Otherwise it acts like the +Also, the @code{step} command only enters a function if there is line +number information for the function. Otherwise it acts like the @code{next} command. This avoids problems when using @code{cc -gl} on MIPS machines. Previously, @code{step} entered subroutines if there was any debugging information about the routine. @@ -3042,8 +3092,8 @@ An argument @var{count} is a repeat count, as for @code{step}. @c @code{step}, but any function calls appearing within the code of the @c function are executed without stopping. -The @code{next} command now only stops at the first instruction of a -source line. This prevents the multiple stops that used to occur in +The @code{next} command only stops at the first instruction of a +source line. This prevents multiple stops that could otherwise occur in switch statements, for loops, etc. @kindex finish @@ -3139,7 +3189,7 @@ An argument is a repeat count, as in @code{next}. A signal is an asynchronous event that can happen in a program. The operating system defines the possible kinds of signals, and gives each kind a name and a number. For example, in Unix @code{SIGINT} is the -signal a program gets when you type an interrupt (often @kbd{C-c}); +signal a program gets when you type an interrupt character (often @kbd{C-c}); @code{SIGSEGV} is the signal a program gets from referencing a place in memory far away from all the areas in use; @code{SIGALRM} occurs when the alarm clock timer goes off (which happens only if your program has @@ -3148,7 +3198,7 @@ requested an alarm). @cindex fatal signals Some signals, including @code{SIGALRM}, are a normal part of the functioning of your program. Others, such as @code{SIGSEGV}, indicate -errors; these signals are @dfn{fatal} (kill your program immediately) if the +errors; these signals are @dfn{fatal} (they kill your program immediately) if the program has not specified in advance some other way to handle the signal. @code{SIGINT} does not indicate an error in your program, but it is normally fatal so it can carry out the purpose of the interrupt: to kill the program. @@ -3170,7 +3220,7 @@ Print a table of all the kinds of signals and how @value{GDBN} has been told to handle each one. You can use this to see the signal numbers of all the defined types of signals. -@code{info handle} is the new alias for @code{info signals}. +@code{info handle} is an alias for @code{info signals}. @kindex handle @item handle @var{signal} @var{keywords}@dots{} @@ -3209,7 +3259,8 @@ and not handled. @end table @c @end group -When a signal stops your program, the signal is not visible until you +When a signal stops your program, the signal is not visible to the +program until you continue. Your program sees the signal then, if @code{pass} is in effect for the signal in question @emph{at that time}. In other words, after @value{GDBN} reports a signal, you can use the @code{handle} @@ -3300,9 +3351,9 @@ current thread may run when the inferior is resumed. The @code{step} mode optimizes for single-stepping. It stops other threads from ``seizing the prompt'' by preempting the current thread while you are stepping. Other threads will only rarely (or never) get a chance to run -when you step. They are more likely to run when you ``next'' over a +when you step. They are more likely to run when you @samp{next} over a function call, and they are completely free to run when you use commands -like ``continue'', ``until'', or ``finish''. However, unless another +like @samp{continue}, @samp{until}, or @samp{finish}. However, unless another thread hits a breakpoint during its timeslice, they will never steal the GDB prompt away from the thread that you are debugging. @@ -3353,7 +3404,7 @@ currently executing frame and describes it briefly, similar to the @node Frames @section Stack frames -@cindex frame +@cindex frame, definition @cindex stack frame The call stack is divided up into contiguous pieces called @dfn{stack frames}, or @dfn{frames} for short; each frame is the data associated @@ -3402,7 +3453,7 @@ correct tracing of the function call chain. However, @value{GDBN} has no provision for frameless functions elsewhere in the stack. @table @code -@kindex frame +@kindex frame@r{, command} @item frame @var{args} The @code{frame} command allows you to move from one stack frame to another, and to print the stack frame you select. @var{args} may be either the @@ -3488,7 +3539,7 @@ selecting a stack frame; all of them finish by printing a brief description of the stack frame just selected. @table @code -@kindex frame +@kindex frame@r{, selecting} @kindex f @item frame @var{n} @itemx f @var{n} @@ -3599,6 +3650,8 @@ the language in which the source code corresponding to this frame is written @item the address of the frame's arguments @item +the address of the frame's local variables +@item the program counter saved in it (the address of execution in the caller frame) @item which registers were saved in the frame @@ -3627,8 +3680,8 @@ line. These are all variables (declared either static or automatic) accessible at the point of execution of the selected frame. @kindex info catch -@cindex catch exceptions -@cindex exception handlers +@cindex catch exceptions, list active handlers +@cindex exception handlers, how to list @item info catch Print a list of all the exception handlers that are active in the current stack frame at the current point of execution. To see other @@ -3651,7 +3704,7 @@ execution in that frame has stopped. You can print other portions of source files by explicit command. If you use @value{GDBN} through its @sc{gnu} Emacs interface, you may -prefer to use Emacs facilities to view source; @pxref{Emacs, ,Using +prefer to use Emacs facilities to view source; see @ref{Emacs, ,Using @value{GDBN} under @sc{gnu} Emacs}. @menu @@ -3715,7 +3768,7 @@ each repetition moves up in the source file. @cindex linespec In general, the @code{list} command expects you to supply zero, one or two @dfn{linespecs}. Linespecs specify source lines; there are several ways -of writing them but the effect is always to specify some source line. +of writing them, but the effect is always to specify some source line. Here is a complete description of the possible arguments for @code{list}: @table @code @@ -3832,14 +3885,17 @@ each line is in the file. @kindex directory @kindex dir -When you start @value{GDBN}, its source path is empty. +When you start @value{GDBN}, its source path includes only @samp{cdir} +and @samp{cwd}, in that order. To add other directories, use the @code{directory} command. @table @code @item directory @var{dirname} @dots{} @item dir @var{dirname} @dots{} Add directory @var{dirname} to the front of the source path. Several -directory names may be given to this command, separated by @samp{:} or +directory names may be given to this command, separated by @samp{:} +(@samp{;} on MS-DOS and MS-Windows, where @samp{:} usually appears as +part of absolute file names) or whitespace. You may specify a directory that is already in the source path; this moves it forward, so @value{GDBN} searches it sooner. @@ -3890,7 +3946,7 @@ directories in one command. You can use the command @code{info line} to map source lines to program addresses (and vice versa), and the command @code{disassemble} to display a range of addresses as machine instructions. When run under @sc{gnu} Emacs -mode, the @code{info line} command now causes the arrow to point to the +mode, the @code{info line} command causes the arrow to point to the line specified. Also, @code{info line} prints addresses in symbolic form as well as hex. @@ -3907,6 +3963,8 @@ For example, we can use @code{info line} to discover the location of the object code for the first line of function @code{m4_changequote}: +@c FIXME: I think this example should also show the addresses in +@c symbolic form, as they usually would be displayed. @smallexample (@value{GDBP}) info line m4_changecom Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350. @@ -3921,6 +3979,7 @@ Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404. @end smallexample @cindex @code{$_} and @code{info line} +@kindex x@r{, and }@code{info line} After @code{info line}, the default address for the @code{x} command is changed to the starting address of the line, so that @samp{x/i} is sufficient to begin examining the machine code (@pxref{Memory, @@ -3964,18 +4023,21 @@ Some architectures have more than one commonly-used set of instruction mnemonics or other syntax. @table @code -@kindex set assembly-language +@kindex set disassembly-flavor @cindex assembly instructions @cindex instructions, assembly @cindex machine instructions @cindex listing machine instructions -@item set assembly-language @var{instruction-set} +@cindex Intel disassembly flavor +@cindex AT&T disassembly flavor +@item set disassembly-flavor @var{instruction-set} Select the instruction set to use when disassembling the program via the @code{disassemble} or @code{x/i} commands. Currently this command is only defined for the Intel x86 family. You -can set @var{instruction-set} to either @code{i386} or @code{i8086}. -The default is @code{i386}. +can set @var{instruction-set} to either @code{intel} or @code{att}. +The default is @code{att}, the AT&T flavor used by default by Unix +assemblers for x86-based targets. @end table @@ -3996,17 +4058,17 @@ program is written in (@pxref{Languages, ,Using @value{GDBN} with Different Languages}). @table @code -@item print @var{exp} -@itemx print /@var{f} @var{exp} -@var{exp} is an expression (in the source language). By default the -value of @var{exp} is printed in a format appropriate to its data type; +@item print @var{expr} +@itemx print /@var{f} @var{expr} +@var{expr} is an expression (in the source language). By default the +value of @var{expr} is printed in a format appropriate to its data type; you can choose a different format by specifying @samp{/@var{f}}, where -@var{f} is a letter specifying the format; @pxref{Output Formats,,Output +@var{f} is a letter specifying the format; see @ref{Output Formats,,Output formats}. @item print @itemx print /@var{f} -If you omit @var{exp}, @value{GDBN} displays the last value again (from the +If you omit @var{expr}, @value{GDBN} displays the last value again (from the @dfn{value history}; @pxref{Value History, ,Value history}). This allows you to conveniently inspect the same value in an alternative format. @end table @@ -4016,8 +4078,8 @@ It examines data in memory at a specified address and prints it in a specified format. @xref{Memory, ,Examining memory}. If you are interested in information about types, or about how the -fields of a struct or class are declared, use the @code{ptype @var{exp}} -command rather than @code{print}. @xref{Symbols, ,Examining the Symbol +fields of a struct or a class are declared, use the @code{ptype @var{exp}} +command rather than @code{print}. @xref{Symbols, ,Examining the Symbol Table}. @menu @@ -4045,10 +4107,10 @@ by the programming language you are using is valid in an expression in and string constants. It unfortunately does not include symbols defined by preprocessor @code{#define} commands. -@value{GDBN} now supports array constants in expressions input by -the user. The syntax is @var{@{element, element@dots{}@}}. For example, -you can now use the command @code{print @{1, 2, 3@}} to build up an array in -memory that is malloc'd in the target program. +@value{GDBN} supports array constants in expressions input by +the user. The syntax is @{@var{element}, @var{element}@dots{}@}. For example, +you can use the command @code{print @{1, 2, 3@}} to build up an array in +memory that is @code{malloc}ed in the target program. Because C is so widespread, most of the expressions shown in examples in this manual are in C. @xref{Languages, , Using @value{GDBN} with Different @@ -4138,7 +4200,7 @@ happens, referring to that name has unpredictable effects. If you wish, you can specify a static variable in a particular function or file, using the colon-colon notation: -@cindex colon-colon +@cindex colon-colon, context for variables/functions @iftex @c info cannot cope with a :: index entry, but why deprive hard copy readers? @kindex :: @@ -4185,6 +4247,29 @@ This may also happen when the compiler does significant optimizations. To be sure of always seeing accurate values, turn off all optimization when compiling. +@cindex ``No symbol "foo" in current context'' +Another possible effect of compiler optimizations is to optimize +unused variables out of existence, or assign variables to registers (as +opposed to memory addresses). Depending on the support for such cases +offered by the debug info format used by the compiler, @value{GDBN} +might not be able to display values for such local variables. If that +happens, @value{GDBN} will print a message like this: + +@example +No symbol "foo" in current context. +@end example + +To solve such problems, either recompile without optimizations, or use a +different debug info format, if the compiler supports several such +formats. For example, @value{NGCC}, the @sc{gnu} C/C++ compiler usually +supports the @samp{-gstabs} option. @samp{-gstabs} produces debug info +in a format that is superior to formats such as COFF. You may be able +to use DWARF-2 (@samp{-gdwarf-2}), which is also an effective form for +debug info. See @ref{Debugging Options,,Options for Debugging Your +Program or @sc{gnu} CC, gcc.info, Using @sc{gnu} CC}, for more +information. + + @node Arrays @section Artificial arrays @@ -4231,7 +4316,7 @@ $1 = @{0x1234, 0x5678@} @end example As a convenience, if you leave the array length out (as in -@samp{(@var{type})[])@var{value}}) gdb calculates the size to fill +@samp{(@var{type}[])@var{value}}) gdb calculates the size to fill the value (as @samp{sizeof(@var{value})/sizeof(@var{type})}: @example (@value{GDBP}) p/x (short[])0x12345678 @@ -4291,7 +4376,7 @@ Print as integer in octal. Print as integer in binary. The letter @samp{t} stands for ``two''. @footnote{@samp{b} cannot be used because these format letters are also used with the @code{x} command, where @samp{b} stands for ``byte''; -@pxref{Memory,,Examining memory}.} +see @ref{Memory,,Examining memory}.} @item a @cindex unknown address, locating @@ -4394,7 +4479,7 @@ For example, @samp{x/3uh 0x54320} is a request to display three halfwords (@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}), starting at address @code{0x54320}. @samp{x/4xw $sp} prints the four words (@samp{w}) of memory above the stack pointer (here, @samp{$sp}; -@pxref{Registers}) in hexadecimal (@samp{x}). +@pxref{Registers, ,Registers}) in hexadecimal (@samp{x}). Since the letters indicating unit sizes are all distinct from the letters specifying output formats, you do not have to remember whether @@ -4406,7 +4491,7 @@ Even though the unit size @var{u} is ignored for the formats @samp{s} and @samp{i}, you might still want to use a count @var{n}; for example, @samp{3i} specifies that you want to see three machine instructions, including any operands. The command @code{disassemble} gives an -alternative way of inspecting machine instructions; @pxref{Machine +alternative way of inspecting machine instructions; see @ref{Machine Code,,Source and machine code}. All the defaults for the arguments to @code{x} are designed to make it @@ -4459,15 +4544,15 @@ supported by @code{x}; otherwise it uses @code{print}. @table @code @kindex display -@item display @var{exp} -Add the expression @var{exp} to the list of expressions to display +@item display @var{expr} +Add the expression @var{expr} to the list of expressions to display each time your program stops. @xref{Expressions, ,Expressions}. @code{display} does not repeat if you press @key{RET} again after using it. -@item display/@var{fmt} @var{exp} +@item display/@var{fmt} @var{expr} For @var{fmt} specifying only a display format and not a size or -count, add the expression @var{exp} to the auto-display list but +count, add the expression @var{expr} to the auto-display list but arrange to display it each time in the specified format @var{fmt}. @xref{Output Formats,,Output formats}. @@ -4480,7 +4565,7 @@ doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory, ,Examining memory}. For example, @samp{display/i $pc} can be helpful, to see the machine instruction about to be executed each time execution stops (@samp{$pc} -is a common name for the program counter; @pxref{Registers}). +is a common name for the program counter; @pxref{Registers, ,Registers}). @table @code @kindex delete display @@ -4669,6 +4754,7 @@ Set a limit on how many elements of an array @value{GDBN} will print. If @value{GDBN} is printing a large array, it stops printing after it has printed the number of elements set by the @code{set print elements} command. This limit also applies to the display of strings. +When @value{GDBN} starts, this limit is set to 200. Setting @var{number-of-elements} to zero means that the printing is unlimited. @kindex show print elements @@ -4679,8 +4765,9 @@ If the number is 0, then the printing is unlimited. @kindex set print null-stop @item set print null-stop Cause @value{GDBN} to stop printing the characters of an array when the first -@sc{NULL} is encountered. This is useful when large arrays actually +@sc{null} is encountered. This is useful when large arrays actually contain only short strings. +The default is off. @kindex set print pretty @item set print pretty on @@ -4791,7 +4878,7 @@ These settings are of interest when debugging C++ programs: @itemx set print demangle on Print C++ names in their source form rather than in the encoded (``mangled'') form passed to the assembler and linker for type-safe -linkage. The default is @samp{on}. +linkage. The default is on. @kindex show print demangle @item show print demangle @@ -4975,7 +5062,7 @@ of your program. That is why you can use them freely. Convenience variables are prefixed with @samp{$}. Any name preceded by @samp{$} can be used for a convenience variable, unless it is one of -the predefined machine-specific register names (@pxref{Registers}). +the predefined machine-specific register names (@pxref{Registers, ,Registers}). (Value history references, in contrast, are @emph{numbers} preceded by @samp{$}. @xref{Value History, ,Value history}.) @@ -5004,7 +5091,7 @@ variable, when used as an expression, has the type of its current value. @kindex show convenience @item show convenience Print a list of convenience variables used so far, and their values. -Abbreviated @code{show con}. +Abbreviated @code{show conv}. @end table One of the ways to use a convenience variable is as a counter to be @@ -5016,7 +5103,8 @@ set $i = 0 print bar[$i++]->contents @end example -@noindent Repeat that command by typing @key{RET}. +@noindent +Repeat that command by typing @key{RET}. Some convenience variables are created automatically by @value{GDBN} and given values likely to be useful. @@ -5103,7 +5191,7 @@ memory (most machines, nowadays). This assumes that the innermost stack frame is selected; setting @code{$sp} is not allowed when other stack frames are selected. To pop entire frames off the stack, regardless of machine architecture, use @code{return}; -@pxref{Returning, ,Returning from a function}.} with +see @ref{Returning, ,Returning from a function}.} with @example set $sp += 4 @@ -5114,7 +5202,8 @@ your machine even though the machine has different canonical mnemonics, so long as there is no conflict. The @code{info registers} command shows the canonical names. For example, on the SPARC, @code{info registers} displays the processor status register as @code{$psr} but you -can also refer to it as @code{$ps}. +can also refer to it as @code{$ps}; and on x86-based machines @code{$ps} +is an alias for the @sc{eflags} register. @value{GDBN} always considers the contents of an ordinary register as an integer when the register is examined in this way. Some machines have @@ -5205,7 +5294,9 @@ source file is in. However, most of the time @value{GDBN} infers the language from the name of the file. The language of a source file controls whether C++ names are demangled---this way @code{backtrace} can show each frame appropriately for its own language. There is no way to -set the language of a source file from within @value{GDBN}. +set the language of a source file from within @value{GDBN}, but you can +set the language associated with a filename extension. @xref{Show, , +Displaying the language}. This is most commonly a problem when you use a program, such as @code{cfront} or @code{f2c}, that generates C but is written in @@ -5318,8 +5409,8 @@ The following commands help you find out which language is the working language, and also what language source files were written in. @kindex show language -@kindex info frame -@kindex info source +@kindex info frame@r{, show the source language} +@kindex info source@r{, show the source language} @table @code @item show language Display the current working language. This is the @@ -5427,7 +5518,7 @@ details on specific languages. @value{GDBN} provides some additional commands for controlling the type checker: -@kindex set check +@kindex set check@r{, type} @kindex set check type @kindex show check type @table @code @@ -5441,7 +5532,7 @@ each language. Set type checking on or off, overriding the default setting for the current working language. Issue a warning if the setting does not match the language default. If any type mismatches occur in -evaluating an expression while typechecking is on, @value{GDBN} prints a +evaluating an expression while type checking is on, @value{GDBN} prints a message and aborts evaluation of the expression. @item set check type warn @@ -5488,7 +5579,7 @@ Supported languages}, for further details on specific languages. @value{GDBN} provides some additional commands for controlling the range checker: -@kindex set check +@kindex set check@r{, range} @kindex set check range @kindex show check range @table @code @@ -5594,7 +5685,8 @@ For the purposes of C and C++, the following definitions hold: specifiers; @code{char}; @code{enum}; and, for C++, @code{bool}. @item -@emph{Floating-point types} include @code{float} and @code{double}. +@emph{Floating-point types} include @code{float}, @code{double}, and +@code{long double} (if supported by the target platform). @item @emph{Pointer types} include all types defined as @code{(@var{type} *)}. @@ -5621,7 +5713,7 @@ assigned. Defined on scalar types. @item @var{op}= Used in an expression of the form @w{@code{@var{a} @var{op}= @var{b}}}, and translated to @w{@code{@var{a} = @var{a op b}}}. -@w{@code{@var{op}=}} and @code{=} have the same precendence. +@w{@code{@var{op}=}} and @code{=} have the same precedence. @var{op} is any one of the operators @code{|}, @code{^}, @code{&}, @code{<<}, @code{>>}, @code{+}, @code{-}, @code{*}, @code{/}, @code{%}. @@ -5757,6 +5849,11 @@ point, followed by a sequence of digits, and optionally followed by an exponent. An exponent is of the form: @samp{@w{e@r{[[}+@r{]|}-@r{]}@var{nnn}}}, where @var{nnn} is another sequence of digits. The @samp{+} is optional for positive exponents. +A floating-point constant may also end with a letter @samp{f} or +@samp{F}, specifying that the constant should be treated as being of +the @code{float} (as opposed to the default @code{double}) type; or with +a letter @samp{l} or @samp{L}, which specifies a @code{long double} +constant. @item Enumerated constants consist of enumerated identifiers, or their @@ -5765,7 +5862,7 @@ integral equivalents. @item Character constants are a single character surrounded by single quotes (@code{'}), or a number---the ordinal value of the corresponding character -(usually its @sc{ASCII} value). Within quotes, the single character may +(usually its @sc{ascii} value). Within quotes, the single character may be represented by a letter or by @dfn{escape sequences}, which are of the form @samp{\@var{nnn}}, where @var{nnn} is the octal representation of the character's ordinal value; or of the form @samp{\@var{x}}, where @@ -5844,11 +5941,11 @@ that is, @value{GDBN} allows implicit references to the class instance pointer @code{this} following the same rules as C++. @cindex call overloaded functions -@cindex overloaded functions +@cindex overloaded functions, calling @cindex type conversions in C++ @item You can call overloaded functions; @value{GDBN} resolves the function -call to the right definition, with some restrictions. GDB does not +call to the right definition, with some restrictions. @value{GDBN} does not perform overload resolution involving user-defined type conversions, calls to constructors, or instantiations of templates that do not exist in the program. It also cannot handle ellipsis argument lists or @@ -5864,13 +5961,14 @@ Overload resolution is always performed, unless you have specified @code{set overload-resolution off}. @xref{Debugging C plus plus, ,@value{GDBN} features for C++}. -You must specify@code{set overload-resolution off} in order to use an +You must specify @code{set overload-resolution off} in order to use an explicit function signature to call an overloaded function, as in @smallexample p 'foo(char,int)'('x', 13) @end smallexample + The @value{GDBN} command-completion facility can simplify this; -@pxref{Completion, ,Command completion}. +see @ref{Completion, ,Command completion}. @cindex reference declarations @item @@ -6024,13 +6122,13 @@ Control the format for printing virtual function tables. ANSI C++ compiler (@code{aCC}).) @kindex set overload-resolution -@cindex overloaded functions +@cindex overloaded functions, overload resolution @item set overload-resolution on Enable overload resolution for C++ expression evaluation. The default is on. For overloaded functions, @value{GDBN} evaluates the arguments and searches for a function whose signature matches the argument types, -using the standard C++ conversion rules (@pxref{C plus plus expressions, ,C++ -expressions} for details). If it cannot find a match, it emits a +using the standard C++ conversion rules (see @ref{C plus plus expressions, ,C++ +expressions}, for details). If it cannot find a match, it emits a message. @item set overload-resolution off @@ -6054,7 +6152,7 @@ available choices, or to finish the type list for you. @node Modula-2 @subsection Modula-2 -@cindex Modula-2 +@cindex Modula-2, @value{GDBN} support The extensions made to @value{GDBN} to support Modula-2 only support output from the @sc{gnu} Modula-2 compiler (which is currently being @@ -6145,7 +6243,7 @@ Same precedence as @code{<}. Boolean disjunction. Defined on boolean types. @item AND@r{, }& -Boolean conjuction. Defined on boolean types. +Boolean conjunction. Defined on boolean types. @item @@ The @value{GDBN} ``artificial array'' operator (@pxref{Expressions, ,Expressions}). @@ -6366,12 +6464,12 @@ Set constants are not yet supported. If type and range checking are set automatically by @value{GDBN}, they both default to @code{on} whenever the working language changes to -Modula-2. This happens regardless of whether you, or @value{GDBN}, +Modula-2. This happens regardless of whether you or @value{GDBN} selected the working language. If you allow @value{GDBN} to set the language automatically, then entering code compiled from a file whose name ends with @file{.mod} sets the -working language to Modula-2. @xref{Automatically, ,Having @value{GDBN} set +working language to Modula-2. @xref{Automatically, ,Having @value{GDBN} set the language automatically}, for further details. @node Deviations @@ -6438,7 +6536,7 @@ index bounds, and all built-in functions and procedures. @kindex . @cindex colon, doubled as scope operator @ifinfo -@kindex colon-colon +@kindex colon-colon@r{, in Modula-2} @c Info cannot handle :: but TeX can. @end ifinfo @iftex @@ -6483,11 +6581,11 @@ apply to C++, and the last to the C @code{union} type, which has no direct analogue in Modula-2. The @code{@@} operator (@pxref{Expressions, ,Expressions}), while available -while using any language, is not useful with Modula-2. Its +with any language, is not useful with Modula-2. Its intent is to aid the debugging of @dfn{dynamic arrays}, which cannot be created in Modula-2 as they can in C or C++. However, because an address can be specified by an integral constant, the construct -@samp{@{@var{type}@}@var{adrexp}} is still useful. (@pxref{Expressions, ,Expressions}) +@samp{@{@var{type}@}@var{adrexp}} is still useful. @cindex @code{#} in Modula-2 In @value{GDBN} scripts, the Modula-2 inequality operator @code{#} is @@ -6497,12 +6595,14 @@ interpreted as the beginning of a comment. Use @code{<>} instead. @subsection Chill The extensions made to @value{GDBN} to support Chill only support output -from the GNU Chill compiler. Other Chill compilers are not currently +from the @sc{gnu} Chill compiler. Other Chill compilers are not currently supported, and attempting to debug executables produced by them is most likely to give an error as @value{GDBN} reads in the executable's symbol table. -This section covers the following Chill related topics and the features +@c This used to say "... following Chill related topics ...", but since +@c menus are not shown in the printed manual, it would look awkward. +This section covers the Chill related topics and the features of @value{GDBN} which support these topics. @menu @@ -6517,9 +6617,12 @@ of @value{GDBN} which support these topics. @subsubsection How modes are displayed The Chill Datatype- (Mode) support of @value{GDBN} is directly related -with the functionality of the GNU Chill compiler, and therefore deviates +with the functionality of the @sc{gnu} Chill compiler, and therefore deviates slightly from the standard specification of the Chill language. The provided modes are: + +@c FIXME: this @table's contents effectively disable @code by using @r +@c on every @item. So why does it need @code? @table @code @item @r{@emph{Discrete modes:}} @itemize @bullet @@ -6546,7 +6649,7 @@ names). @item @r{@emph{Powerset Mode:}} A Powerset Mode is displayed by the keyword @code{POWERSET} followed by -the member mode of the powerset. The member mode can be any discrete mode. +the member mode of the powerset. The member mode can be any discrete mode. @smallexample (@value{GDBP}) ptype x type = POWERSET SET (egon, hugo, otto) @@ -6555,7 +6658,7 @@ type = POWERSET SET (egon, hugo, otto) @item @r{@emph{Reference Modes:}} @itemize @bullet @item -@emph{Bound Reference Mode} which is diplayed by the keyword @code{REF} +@emph{Bound Reference Mode} which is displayed by the keyword @code{REF} followed by the mode name to which the reference is bound. @item @emph{Free Reference Mode} which is displayed by the keyword @code{PTR}. @@ -6564,8 +6667,8 @@ followed by the mode name to which the reference is bound. @item @r{@emph{Procedure mode}} The procedure mode is displayed by @code{type = PROC(<parameter list>) <return mode> EXCEPTIONS (<exception list>)}. The @code{<parameter -list>} is a list of the parameter modes. @code{<return mode>} indicates -the mode of the result of the procedure if any. The exceptionlist lists +list>} is a list of the parameter modes. @code{<return mode>} indicates +the mode of the result of the procedure if any. The exceptionlist lists all possible exceptions which can be raised by the procedure. @ignore @@ -6618,9 +6721,9 @@ type = ARRAY (1:42) @item @r{@emph{Structure Mode}} The Structure mode is displayed by the keyword @code{STRUCT(<field -list>)}. The @code{<field list>} consists of names and modes of fields -of the structure. Variant structures have the keyword @code{CASE <field> -OF <variant fields> ESAC} in their field list. Since the current version +list>)}. The @code{<field list>} consists of names and modes of fields +of the structure. Variant structures have the keyword @code{CASE <field> +OF <variant fields> ESAC} in their field list. Since the current version of the GNU Chill compiler doesn't implement tag processing (no runtime checks of variant fields, and therefore no debugging info), the output always displays all variant fields. @@ -6645,28 +6748,31 @@ type = STRUCT ( A location in Chill is an object which can contain values. A value of a location is generally accessed by the (declared) name of -the location. The output conforms to the specification of values in -Chill programs. How values are specified -is the topic of the next section. +the location. The output conforms to the specification of values in +Chill programs. How values are specified +is the topic of the next section, @ref{Values and their Operations}. The pseudo-location @code{RESULT} (or @code{result}) can be used to display or change the result of a currently-active procedure: + @smallexample set result := EXPR @end smallexample -- does the same as the Chill action @code{RESULT EXPR} (which + +@noindent +This does the same as the Chill action @code{RESULT EXPR} (which is not available in gdb). Values of reference mode locations are printed by @code{PTR(<hex value>)} in case of a free reference mode, and by @code{(REF <reference -mode>) (<hex-value>)} in case of a bound reference. @code{<hex value>} +mode>) (<hex-value>)} in case of a bound reference. @code{<hex value>} represents the address where the reference points to. To access the value of the location referenced by the pointer, use the dereference -operator `@code{->}'. +operator @samp{->}. Values of procedure mode locations are displayed by @code{@{ PROC (<argument modes> ) <return mode> @} <address> <name of procedure -location>}. @code{<argument modes>} is a list of modes according to the +location>}. @code{<argument modes>} is a list of modes according to the parameter specification of the procedure and @code{<address>} shows the address of the entry point. @@ -6674,9 +6780,9 @@ address of the entry point. Locations of instance modes are displayed just like a structure with two fields specifying the @emph{process type} and the @emph{copy number} of the investigated instance location@footnote{This comes from the current -implementation of instances. They are implemented as a structure (no -na). The output should be something like @code{[<name of the process>; -<instance number>]}.}. The field names are @code{__proc_type} and +implementation of instances. They are implemented as a structure (no +na). The output should be something like @code{[<name of the process>; +<instance number>]}.}. The field names are @code{__proc_type} and @code{__proc_copy}. Locations of synchronization modes are displayed like a structure with @@ -6685,15 +6791,15 @@ like a structure with the field @code{__buffer_data} in case of a buffer mode location (refer to previous paragraph). Structure Mode locations are printed by @code{[.<field name>: <value>, -...]}. The @code{<field name>} corresponds to the structure mode +...]}. The @code{<field name>} corresponds to the structure mode definition and the layout of @code{<value>} varies depending of the mode -of the field. If the investigated structure mode location is of variant -structure mode the variant parts of the structure are enclosed in curled -braces (`@code{@{@}}'). Fields enclosed by `@code{@{,@}}' are residing +of the field. If the investigated structure mode location is of variant +structure mode, the variant parts of the structure are enclosed in curled +braces (@samp{@{@}}). Fields enclosed by @samp{@{,@}} are residing on the same memory location and represent the current values of the -memory location in their specific modes. Since no tag processing is done +memory location in their specific modes. Since no tag processing is done all variants are displayed. A variant field is printed by -@code{(<variant name>) = .<field name>: <value>}. (who implements the +@code{(<variant name>) = .<field name>: <value>}. (who implements the stuff ???) @smallexample (@value{GDBP}) print str1 $4 = [.as: 0, .bs: karli, .<TAG>: { (karli) = @@ -6703,14 +6809,16 @@ stuff ???) Substructures of string mode-, array mode- or structure mode-values (e.g. array slices, fields of structure locations) are accessed using -certain operations which are descibed in the next chapter. +certain operations which are described in the next section, @ref{Values +and their Operations}. A location value may be interpreted as having a different mode using the -location conversion. This mode conversion is written as @code{<mode -name>(<location>)}. The user has to consider that the sizes of the modes -have to be equal otherwise an error message occurs. Further no range -checking of the location against the destination mode is performed and +location conversion. This mode conversion is written as @code{<mode +name>(<location>)}. The user has to consider that the sizes of the modes +have to be equal otherwise an error occurs. Furthermore, no range +checking of the location against the destination mode is performed, and therefore the result can be quite confusing. + @smallexample (@value{GDBP}) print int (s(3 up 4)) XXX TO be filled in !! XXX @end smallexample @@ -6720,27 +6828,29 @@ therefore the result can be quite confusing. Values are used to alter locations, to investigate complex structures in more detail or to filter relevant information out of a large amount of -data. There are several (mode dependent) operations defined which enable -such investigations. These operations are not only applicable to +data. There are several (mode dependent) operations defined which enable +such investigations. These operations are not only applicable to constant values but also to locations, which can become quite useful -when debugging complex structures. During parsing the command line +when debugging complex structures. During parsing the command line (e.g. evaluating an expression) @value{GDBN} treats location names as the values behind these locations. -This subchapters describes how values have to be specified and which +This section describes how values have to be specified and which operations are legal to be used with such values. @table @code @item Literal Values -Literal values are specified in the same manner as in GNU Chill programs. -For detailed specification refer to the GNU Chill implementation Manual +Literal values are specified in the same manner as in @sc{gnu} Chill programs. +For detailed specification refer to the @sc{gnu} Chill implementation Manual chapter 1.5. +@c FIXME: if the Chill Manual is a Texinfo documents, the above should +@c be converted to a @ref. @ignore @itemize @bullet @item @emph{Integer Literals} are specified in the same manner as in Chill -programs (refer z200/88 chpt 5.2.4.2) +programs (refer to the Chill Standard z200/88 chpt 5.2.4.2) @item @emph{Boolean Literals} are defined by @code{TRUE} and @code{FALSE}. @item @@ -6748,42 +6858,43 @@ programs (refer z200/88 chpt 5.2.4.2) @code{'M'}) @item @emph{Set Literals} are defined by a name which was specified in a set -mode. The value delivered by a Set Literal is the set value. This is -comparable to an enumaration in C/C++ language. +mode. The value delivered by a Set Literal is the set value. This is +comparable to an enumeration in C/C++ language. @item -@emph{Emptiness Literal} is predefined by @code{NULL}. The value of the +@emph{Emptiness Literal} is predefined by @code{NULL}. The value of the emptiness literal delivers either the empty reference value, the empty procedure value or the empty instance value. @item @emph{Character String Literals} are defined by a sequence of characters -enclosed in single- or double quotes. If a single- or double quote has +enclosed in single- or double quotes. If a single- or double quote has to be part of the string literal it has to be stuffed (specified twice). @item @emph{Bitstring Literals} are specified in the same manner as in Chill programs (refer z200/88 chpt 5.2.4.8). @item @emph{Floating point literals} are specified in the same manner as in -(gnu-)Chill programs (refer GNU Chill implementation Manual chapter 1.5). +(gnu-)Chill programs (refer @sc{gnu} Chill implementation Manual chapter 1.5). @end itemize @end ignore @item Tuple Values A tuple is specified by @code{<mode name>[<tuple>]}, where @code{<mode -name>} can be omitted if the mode of the tuple is unambigous. This +name>} can be omitted if the mode of the tuple is unambiguous. This unambiguity is derived from the context of a evaluated expression. @code{<tuple>} can be one of the following: + @itemize @bullet @item @emph{Powerset Tuple} @item @emph{Array Tuple} @item @emph{Structure Tuple} Powerset tuples, array tuples and structure tuples are specified in the -same manner as in Chill programs refer z200/88 chpt 5.2.5. +same manner as in Chill programs refer to z200/88 chpt 5.2.5. @end itemize @item String Element Value A string element value is specified by @code{<string value>(<index>)}, -where @code{<index>} is a integer expression. It delivers a character +where @code{<index>} is a integer expression. It delivers a character value which is equivalent to the character indexed by @code{<index>} in the string. @@ -6802,31 +6913,32 @@ delivers a array element value of the mode of the specified array. @item Array Slice Values An array slice is specified by @code{<array value>(<slice spec>)}, where @code{<slice spec>} can be either a range specified by expressions or by -@code{<start expr> up <size>}. @code{<size>} denotes the number of -arrayelements the slice contains. The delivered value is an array value +@code{<start expr> up <size>}. @code{<size>} denotes the number of +arrayelements the slice contains. The delivered value is an array value which is part of the specified array. @item Structure Field Values A structure field value is derived by @code{<structure value>.<field -name>}, where @code{<field name>} indcates the name of a field specified -in the mode definition of the structure. The mode of the delivered value +name>}, where @code{<field name>} indicates the name of a field specified +in the mode definition of the structure. The mode of the delivered value corresponds to this mode definition in the structure definition. @item Procedure Call Value The procedure call value is derived from the return value of the procedure@footnote{If a procedure call is used for instance in an expression, then this procedure is called with all its side -effects. This can lead to confusing results if used carelessly.}. +effects. This can lead to confusing results if used carelessly.}. -Values of duration mode locations are represented by ULONG literals. +Values of duration mode locations are represented by @code{ULONG} literals. -Values of time mode locations are represented by TIME(<secs>:<nsecs>). +Values of time mode locations are represented by @code{TIME(<secs>:<nsecs>)}. @ignore This is not implemented yet: @item Built-in Value @noindent The following built in functions are provided: + @table @code @item @code{ADDR()} @item @code{NUM()} @@ -6862,42 +6974,53 @@ current active process. @item Expression Values The value delivered by an expression is the result of the evaluation of -the specified expression. If there are error conditions (mode +the specified expression. If there are error conditions (mode incompatibility, etc.) the evaluation of expressions is aborted with a -corresponding error message. Expressions may be paranthesised which +corresponding error message. Expressions may be parenthesised which causes the evaluation of this expression before any other expression -which uses the result of the paranthesised expression. The following +which uses the result of the parenthesised expression. The following operators are supported by @value{GDBN}: + @table @code @item @code{OR, ORIF, XOR} -@item @code{AND, ANDIF} -@item @code{NOT} +@itemx @code{AND, ANDIF} +@itemx @code{NOT} Logical operators defined over operands of boolean mode. + @item @code{=, /=} Equality and inequality operators defined over all modes. + @item @code{>, >=} -@item @code{<, <=} +@itemx @code{<, <=} Relational operators defined over predefined modes. + @item @code{+, -} -@item @code{*, /, MOD, REM} +@itemx @code{*, /, MOD, REM} Arithmetic operators defined over predefined modes. + @item @code{-} Change sign operator. + @item @code{//} String concatenation operator. + @item @code{()} String repetition operator. + @item @code{->} Referenced location operator which can be used either to take the address of a location (@code{->loc}), or to dereference a reference location (@code{loc->}). + @item @code{OR, XOR} -@item @code{AND} -@item @code{NOT} +@itemx @code{AND} +@itemx @code{NOT} Powerset and bitstring operators. + @item @code{>, >=} -@item @code{<, <=} +@itemx @code{<, <=} Powerset inclusion operators. + @item @code{IN} Membership operator. @end table @@ -6907,21 +7030,20 @@ Membership operator. @subsubsection Chill type and range checks @value{GDBN} considers two Chill variables mode equivalent if the sizes -of the two modes are equal. This rule applies recursively to more +of the two modes are equal. This rule applies recursively to more complex datatypes which means that complex modes are treated -eqivalent if all element modes (which also can be complex modes like +equivalent if all element modes (which also can be complex modes like structures, arrays, etc.) have the same size. Range checking is done on all mathematical operations, assignment, array index bounds and all built in procedures. Strong type checks are forced using the @value{GDBN} command @code{set -check strong}. This enforces strong type and range checks on all +check strong}. This enforces strong type and range checks on all operations where Chill constructs are used (expressions, built in functions, etc.) in respect to the semantics as defined in the z.200 language specification. -@noindent All checks can be disabled by the @value{GDBN} command @code{set check off}. @@ -6935,18 +7057,18 @@ see last paragraph ? If type and range checking are set automatically by @value{GDBN}, they both default to @code{on} whenever the working language changes to -Chill. This happens regardless of whether you, or @value{GDBN}, +Chill. This happens regardless of whether you or @value{GDBN} selected the working language. If you allow @value{GDBN} to set the language automatically, then entering code compiled from a file whose name ends with @file{.ch} sets the -working language to Chill. @xref{Automatically, ,Having @value{GDBN} set +working language to Chill. @xref{Automatically, ,Having @value{GDBN} set the language automatically}, for further details. @node Symbols @chapter Examining the Symbol Table -The commands described in this section allow you to inquire about the +The commands described in this chapter allow you to inquire about the symbols (names of variables, functions and types) defined in your program. This information is inherent in the text of your program and does not change as your program executes. @value{GDBN} finds it in your @@ -6986,8 +7108,8 @@ at all for a register variable, and for a stack local variable prints the exact address of the current instantiation of the variable. @kindex whatis -@item whatis @var{exp} -Print the data type of expression @var{exp}. @var{exp} is not +@item whatis @var{expr} +Print the data type of expression @var{expr}. @var{expr} is not actually evaluated, and any side-effecting operations (such as assignments or function calls) inside it do not take place. @xref{Expressions, ,Expressions}. @@ -7002,9 +7124,9 @@ the name of a type, or for C code it may have the form @samp{class @var{class-name}}, @samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or @samp{enum @var{enum-tag}}. -@item ptype @var{exp} +@item ptype @var{expr} @itemx ptype -Print a description of the type of expression @var{exp}. @code{ptype} +Print a description of the type of expression @var{expr}. @code{ptype} differs from @code{whatis} by printing a detailed description, instead of just the name of the type. @@ -7036,11 +7158,11 @@ the type of @code{$}, the last value in the value history. @kindex info types @item info types @var{regexp} @itemx info types -Print a brief description of all types whose name matches @var{regexp} +Print a brief description of all types whose names match @var{regexp} (or all types in your program, if you supply no argument). Each complete typename is matched as though it were a complete line; thus, @samp{i type value} gives information on all types in your program whose -name includes the string @code{value}, but @samp{i type ^value$} gives +names include the string @code{value}, but @samp{i type ^value$} gives information only on types whose complete name is @code{value}. This command differs from @code{ptype} in two ways: first, like @@ -7666,8 +7788,8 @@ The @code{section} command changes the base address of section SECTION of the exec file to ADDR. This can be used if the exec file does not contain section addresses, (such as in the a.out format), or when the addresses specified in the file itself are wrong. Each section must be changed -separately. The ``info files'' command lists all the sections and their -addresses. +separately. The @code{info files} command, described below, lists all +the sections and their addresses. @kindex info files @kindex info target @@ -7714,7 +7836,6 @@ Print the names of the shared libraries which are currently loaded. @kindex share @item sharedlibrary @var{regex} @itemx share @var{regex} - Load shared object library symbols for files matching a Unix regular expression. As with files loaded automatically, it only loads shared libraries @@ -7728,8 +7849,8 @@ and automatically reads in symbols from the newly loaded library, up to a threshold that is initially set but that you can modify if you wish. Beyond that threshold, symbols from shared libraries must be explicitly -loaded. To load these symbols, use the command @code{sharedlibrary} -@var{filename}. The base address of the shared library is determined +loaded. To load these symbols, use the command @code{sharedlibrary +@var{filename}}. The base address of the shared library is determined automatically by @value{GDBN} and need not be specified. To display or set the threshold, use the commands: @@ -7815,7 +7936,7 @@ with this name. The symbol information contains new data types that @value{GDBN} does not yet know how to read. @code{0x@var{nn}} is the symbol type of the -misunderstood information, in hexadecimal. +uncomprehended information, in hexadecimal. @value{GDBN} circumvents the error by ignoring this symbol information. This usually allows you to debug your program, though certain symbols @@ -7935,10 +8056,13 @@ a @dfn{core}, or a @dfn{.o} file; however, you can specify the file format with the @code{set gnutarget} command. Unlike most @code{target} commands, with @code{gnutarget} the @code{target} refers to a program, not a machine. +@quotation @emph{Warning:} To specify a file format with @code{set gnutarget}, you must know the actual BFD name. +@end quotation -@noindent @xref{Files, , Commands to specify files}. +@noindent +@xref{Files, , Commands to specify files}. @kindex show gnutarget @item show gnutarget @@ -7967,7 +8091,7 @@ A core dump file. @samp{target core @var{filename}} is the same as Remote serial target in GDB-specific protocol. The argument @var{dev} specifies what serial device to use for the connection (e.g. @file{/dev/ttya}). @xref{Remote, ,Remote debugging}. @code{target remote} -now supports the @code{load} command. This is only useful if you have +supports the @code{load} command. This is only useful if you have some other way of getting the stub to the target system, and you can put it somewhere in memory where it won't get clobbered by the download. @@ -7980,8 +8104,9 @@ In general, load run @end example +@noindent works; however, you cannot assume that a specific memory map, device -drivers, or even basic I/O is available, although some simulator do +drivers, or even basic I/O is available, although some simulators do provide these. For info about any processor-specific simulator details, see the appropriate section in @ref{Embedded Processors, ,Embedded Processors}. @@ -8043,7 +8168,7 @@ offer the ability to run either big-endian or little-endian byte orders. Usually the executable or symbol will include a bit to designate the endian-ness, and you will not need to worry about which to use. However, you may still find it useful to adjust -GDB's idea of processor endian-ness manually. +@value{GDBN}'s idea of processor endian-ness manually. @table @code @kindex set endian big @@ -8108,7 +8233,7 @@ have a name like @file{crt0}. The startup routine may be supplied by your hardware supplier, or you may have to write your own. @item -You probably need a C subroutine library to support your program's +A C subroutine library to support your program's subroutine calls, notably managing input and output. @item @@ -8216,7 +8341,7 @@ run when a trap is triggered. execution (for example, on a breakpoint), and mediates communications with @value{GDBN} on the host machine. This is where the communications protocol is implemented; @code{handle_exception} acts as the @value{GDBN} -representative on the target machine; it begins by sending summary +representative on the target machine. It begins by sending summary information on the state of your program, then continues to execute, retrieving and transmitting any information @value{GDBN} needs, until you execute a @value{GDBN} command that makes your program resume; at that point, @@ -8306,7 +8431,7 @@ help from @code{exceptionHandler}. @item void flush_i_cache() @kindex flush_i_cache -(sparc and sparclite only) Write this subroutine to flush the +On @sc{sparc} and @sc{sparclite} only, write this subroutine to flush the instruction cache, if any, on your target machine. If there is no instruction cache, this subroutine may be a no-op. @@ -8329,7 +8454,7 @@ either obtain it from your hardware manufacturer, or write your own. If you do not use the GNU C compiler, you may need other standard library subroutines as well; this varies from one stub to another, but in general the stubs are likely to use any of the common library -subroutines which @code{gcc} generates as inline code. +subroutines which @code{@value{GCC}} generates as inline code. @node Debug Session @@ -8364,8 +8489,9 @@ For the 680x0 stub only, you need to provide a variable called void (*exceptionHook)() = 0; @end example +@noindent but if before calling @code{set_debug_traps}, you set it to point to a -function in your program, that function is called when +function in your program; that function is called when @code{@value{GDBN}} continues after stopping on a trap (for example, bus error). The function indicated by @code{exceptionHook} is called with one parameter: an @code{int} which is the exception number. @@ -8390,8 +8516,9 @@ as an executable file the program that is running in the remote machine. This tells @value{GDBN} how to find your program's symbols and the contents of its pure text. +@item @cindex serial line, @code{target remote} -Then establish communication using the @code{target remote} command. +Establish communication using the @code{target remote} command. Its argument specifies how to communicate with the target machine---either via a devicename attached to a direct serial line, or a TCP port (usually to a terminal server which in turn has a serial line @@ -8482,7 +8609,7 @@ or, with the optional @var{sequence-id}: The two-digit @var{checksum} is computed as the modulo 256 sum of all characters between the leading @samp{$} and the trailing @samp{#} (that consisting of both the optional @var{sequence-id}@code{:} and the actual -@var{packet-data}). +@var{packet-data}) (an eight bit unsigned checksum). @cindex sequence-id, for @value{GDBN} remote @noindent @@ -8525,8 +8652,13 @@ Response @var{data} can be run-length encoded to save space. A @samp{*} means that the next character is an ASCII encoding giving a repeat count which stands for that many repetitions of the character preceding the @samp{*}. The encoding is @code{n+29}, yielding a printable character -where @code{n >=3} (which is where rle starts to win). Don't use an -@code{n > 126}. +where @code{n >=3} (which is where rle starts to win). The printable +characters @samp{$}, @samp{#}, @samp{+} and @samp{-} or with a numeric +value greater than 126 should not be used. + +Some remote systems have used a different run-length encoding mechanism +loosely refered to as the cisco encoding. Following the @samp{*} +character are two hex digits that indicate the size of the packet. So: @example @@ -8541,7 +8673,7 @@ error number. That number is not well defined. For any @var{command} not supported by the stub, an empty response (@samp{$#00}) should be returned. That way it is possible to extend the protocol. A newer @value{GDBN} can tell if a packet is supported based -on the response. +on that response. Below is a complete list of all currently defined @var{command}s and their corresponding response @var{data}: @@ -8554,7 +8686,7 @@ their corresponding response @var{data}: @item extended ops @emph{(optional)} @tab @code{!} @tab -Use the extended remote protocol. Sticky -- only needs to be set once. +Use the extended remote protocol. Sticky---only needs to be set once. The extended remote protocol support the @samp{R} packet. @item @tab reply @samp{} @@ -8566,9 +8698,12 @@ support protocol extensions. @item last signal @tab @code{?} @tab -Reply the current reason for stopping. This is the same reply as is -generated for step or cont : @code{S}@var{AA} where @var{AA} is the -signal number. +Indicate the reason the target halted. The reply is the same as for step +and continue. +@item +@tab reply +@tab see below + @item reserved @tab @code{a} @@ -8579,6 +8714,7 @@ signal number. @tab Initialized @samp{argv[]} array passed into program. @var{arglen} specifies the number of bytes in the hex encoded byte stream @var{arg}. +See @file{gdbserver} for more details. @item @tab reply @code{OK} @item @@ -8622,14 +8758,20 @@ Continue with signal @var{sig} (hex signal number). If @tab reply @tab see below -@item toggle debug @emph{(optional)} +@item toggle debug @emph{(deprecated)} @tab @code{d} @tab -toggle debug flag (see 386 & 68k stubs) +toggle debug flag. @item detach @emph{(optional)} @tab @code{D} -@tab Reply OK. +@tab +Detach GDB from the remote system. Sent to the remote target before +GDB disconnects. +@item +@tab reply @emph{no response} +@tab +GDB does not check for any response after sending this packet @item reserved @tab @code{e} @@ -8655,9 +8797,10 @@ toggle debug flag (see 386 & 68k stubs) @tab Each byte of register data is described by two hex digits. The bytes with the register are transmitted in target byte order. The size of -each register and their position within the @samp{g} @var{packet} is -determined by the @var{REGISTER_RAW_SIZE} and @var{REGISTER_NAME} -macros. +each register and their position within the @samp{g} @var{packet} are +determined by the GDB internal macros @var{REGISTER_RAW_SIZE} and +@var{REGISTER_NAME} macros. The specification of several standard +@code{g} packets is specified below. @item @tab @code{E}@var{NN} @tab for an error. @@ -8680,10 +8823,10 @@ See @samp{g} for a description of the @var{XX...} data. @item set thread @emph{(optional)} @tab @code{H}@var{c}@var{t...} @tab -Set thread for subsequent operations. @var{c} = @samp{c} for thread -used in step and continue; @var{t...} can be -1 for all threads. -@var{c} = @samp{g} for thread used in other operations. If zero, pick a -thread, any thread. +Set thread for subsequent operations (@samp{m}, @samp{M}, @samp{g}, +@samp{G}, et.al.). @var{c} = @samp{c} for thread used in step and +continue; @var{t...} can be -1 for all threads. @var{c} = @samp{g} for +thread used in other operations. If zero, pick a thread, any thread. @item @tab reply @code{OK} @tab for success @@ -8691,6 +8834,21 @@ thread, any thread. @tab reply @code{E}@var{NN} @tab for an error +@c FIXME: JTC: +@c 'H': How restrictive (or permissive) is the thread model. If a +@c thread is selected and stopped, are other threads allowed +@c to continue to execute? As I mentioned above, I think the +@c semantics of each command when a thread is selected must be +@c described. For example: +@c +@c 'g': If the stub supports threads and a specific thread is +@c selected, returns the register block from that thread; +@c otherwise returns current registers. +@c +@c 'G' If the stub supports threads and a specific thread is +@c selected, sets the registers of the register block of +@c that thread; otherwise sets current registers. + @item cycle step @strong{(draft)} @emph{(optional)} @tab @code{i}@var{addr}@code{,}@var{nnn} @tab @@ -8714,6 +8872,8 @@ See @samp{i} and @samp{S} for likely syntax and semantics. @item kill request @emph{(optional)} @tab @code{k} @tab +FIXME: @emph{There is no description of how operate when a specific +thread context has been selected (ie. does 'k' kill only that thread?)}. @item reserved @tab @code{l} @@ -8727,11 +8887,16 @@ See @samp{i} and @samp{S} for likely syntax and semantics. @tab @code{m}@var{addr}@code{,}@var{length} @tab Read @var{length} bytes of memory starting at address @var{addr}. +Neither GDB nor the stub assume that sized memory transfers are assumed +using word alligned accesses. FIXME: @emph{A word aligned memory +transfer mechanism is needed.} @item @tab reply @var{XX...} @tab -@var{XX...} is mem contents. Can be fewer bytes than requested if able to -read only part of the data. +@var{XX...} is mem contents. Can be fewer bytes than requested if able +to read only part of the data. Neither GDB nor the stub assume that +sized memory transfers are assumed using word alligned accesses. FIXME: +@emph{A word aligned memory transfer mechanism is needed.} @item @tab reply @code{E}@var{NN} @tab @var{NN} is errno @@ -8789,15 +8954,14 @@ digits for each byte in the register (target byte order). @item general query @emph{(optional)} @tab @code{q}@var{query} @tab -Request info about @var{query}. In general @value{GDBN} @var{query}'s +Request info about @var{query}. In general @value{GDBN} @var{query}'s have a leading upper case letter. Custom vendor queries should use a -leading lower case letter and a company prefix, ex: @samp{qfsf.var}. -@var{query} may optionally be followed by a @samp{,} or @samp{;} -separated list. Stubs should ensure that they fully match any -@var{query} name. +company prefix (in lower case) ex: @samp{qfsf.var}. @var{query} may +optionally be followed by a @samp{,} or @samp{;} separated list. Stubs +must ensure that they match the full @var{query} name. @item @tab reply @code{XX...} -@tab Hex encoded data from query. The reply can not be empty. +@tab Hex encoded data from query. The reply can not be empty. @item @tab reply @code{E}@var{NN} @tab error reply @@ -8805,96 +8969,23 @@ separated list. Stubs should ensure that they fully match any @tab reply @samp{} @tab Indicating an unrecognized @var{query}. -@item current thread -@tab @code{q}@code{C} -@tab Return the current thread id. -@item -@tab reply @code{QC}@var{pid} -@tab -Where @var{pid} is a HEX encoded 16 bit process id. -@item -@tab reply * -@tab Any other reply implies the old pid. - -@item compute CRC of memory block -@tab @code{q}@code{CRC:}@var{addr}@code{,}@var{length} -@tab -@item -@tab reply @code{E}@var{NN} -@tab An error (such as memory fault) -@item -@tab reply @code{C}@var{CRC32} -@tab A 32 bit cyclic redundancy check of the specified memory region. - -@item query @var{LIST} or @var{threadLIST} -@tab @code{q}@code{L}@var{startflag}@var{threadcount}@var{nextthread} -@tab -Obtain thread information from RTOS. @var{startflag} is one hex digit; -@var{threadcount} is two hex digits; and @var{nextthread} is 16 hex -digits. -@item -@tab reply * -@tab -See @code{remote.c:parse_threadlist_response()}. - -@item query sect offs -@tab @code{q}@code{Offsets} -@tab Get section offsets. -@item -@tab reply @code{Text=}@var{xxx}@code{;Data=}@var{yyy}@code{;Bss=}@var{zzz} - -@item thread info request -@tab @code{q}@code{P}@var{mode}@var{threadid} -@tab -Returns information on @var{threadid}. Where: @var{mode} is a hex -encoded 32 bit mode; @var{threadid} is a hex encoded 64 bit thread ID. -@item -@tab reply * -@tab -See @code{remote.c:remote_unpack_thread_info_response()}. - -@item remote command -@tab @code{q}@code{Rcmd,}@var{COMMAND} -@tab -@var{COMMAND} (hex encoded) is passed to the local interpreter for -execution. Invalid commands should be reported using the output string. -Before the final result packet, the target may also respond with a -number of intermediate @code{O}@var{OUTPUT} console output -packets. @emph{Implementors should note that providing access to a -stubs's interpreter may have security implications}. -@item -@tab reply @code{OK} -@tab -A command response with no output. -@item -@tab reply @var{OUTPUT} -@tab -A command response with the hex encoded output string @var{OUTPUT}. -@item -@tab reply @code{E}@var{NN} -@tab -Indicate a badly formed request. - -@item -@tab reply @samp{} -@tab -When @samp{q}@samp{Rcmd} is not recognized. - @item general set @emph{(optional)} @tab @code{Q}@var{var}@code{=}@var{val} @tab Set value of @var{var} to @var{val}. See @samp{q} for a discussing of naming conventions. -@item reset @emph{(optional)} -@tab r -@tab reset -- see sparc stub. +@item reset @emph{(deprecated)} +@tab @code{r} +@tab +Reset the entire system. @item remote restart @emph{(optional)} @tab @code{R}@var{XX} @tab -Restart the remote server. @var{XX} while needed has no clear -definition. +Restart the remote server. @var{XX} while needed has no clear +definition. FIXME: @emph{An example interaction explaining how this +packet is used in extended-remote mode is needed}. @item step @emph{(optional)} @tab @code{s}@var{addr} @@ -8918,7 +9009,7 @@ Like @samp{C} but step not continue. @tab Search backwards starting at address @var{addr} for a match with pattern @var{PP} and mask @var{MM}. @var{PP} and @var{MM} are 4 -bytes. @var{addr} must be at least 3 digits. +bytes. @var{addr} must be at least 3 digits. @item thread alive @emph{(optional)} @tab @code{T}@var{XX} @@ -8962,7 +9053,8 @@ bytes. @var{addr} must be at least 3 digits. @tab @code{X}@var{addr}@code{,}@var{length}@var{:}@var{XX...} @tab @var{addr} is address, @var{length} is number of bytes, @var{XX...} is -binary data. +binary data. The characters @code{$}, @code{#}, and @code{0x7d} are +escaped using @code{0x7d}. @item @tab reply @code{OK} @tab for success @@ -8991,7 +9083,9 @@ breakpoint, @samp{2} - write watchpoint, @samp{3} - read watchpoint, @samp{4} - access watchpoint; @var{addr} is address; @var{length} is in bytes. For a software breakpoint, @var{length} specifies the size of the instruction to be patched. For hardware breakpoints and watchpoints -@var{length} specifies the memory region to be monitored. +@var{length} specifies the memory region to be monitored. To avoid +potential problems with duplicate packets, the operations should be +implemented in an ident-potentent way. @item @tab reply @code{E}@var{NN} @tab for an error @@ -9008,9 +9102,12 @@ the instruction to be patched. For hardware breakpoints and watchpoints @end multitable -In the case of the @samp{C}, @samp{c}, @samp{S} and @samp{s} packets, -there is no immediate response. The reply, described below, comes when -the machine stops: +The @samp{C}, @samp{c}, @samp{S}, @samp{s} and @samp{?} packets can +receive any of the below as a reply. In the case of the @samp{C}, +@samp{c}, @samp{S} and @samp{s} packets, that reply is only returned +when the target halts. In the below the exact meaning of @samp{signal +number} is poorly defined. In general one of the UNIX signal numbering +conventions is used. @multitable @columnfractions .4 .6 @@ -9023,7 +9120,7 @@ the machine stops: (hex), @var{r...} = target byte ordered register contents, size defined by @code{REGISTER_RAW_SIZE}; @var{n...} = @samp{thread}, @var{r...} = thread process ID, this is a hex integer; @var{n...} = other string not -starting with valid hex digit. @value{GDBN} should ignore this +starting with valid hex digit. @value{GDBN} should ignore this @var{n...}, @var{r...} pair and go on to the next. This way we can extend the protocol. @@ -9040,19 +9137,131 @@ The process terminated with signal @var{AA}. @tab @var{AA} = signal number; @var{tttttttt} = address of symbol "_start"; @var{dddddddd} = base of data section; @var{bbbbbbbb} = base of bss -section. @emph{Note: only used by Cisco Systems targets. The difference +section. @emph{Note: only used by Cisco Systems targets. The difference between this reply and the "qOffsets" query is that the 'N' packet may arrive spontaneously whereas the 'qOffsets' is a query initiated by the host debugger.} @item @code{O}@var{XX...} @tab -@var{XX...} is hex encoding of ASCII data. This can happen at any time +@var{XX...} is hex encoding of ASCII data. This can happen at any time while the program is running and the debugger should continue to wait for 'W', 'T', etc. @end multitable +The following set and query packets have already been defined. + +@multitable @columnfractions .2 .2 .6 + +@item current thread +@tab @code{q}@code{C} +@tab Return the current thread id. +@item +@tab reply @code{QC}@var{pid} +@tab +Where @var{pid} is a HEX encoded 16 bit process id. +@item +@tab reply * +@tab Any other reply implies the old pid. + +@item compute CRC of memory block +@tab @code{q}@code{CRC:}@var{addr}@code{,}@var{length} +@tab +@item +@tab reply @code{E}@var{NN} +@tab An error (such as memory fault) +@item +@tab reply @code{C}@var{CRC32} +@tab A 32 bit cyclic redundancy check of the specified memory region. + +@item query @var{LIST} or @var{threadLIST} @strong{(deprecated)} +@tab @code{q}@code{L}@var{startflag}@var{threadcount}@var{nextthread} +@tab +Obtain thread information from RTOS. Where: @var{startflag} (one hex +digit) is one to indicate the first query and zero to indicate a +subsequent query; @var{threadcount} (two hex digits) is the maximum +number of threads the response packet can contain; and @var{nextthread} +(eight hex digits), for subsequent queries (@var{startflag} is zero), is +returned in the response as @var{argthread}. +@item +@tab reply @code{q}@code{M}@var{count}@var{done}@var{argthread}@var{thread...} +@tab +Where: @var{count} (two hex digits) is the number of threads being +returned; @var{done} (one hex digit) is zero to indicate more threads +and one indicates no further threads; @var{argthreadid} (eight hex +digits) is @var{nextthread} from the request packet; @var{thread...} is +a sequence of thread IDs from the target. @var{threadid} (eight hex +digits). See @code{remote.c:parse_threadlist_response()}. + +@item query sect offs +@tab @code{q}@code{Offsets} +@tab Get section offsets. +@item +@tab reply @code{Text=}@var{xxx}@code{;Data=}@var{yyy}@code{;Bss=}@var{zzz} + +@item thread info request +@tab @code{q}@code{P}@var{mode}@var{threadid} +@tab +Returns information on @var{threadid}. Where: @var{mode} is a hex +encoded 32 bit mode; @var{threadid} is a hex encoded 64 bit thread ID. +@item +@tab reply * +@tab +See @code{remote.c:remote_unpack_thread_info_response()}. + +@item remote command +@tab @code{q}@code{Rcmd,}@var{COMMAND} +@tab +@var{COMMAND} (hex encoded) is passed to the local interpreter for +execution. Invalid commands should be reported using the output string. +Before the final result packet, the target may also respond with a +number of intermediate @code{O}@var{OUTPUT} console output +packets. @emph{Implementors should note that providing access to a +stubs's interpreter may have security implications}. +@item +@tab reply @code{OK} +@tab +A command response with no output. +@item +@tab reply @var{OUTPUT} +@tab +A command response with the hex encoded output string @var{OUTPUT}. +@item +@tab reply @code{E}@var{NN} +@tab +Indicate a badly formed request. + +@item +@tab reply @samp{} +@tab +When @samp{q}@samp{Rcmd} is not recognized. + +@end multitable + +The following @samp{g}/@samp{G} packets have previously been defined. +In the below, some thirty-two bit registers are transferred as sixty-four +bits. Those registers should be zero/sign extended (which?) to fill the +space allocated. Register bytes are transfered in target byte order. +The two nibbles within a register byte are transfered most-significant - +least-significant. + +@multitable @columnfractions .5 .5 + +@item MIPS32 +@tab +All registers are transfered as thirty-two bit quantities in the order: +32 general-purpose; sr; lo; hi; bad; cause; pc; 32 floating-point +registers; fsr; fir; fp. + +@item MIPS64 +@tab +All registers are transfered as sixty-four bit quantities (including +thirty-two bit registers such as @code{sr}). The ordering is the same +as @code{MIPS32}. + +@end multitable + Example sequence of a target being re-started. Notice how the restart does not get any direct output: @@ -9082,8 +9291,8 @@ Example sequence of a target being stepped by a single instruction: <- @code{+} @end example -@kindex set remotedebug -@kindex show remotedebug +@kindex set remotedebug@r{, serial protocol} +@kindex show remotedebug@r{, serial protocol} @cindex packets, reporting on stdout @cindex serial connections, debugging If you have trouble with the serial connection, you can use the command @@ -9162,7 +9371,7 @@ you want for the port number as long as it does not conflict with any TCP ports already in use on the target system (for example, @code{23} is reserved for @code{telnet}).@footnote{If you choose a port number that conflicts with another service, @code{gdbserver} prints an error message -and exits.} You must use the same port number with the host @value{GDBN} +and exits.} You must use the same port number with the host @value{GDBN} @code{target remote} command. @item On the @value{GDBN} host machine, @@ -9170,7 +9379,7 @@ you need an unstripped copy of your program, since @value{GDBN} needs symbols and debugging information. Start up @value{GDBN} as usual, using the name of the local copy of your program as the first argument. (You may also need the @w{@samp{--baud}} option if the serial line is -running at anything other than 9600 bps.) After that, use @code{target +running at anything other than 9600@dmn{bps}.) After that, use @code{target remote} to establish communications with @code{gdbserver}. Its argument is either a device name (usually a serial device, like @file{/dev/ttyb}), or a TCP port descriptor in the form @@ -9224,11 +9433,11 @@ load gdbserve [ BOARD=@var{board} ] [ PORT=@var{port} ] @var{board} and @var{port} specify the serial line; @var{baud} specifies the baud rate used by the connection. @var{port} and @var{node} default -to 0, @var{baud} defaults to 9600 bps. +to 0, @var{baud} defaults to 9600@dmn{bps}. For example, to debug Emacs with the argument @samp{foo.txt}and communicate with @value{GDBN} over serial port number 2 or board 1 -using a 19200 bps connection: +using a 19200@dmn{bps} connection: @smallexample load gdbserve BOARD=1 PORT=2 BAUD=19200 emacs foo.txt @@ -9239,7 +9448,7 @@ you need an unstripped copy of your program, since @value{GDBN} needs symbols and debugging information. Start up @value{GDBN} as usual, using the name of the local copy of your program as the first argument. (You may also need the @w{@samp{--baud}} option if the serial line is -running at anything other than 9600 bps. After that, use @code{target +running at anything other than 9600@dmn{bps}. After that, use @code{target remote} to establish communications with @code{gdbserve.nlm}. Its argument is a device name (usually a serial device, like @file{/dev/ttyb}). For example: @@ -9409,9 +9618,9 @@ current target system as well as adding its symbols in @value{GDBN}. VxWorks targets from a Unix host. Already-running tasks spawned from the VxWorks shell can also be debugged. @value{GDBN} uses code that runs on both the Unix host and on the VxWorks target. The program -@code{gdb} is installed and executed on the Unix host. (It may be +@code{@value{GDBP}} is installed and executed on the Unix host. (It may be installed with the name @code{vxgdb}, to distinguish it from a -@value{GDBN} for debugging programs on the host itself.) +@value{GDB} for debugging programs on the host itself.) @table @code @item VxWorks-timeout @var{args} @@ -9440,7 +9649,7 @@ manual. Once you have included @file{rdb.a} in your VxWorks system image and set your Unix execution search path to find @value{GDBN}, you are ready to -run @value{GDBN}. From your Unix host, run @code{gdb} (or @code{vxgdb}, +run @value{GDBN}. From your Unix host, run @code{@value{GDBP}} (or @code{vxgdb}, depending on your installation). @value{GDBN} comes up showing the prompt: @@ -9511,7 +9720,8 @@ program, type this on VxWorks: @example -> cd "@var{vxpath}/vw/demo/rdb" @end example -v + +@noindent Then, in @value{GDBN}, type: @example @@ -9530,7 +9740,7 @@ after editing and recompiling the corresponding source file. Note that this makes @value{GDBN} delete all currently-defined breakpoints, auto-displays, and convenience variables, and to clear the value history. (This is necessary in order to preserve the integrity of -debugger data structures that reference the target system's symbol +debugger's data structures that reference the target system's symbol table.) @node VxWorks Attach @@ -9658,6 +9868,12 @@ you must match the communications parameters when establishing the Unix end of the connection as well. @c FIXME: Who knows what this "no retry action" crud from the DOS manual may @c mean? It's optional; leave it out? ---doc@cygnus.com, 25feb91 +@c +@c It's optional, but it's unwise to omit it: who knows what is the +@c default value set when the DOS machines boots? "No retry" means that +@c the DOS serial device driver won't retry the operation if it fails; +@c I understand that this is needed because the GDB serial protocol +@c handles any errors and retransmissions itself. ---Eli Zaretskii, 3sep99 To give control of the PC to the Unix side of the serial line, type the following at the DOS console: @@ -9700,6 +9916,10 @@ system table @file{/etc/remote}. @c can set these as internal variables, eg ~s parity=none; man stty @c suggests that it *might* work to stty these options with stdin or @c stdout redirected... ---doc@cygnus.com, 25feb91 +@c +@c There's nothing to be done for the "none" part of the DOS MODE +@c command. The rest of the parameters should be matched by the +@c baudrate, bits, and parity used by the Unix side. ---Eli Zaretskii, 3Sep99 @kindex EBMON Using the @code{tip} or @code{cu} connection, change the DOS working @@ -9746,7 +9966,7 @@ running, ready for @value{GDBN} to take over. For this example, we've assumed what is probably the most convenient way to make sure the same 29K program is on both the PC and the Unix -system: a PC/NFS connection that establishes ``drive @code{G:}'' on the +system: a PC/NFS connection that establishes ``drive @file{G:}'' on the PC as a file system on the Unix host. If you do not have PC/NFS or something similar connecting the two systems, you must arrange some other way---perhaps floppy-disk transfer---of getting the 29K program @@ -9794,7 +10014,7 @@ To return control of the PC to its console, use @code{tip} or @code{cu} once again, after your @value{GDBN} session has concluded, to attach to @code{EBMON}. You can then type the command @code{q} to shut down @code{EBMON}, returning control to the DOS command-line interpreter. -Type @code{CTTY con} to return command input to the main DOS console, +Type @kbd{CTTY con} to return command input to the main DOS console, and type @kbd{~.} to leave @code{tip} or @code{cu}. @node Remote Log @@ -9831,18 +10051,18 @@ ARM Demon monitor. @table @code -@kindex target hms +@kindex target hms@r{, with H8/300} @item target hms @var{dev} A Hitachi SH, H8/300, or H8/500 board, attached via serial line to your host. Use special commands @code{device} and @code{speed} to control the serial line and the communications speed used. -@kindex target e7000 +@kindex target e7000@r{, with H8/300} @item target e7000 @var{dev} E7000 emulator for Hitachi H8 and SH. -@kindex target sh3 -@kindex target sh3e +@kindex target sh3@r{, with H8/300} +@kindex target sh3e@r{, with H8/300} @item target sh3 @var{dev} @item target sh3e @var{dev} Hitachi SH-3 and SH-3E target systems. @@ -9899,8 +10119,8 @@ hosts, where it is typically something like @file{/dev/ttya}. @code{@value{GDBP}} has another special command to set the communications speed: @samp{speed @var{bps}}. This command also is only used from Unix hosts; on DOS hosts, set the line speed as usual from outside GDB with -the DOS @kbd{mode} command (for instance, @w{@samp{mode -com2:9600,n,8,1,p}} for a 9600 bps connection). +the DOS @code{mode} command (for instance, +@w{@kbd{mode com2:9600,n,8,1,p}} for a 9600@dmn{bps} connection). The @samp{device} and @samp{speed} commands are available only when you use a Unix host to debug your Hitachi microprocessor programs. If you @@ -9919,7 +10139,7 @@ First hook up your development board. In this example, we use a board attached to serial port @code{COM2}; if you use a different serial port, substitute its name in the argument of the @code{mode} command. When you call @code{asynctsr}, the auxiliary comms program used by the -degugger, you give it just the numeric part of the serial port's name; +debugger, you give it just the numeric part of the serial port's name; for example, @samp{asyncstr 2} below runs @code{asyncstr} on @code{COM2}. @@ -9940,7 +10160,7 @@ disable it, or even boot without it, to use @code{asynctsr} to control your development board. @end quotation -@kindex target hms +@kindex target hms@r{, and serial protocol} Now that serial communications are set up, and the development board is connected, you can start up @value{GDBN}. Call @code{@value{GDBP}} with the name of your program as the argument. @code{@value{GDBP}} prompts @@ -9999,7 +10219,7 @@ development board as a ``normal exit'' of your program. @node Hitachi ICE @subsubsection Using the E7000 in-circuit emulator -@kindex target e7000 +@kindex target e7000@r{, with Hitachi ICE} You can use the E7000 in-circuit emulator to develop code for either the Hitachi SH or the H8/300H. Use one of these forms of the @samp{target e7000} command to connect @value{GDBN} to your E7000: @@ -10356,8 +10576,8 @@ As usual, you can inquire about the @code{mipsfpu} variable with @item set remotedebug @var{n} @itemx show remotedebug -@kindex set remotedebug -@kindex show remotedebug +@kindex set remotedebug@r{, MIPS protocol} +@kindex show remotedebug@r{, MIPS protocol} @cindex @code{remotedebug}, MIPS protocol @cindex MIPS @code{remotedebug} protocol @c FIXME! For this to be useful, you must know something about the MIPS @@ -10434,18 +10654,18 @@ W89K monitor, running on a Winbond HPPA board. @table @code -@kindex target hms +@kindex target hms@r{, with Hitachi SH} @item target hms @var{dev} A Hitachi SH board attached via serial line to your host. Use special commands @code{device} and @code{speed} to control the serial line and the communications speed used. -@kindex target e7000 +@kindex target e7000@r{, with Hitachi SH} @item target e7000 @var{dev} E7000 emulator for Hitachi SH. -@kindex target sh3 -@kindex target sh3e +@kindex target sh3@r{, with SH} +@kindex target sh3e@r{, with SH} @item target sh3 @var{dev} @item target sh3e @var{dev} Hitachi SH-3 and SH-3E target systems. @@ -10461,27 +10681,27 @@ Hitachi SH-3 and SH-3E target systems. Sparclet targets from a Unix host. @value{GDBN} uses code that runs on both the Unix host and on the Sparclet target. The program -@code{gdb} is installed and executed on the Unix host. +@code{@value{GDBP}} is installed and executed on the Unix host. @table @code @item timeout @var{args} @kindex remotetimeout -@value{GDBN} now supports the option @code{remotetimeout}. +@value{GDBN} supports the option @code{remotetimeout}. This option is set by the user, and @var{args} represents the number of seconds @value{GDBN} waits for responses. @end table @kindex Compiling -When compiling for debugging, include the options "-g" to get debug -information and "-Ttext" to relocate the program to where you wish to -load it on the target. You may also want to add the options "-n" or -"-N" in order to reduce the size of the sections. +When compiling for debugging, include the options @samp{-g} to get debug +information and @samp{-Ttext} to relocate the program to where you wish to +load it on the target. You may also want to add the options @samp{-n} or +@samp{-N} in order to reduce the size of the sections. Example: @example sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N @end example -You can use objdump to verify that the addresses are what you intended. +You can use @code{objdump} to verify that the addresses are what you intended: @example sparclet-aout-objdump --headers --syms prog @@ -10490,7 +10710,7 @@ sparclet-aout-objdump --headers --syms prog @kindex Running Once you have set your Unix execution search path to find @value{GDBN}, you are ready to -run @value{GDBN}. From your Unix host, run @code{gdb} +run @value{GDBN}. From your Unix host, run @code{@value{GDBP}} (or @code{sparclet-aout-gdb}, depending on your installation). @value{GDBN} comes up showing the prompt: @@ -10551,9 +10771,9 @@ main () at ../prog.c:3 @need 750 @value{GDBN} displays messages like these: -@smallexample +@example Connected to ttya. -@end smallexample +@end example @node Sparclet Download @subsubsection Sparclet download @@ -10565,7 +10785,7 @@ you can use the @value{GDBN} The file name and load offset should be given as arguments to the @code{load} command. Since the file format is aout, the program must be loaded to the starting -address. You can use objdump to find out what this value is. The load +address. You can use @code{objdump} to find out what this value is. The load offset is an offset which is added to the VMA (virtual memory address) of each of the file's sections. For instance, if the program @@ -10682,7 +10902,7 @@ appropriate by inspecting the object code. @table @code @item target sim @var{args} @kindex sim -@kindex target sim +@kindex target sim@r{, with Z8000} Debug programs on a simulated CPU. If the simulator supports setup options, specify them via @var{args}. @end table @@ -10693,9 +10913,9 @@ CPU in the same style as programs for your host computer; use the @code{file} command to load a new program image, the @code{run} command to run your program, and so on. -As well as making available all the usual machine registers (see -@code{info reg}), the Z8000 simulator provides three additional items -of information as specially named registers: +As well as making available all the usual machine registers +(@pxref{Registers, ,Registers}), the Z8000 simulator provides three +additional items of information as specially named registers: @table @code @@ -10737,7 +10957,7 @@ all uses of GDB with this architecture, both native and cross. @cindex register stack, AMD29K @item set rstack_high_address @var{address} On AMD 29000 family processors, registers are saved in a separate -``register stack''. There is no way for @value{GDBN} to determine the +@dfn{register stack}. There is no way for @value{GDBN} to determine the extent of this stack. Normally, @value{GDBN} just assumes that the stack is ``large enough''. This may result in @value{GDBN} referencing memory locations that do not exist. If necessary, you can get around @@ -10798,7 +11018,7 @@ for debugging programs on Alpha or MIPS processors. You can alter the way @value{GDBN} interacts with you by using the @code{set} command. For commands controlling how @value{GDBN} displays -data, @pxref{Print Settings, ,Print settings}; other settings are +data, see @ref{Print Settings, ,Print settings}. Other settings are described here. @menu @@ -10822,7 +11042,7 @@ instance, when debugging @value{GDBN} with @value{GDBN}, it is useful to change the prompt in one of the @value{GDBN} sessions so that you can always tell which one you are talking to. -@emph{Note:} @code{set prompt} no longer adds a space for you after the +@emph{Note:} @code{set prompt} does not add a space for you after the prompt you set. This allows you to set a prompt which ends in a space or a prompt that does not. @@ -10886,7 +11106,8 @@ list, and where it writes the command history from this session when it exits. You can access this list through history expansion or through the history command editing characters listed below. This file defaults to the value of the environment variable @code{GDBHISTFILE}, or to -@file{./.gdb_history} if this variable is not set. +@file{./.gdb_history} (@file{./_gdb_history} on MS-DOS) if this variable +is not set. @cindex history save @kindex set history save @@ -10976,9 +11197,10 @@ determines when to wrap lines of output. Depending on what is being printed, @value{GDBN} tries to break the line at a readable place, rather than simply letting it overflow onto the following line. -Normally @value{GDBN} knows the size of the screen from the termcap data base +Normally @value{GDBN} knows the size of the screen from the terminal +driver software. For example, on Unix @value{GDBN} uses the termcap data base together with the value of the @code{TERM} environment variable and the -@code{stty rows} and @code{stty cols} settings. If this is not correct, +@code{stty rows} and @code{stty cols} settings. If this is not correct, you can override it with the @code{set height} and @code{set width} commands: @@ -11149,13 +11371,15 @@ define adder print $arg0 + $arg1 + $arg2 @end smallexample -@noindent To execute the command use: +@noindent +To execute the command use: @smallexample adder 1 2 3 @end smallexample -@noindent This defines the command @code{adder}, which prints the sum of +@noindent +This defines the command @code{adder}, which prints the sum of its three arguments. Note the arguments are text substitutions, so they may reference variables, use complex expressions, or even perform inferior functions calls. @@ -11225,13 +11449,15 @@ messages when used in a user-defined command. @node Hooks @section User-defined command hooks -@cindex command files +@cindex command hooks +@cindex hooks, for commands You may define @emph{hooks}, which are a special kind of user-defined command. Whenever you run the command @samp{foo}, if the user-defined command @samp{hook-foo} exists, it is executed (with no arguments) before that command. +@kindex stop@r{, a pseudo-command} In addition, a pseudo-command, @samp{stop} exists. Defining (@samp{hook-stop}) makes the associated commands execute every time execution stops in your program: before breakpoint commands are run, @@ -11278,10 +11504,13 @@ the last command, as it would from the terminal. @cindex init file @cindex @file{.gdbinit} +@cindex @file{gdb.ini} When you start @value{GDBN}, it automatically executes commands from its @dfn{init files}. These are files named @file{.gdbinit} on Unix, or @file{gdb.ini} on DOS/Windows. @value{GDBN} reads the init file (if -any) in your home directory, then processes command line options and +any) in your home directory@footnote{On DOS/Windows systems, the home +directory is the one pointed to by the @code{HOME} environment variable.}, +then processes command line options and operands, and then reads the init file (if any) in the current working directory. This is so the init file in your home directory can set options (such as @code{set complaints}) which affect the processing of @@ -11387,6 +11616,10 @@ Print the values of the @var{expressions} under the control of either numbers or pointers. Their values are printed as specified by @var{string}, exactly as if your program were to execute the C subroutine +@c FIXME: the above implies that at least all ANSI C formats are +@c supported, but it isn't true: %E and %G don't work (or so it seems). +@c Either this is a bug, or the manual should document what formats are +@c supported. @example printf (@var{string}, @var{expressions}@dots{}); @@ -11479,7 +11712,7 @@ Emacs variable @code{gdb-command-name}; for example, @end example @noindent -(preceded by @kbd{ESC ESC}, or typed in the @code{*scratch*} buffer, or +(preceded by @kbd{M-:} or @kbd{ESC :}, or typed in the @code{*scratch*} buffer, or in your @file{.emacs} file) makes Emacs call the program named ``@code{mygdb}'' instead. @@ -11647,11 +11880,11 @@ In any event, we also recommend that you send bug reports for @value{GDBN} to this addresses: @example -bug-gdb@@prep.ai.mit.edu +bug-gdb@@gnu.org @end example @strong{Do not send bug reports to @samp{info-gdb}, or to -@samp{help-gdb}, or to any newsgroups.} Most users of @value{GDBN} do +@samp{help-gdb}, or to any newsgroups.} Most users of @value{GDBN} do not want to receive bug reports. Those that do have arranged to receive @samp{bug-gdb}. diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo index a60c9f3..4418ab7 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -1481,6 +1481,17 @@ trampoline that connects to a shared library. Define this to evaluate to nonzero if the program is stopped in the trampoline that returns from a shared library. +@item IN_SOLIB_DYNSYM_RESOLVE_CODE pc +Define this to evaluate to nonzero if the program is stopped in the +dynamic linker. + +@item SKIP_SOLIB_RESOLVER pc +Define this to evaluate to the (nonzero) address at which execution +should continue to get past the dynamic linker's symbol resolution +function. A zero value indicates that it is not important or necessary +to set a breakpoint to get through the dynamic linker and that single +stepping will suffice. + @item IS_TRAPPED_INTERNALVAR (name) This is an ugly hook to allow the specification of special actions that should occur as a side-effect of setting the value of a variable diff --git a/gdb/dsrec.c b/gdb/dsrec.c index 4cfe835..76e32ab 100644 --- a/gdb/dsrec.c +++ b/gdb/dsrec.c @@ -98,8 +98,14 @@ load_srec (desc, file, load_offset, maxrecsize, flags, hashmark, waitack) bfd_vma addr = bfd_get_section_vma (abfd, s) + load_offset; bfd_size_type size = bfd_get_section_size_before_reloc (s); char *section_name = (char *) bfd_get_section_name (abfd, s); - printf_filtered ("%s\t: 0x%08x .. 0x%08x ", - section_name, (int) addr, (int) addr + size); + /* Both GDB and BFD have mechanisms for printing addresses. + In the below, GDB's is used so that the address is + consistent with the rest of GDB. BFD's printf_vma() could + have also been used. cagney 1999-09-01 */ + printf_filtered ("%s\t: 0x%s .. 0x%s ", + section_name, + paddr (addr), + paddr (addr + size)); gdb_flush (gdb_stdout); data_count += size; diff --git a/gdb/dstread.c b/gdb/dstread.c index 8ed415b..0341727 100644 --- a/gdb/dstread.c +++ b/gdb/dstread.c @@ -1638,13 +1638,13 @@ init_dst_sections (chan) struct section_offsets dst_symfile_faker = {0}; -struct section_offsets * +void dst_symfile_offsets (objfile, addr) struct objfile *objfile; CORE_ADDR addr; { objfile->num_sections = 1; - return &dst_symfile_faker; + objfile->section_offsets = &dst_symfile_faker; } /* Register our ability to parse symbols for DST BFD files */ diff --git a/gdb/dve3900-rom.c b/gdb/dve3900-rom.c index 8565040..60a177d 100644 --- a/gdb/dve3900-rom.c +++ b/gdb/dve3900-rom.c @@ -532,7 +532,7 @@ store_bitmapped_register (regno, bf) oldbits = (oldval >> bf->start) & mask; newbits = (newval >> bf->start) & mask; if (oldbits != newbits) - monitor_printf ("%s %x ", bf->user_name, newbits); + monitor_printf ("%s %lx ", bf->user_name, newbits); } } diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 6a617b3..9db63c2 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -563,14 +563,10 @@ extern int info_verbose; /* From main.c; nonzero => verbose */ static void dwarf2_locate_sections PARAMS ((bfd *, asection *, PTR)); #if 0 -static void dwarf2_build_psymtabs_easy PARAMS ((struct objfile *, - struct section_offsets *, - int)); +static void dwarf2_build_psymtabs_easy PARAMS ((struct objfile *, int)); #endif -static void dwarf2_build_psymtabs_hard PARAMS ((struct objfile *, - struct section_offsets *, - int)); +static void dwarf2_build_psymtabs_hard PARAMS ((struct objfile *, int)); static char *scan_partial_symbols PARAMS ((char *, struct objfile *, CORE_ADDR *, CORE_ADDR *)); @@ -840,9 +836,8 @@ dwarf2_locate_sections (ignore_abfd, sectp, ignore_ptr) /* Build a partial symbol table. */ void -dwarf2_build_psymtabs (objfile, section_offsets, mainline) +dwarf2_build_psymtabs (objfile, mainline) struct objfile *objfile; - struct section_offsets *section_offsets; int mainline; { @@ -867,17 +862,17 @@ dwarf2_build_psymtabs (objfile, section_offsets, mainline) #if 0 if (dwarf_aranges_offset && dwarf_pubnames_offset) { - /* Things are significanlty easier if we have .debug_aranges and + /* Things are significantly easier if we have .debug_aranges and .debug_pubnames sections */ - dwarf2_build_psymtabs_easy (objfile, section_offsets, mainline); + dwarf2_build_psymtabs_easy (objfile, mainline); } else #endif /* only test this case for now */ { /* In this case we have to work a bit harder */ - dwarf2_build_psymtabs_hard (objfile, section_offsets, mainline); + dwarf2_build_psymtabs_hard (objfile, mainline); } } @@ -886,9 +881,8 @@ dwarf2_build_psymtabs (objfile, section_offsets, mainline) .debug_pubnames and .debug_aranges sections. */ static void -dwarf2_build_psymtabs_easy (objfile, section_offsets, mainline) +dwarf2_build_psymtabs_easy (objfile, mainline) struct objfile *objfile; - struct section_offsets *section_offsets; int mainline; { bfd *abfd = objfile->obfd; @@ -923,9 +917,8 @@ dwarf2_build_psymtabs_easy (objfile, section_offsets, mainline) .debug_info and .debug_abbrev sections. */ static void -dwarf2_build_psymtabs_hard (objfile, section_offsets, mainline) +dwarf2_build_psymtabs_hard (objfile, mainline) struct objfile *objfile; - struct section_offsets *section_offsets; int mainline; { /* Instead of reading this into a big buffer, we should probably use @@ -1002,7 +995,7 @@ dwarf2_build_psymtabs_hard (objfile, section_offsets, mainline) set_cu_language (comp_unit_die.language); /* Allocate a new partial symbol table structure */ - pst = start_psymtab_common (objfile, section_offsets, + pst = start_psymtab_common (objfile, objfile->section_offsets, comp_unit_die.name ? comp_unit_die.name : "", comp_unit_die.lowpc, objfile->global_psymbols.next, @@ -1016,7 +1009,7 @@ dwarf2_build_psymtabs_hard (objfile, section_offsets, mainline) DWARF_ABBREV_BUFFER (pst) = dwarf_abbrev_buffer; DWARF_ABBREV_SIZE (pst) = dwarf_abbrev_size; DWARF_LINE_BUFFER (pst) = dwarf_line_buffer; - baseaddr = ANOFFSET (section_offsets, 0); + baseaddr = ANOFFSET (objfile->section_offsets, 0); /* Store the function that reads in the rest of the symbol table */ pst->read_symtab = dwarf2_psymtab_to_symtab; diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index 13599fa..bc6f137 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -704,7 +704,6 @@ set_cu_language (dip) SYNOPSIS void dwarf_build_psymtabs (struct objfile *objfile, - struct section_offsets *section_offsets, int mainline, file_ptr dbfoff, unsigned int dbfsize, file_ptr lnoffset, unsigned int lnsize) @@ -728,10 +727,9 @@ set_cu_language (dip) */ void -dwarf_build_psymtabs (objfile, section_offsets, mainline, dbfoff, dbfsize, +dwarf_build_psymtabs (objfile, mainline, dbfoff, dbfsize, lnoffset, lnsize) struct objfile *objfile; - struct section_offsets *section_offsets; int mainline; file_ptr dbfoff; unsigned int dbfsize; @@ -765,8 +763,8 @@ dwarf_build_psymtabs (objfile, section_offsets, mainline, dbfoff, dbfsize, /* Save the relocation factor where everybody can see it. */ - base_section_offsets = section_offsets; - baseaddr = ANOFFSET (section_offsets, 0); + base_section_offsets = objfile->section_offsets; + baseaddr = ANOFFSET (objfile->section_offsets, 0); /* Follow the compilation unit sibling chain, building a partial symbol table entry for each one. Save enough information about each compilation diff --git a/gdb/elfread.c b/gdb/elfread.c index 69e8e77..e33ed82 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -77,7 +77,7 @@ static void elf_symfile_finish PARAMS ((struct objfile *)); static void -elf_symtab_read PARAMS ((bfd *, CORE_ADDR, struct objfile *, int)); +elf_symtab_read PARAMS ((struct objfile *, int)); static void free_elfinfo PARAMS ((void *)); @@ -221,15 +221,13 @@ record_minimal_symbol_and_info (name, address, ms_type, info, bfd_section, SYNOPSIS - void elf_symtab_read (bfd *abfd, CORE_ADDR addr, - struct objfile *objfile, int dynamic) + void elf_symtab_read (struct objfile *objfile, int dynamic) DESCRIPTION - Given an open bfd, a base address to relocate symbols to, and a - flag that specifies whether or not this bfd is for an executable - or not (may be shared library for example), add all the global - function and data symbols to the minimal symbol table. + Given an objfile and a flag that specifies whether or not the objfile + is for an executable or not (may be shared library for example), add + all the global function and data symbols to the minimal symbol table. In stabs-in-ELF, as implemented by Sun, there are some local symbols defined in the ELF symbol table, which can be used to locate @@ -240,9 +238,7 @@ record_minimal_symbol_and_info (name, address, ms_type, info, bfd_section, */ static void -elf_symtab_read (abfd, addr, objfile, dynamic) - bfd *abfd; - CORE_ADDR addr; +elf_symtab_read (objfile, dynamic) struct objfile *objfile; int dynamic; { @@ -254,6 +250,7 @@ elf_symtab_read (abfd, addr, objfile, dynamic) int index; struct cleanup *back_to; CORE_ADDR symaddr; + CORE_ADDR offset; enum minimal_symbol_type ms_type; /* If sectinfo is nonNULL, it contains section info that should end up filed in the objfile. */ @@ -267,11 +264,11 @@ elf_symtab_read (abfd, addr, objfile, dynamic) #endif struct dbx_symfile_info *dbx = objfile->sym_stab_info; unsigned long size; - int stripped = (bfd_get_symcount (abfd) == 0); + int stripped = (bfd_get_symcount (objfile->obfd) == 0); if (dynamic) { - storage_needed = bfd_get_dynamic_symtab_upper_bound (abfd); + storage_needed = bfd_get_dynamic_symtab_upper_bound (objfile->obfd); /* Nothing to be done if there is no dynamic symtab. */ if (storage_needed < 0) @@ -279,9 +276,9 @@ elf_symtab_read (abfd, addr, objfile, dynamic) } else { - storage_needed = bfd_get_symtab_upper_bound (abfd); + storage_needed = bfd_get_symtab_upper_bound (objfile->obfd); if (storage_needed < 0) - error ("Can't read symbols from %s: %s", bfd_get_filename (abfd), + error ("Can't read symbols from %s: %s", bfd_get_filename (objfile->obfd), bfd_errmsg (bfd_get_error ())); } if (storage_needed > 0) @@ -289,13 +286,15 @@ elf_symtab_read (abfd, addr, objfile, dynamic) symbol_table = (asymbol **) xmalloc (storage_needed); back_to = make_cleanup (free, symbol_table); if (dynamic) - number_of_symbols = bfd_canonicalize_dynamic_symtab (abfd, + number_of_symbols = bfd_canonicalize_dynamic_symtab (objfile->obfd, symbol_table); else - number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); + number_of_symbols = bfd_canonicalize_symtab (objfile->obfd, symbol_table); if (number_of_symbols < 0) - error ("Can't read symbols from %s: %s", bfd_get_filename (abfd), + error ("Can't read symbols from %s: %s", bfd_get_filename (objfile->obfd), bfd_errmsg (bfd_get_error ())); + /* FIXME: Should use section specific offset, not SECT_OFF_TEXT. */ + offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); for (i = 0; i < number_of_symbols; i++) { sym = symbol_table[i]; @@ -316,14 +315,14 @@ elf_symtab_read (abfd, addr, objfile, dynamic) a shared library. If its value is non zero then it is usually the address of the corresponding entry in the procedure linkage table, - relative to the base address. + plus the desired section offset. If its value is zero then the dynamic linker has to resolve the symbol. We are unable to find any meaningful address for this symbol in the executable file, so we skip it. */ symaddr = sym->value; if (symaddr == 0) continue; - symaddr += addr; + symaddr += offset; msym = record_minimal_symbol_and_info ((char *) sym->name, symaddr, mst_solib_trampoline, NULL, sym->section, objfile); @@ -365,10 +364,10 @@ elf_symtab_read (abfd, addr, objfile, dynamic) interested in will have a section. */ /* Bfd symbols are section relative. */ symaddr = sym->value + sym->section->vma; - /* Relocate all non-absolute symbols by base address. */ + /* Relocate all non-absolute symbols by the section offset. */ if (sym->section != &bfd_abs_section) { - symaddr += addr; + symaddr += offset; } /* For non-absolute symbols, use the type of the section they are relative to, to intuit text/data. Bfd provides @@ -397,12 +396,12 @@ elf_symtab_read (abfd, addr, objfile, dynamic) } /* If it is an Irix dynamic symbol, skip section name - symbols, relocate all others. */ + symbols, relocate all others by section offset. */ if (ms_type != mst_abs) { if (sym->name[0] == '.') continue; - symaddr += addr; + symaddr += offset; } } else if (sym->section->flags & SEC_CODE) @@ -498,10 +497,10 @@ elf_symtab_read (abfd, addr, objfile, dynamic) } /* Bfd symbols are section relative. */ symaddr = sym->value + sym->section->vma; - /* Relocate non-absolute symbols by base address. */ + /* Relocate non-absolute symbols by the section offset. */ if (sym->section != &bfd_abs_section) { - symaddr += addr; + symaddr += offset; } sectinfo->sections[index] = symaddr; /* The special local symbols don't go in the @@ -608,13 +607,11 @@ elf_symfile_read (objfile, mainline) chain of info into the dbx_symfile_info in objfile->sym_stab_info, which can later be used by elfstab_offset_sections. */ - /* FIXME, should take a section_offsets param, not just an offset. */ - offset = ANOFFSET (objfile->section_offsets, 0); - elf_symtab_read (abfd, offset, objfile, 0); + elf_symtab_read (objfile, 0); /* Add the dynamic symbols. */ - elf_symtab_read (abfd, offset, objfile, 1); + elf_symtab_read (objfile, 1); /* Now process debugging information, which is contained in special ELF sections. */ @@ -651,8 +648,7 @@ elf_symfile_read (objfile, mainline) information. */ swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap; if (swap) - elfmdebug_build_psymtabs (objfile, swap, ei.mdebugsect, - objfile->section_offsets); + elfmdebug_build_psymtabs (objfile, swap, ei.mdebugsect); } if (ei.stabsect) { @@ -674,13 +670,13 @@ elf_symfile_read (objfile, mainline) if (dwarf2_has_info (abfd)) { /* DWARF 2 sections */ - dwarf2_build_psymtabs (objfile, objfile->section_offsets, mainline); + dwarf2_build_psymtabs (objfile, mainline); } else if (ei.dboffset && ei.lnoffset) { /* DWARF sections */ dwarf_build_psymtabs (objfile, - objfile->section_offsets, mainline, + mainline, ei.dboffset, ei.dbsize, ei.lnoffset, ei.lnsize); } @@ -394,7 +394,6 @@ evaluate_subexp_standard (expect_type, exp, pos, noside) int code; int ix; long mem_offset; - struct symbol *sym; struct type **arg_types; int save_pos1; @@ -842,10 +841,6 @@ evaluate_subexp_standard (expect_type, exp, pos, noside) int static_memfuncp; value_ptr temp = arg2; char tstr[256]; - struct fn_field *fns_ptr; - int num_fns; - struct type *basetype; - int boffset; /* Method invocation : stuff "this" as first parameter */ /* pai: this used to have lookup_pointer_type for some reason, diff --git a/gdb/event-top.c b/gdb/event-top.c index 75b24e9..330f903 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -52,7 +52,9 @@ void handle_sigint PARAMS ((int)); static void handle_sigquit PARAMS ((int)); static void handle_sighup PARAMS ((int)); static void handle_sigfpe PARAMS ((int)); +#if defined(SIGWINCH) && defined(SIGWINCH_HANDLER) static void handle_sigwinch PARAMS ((int)); +#endif /* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT. */ #ifndef STOP_SIGNAL #ifdef SIGTSTP @@ -315,11 +315,7 @@ exec_file_command (args, from_tty) char *args; int from_tty; { - char **argv; - char *filename; - target_preopen (from_tty); - exec_file_attach (args, from_tty); } @@ -618,13 +614,21 @@ exec_files_info (t) struct vmap *vp; printf_unfiltered ("\tMapping info for file `%s'.\n", vmap->name); - printf_unfiltered ("\t %8.8s %8.8s %8.8s %8.8s %8.8s %s\n", - "tstart", "tend", "dstart", "dend", "section", + printf_unfiltered ("\t %*s %*s %*s %*s %8.8s %s\n", + strlen_paddr (), "tstart", + strlen_paddr (), "tend", + strlen_paddr (), "dstart", + strlen_paddr (), "dend", + "section", "file(member)"); for (vp = vmap; vp; vp = vp->nxt) - printf_unfiltered ("\t0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x %s%s%s%s\n", - vp->tstart, vp->tend, vp->dstart, vp->dend, vp->name, + printf_unfiltered ("\t0x%s 0x%s 0x%s 0x%s %s%s%s%s\n", + paddr (vp->tstart), + paddr (vp->tend), + paddr (vp->dstart), + paddr (vp->dend), + vp->name, *vp->member ? "(" : "", vp->member, *vp->member ? ")" : ""); } diff --git a/gdb/expprint.c b/gdb/expprint.c index fadb0b7..fb98994 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -706,7 +706,7 @@ dump_prefix_expression (exp, stream, note) int eltsize; fprintf_filtered (stream, "Dump of expression @ "); - gdb_print_address (exp, stream); + gdb_print_host_address (exp, stream); fprintf_filtered (stream, ", %s:\nExpression: `", note); if (exp->elts[0].opcode != OP_TYPE) print_expression (exp, stream); @@ -831,7 +831,9 @@ dump_subexp (exp, stream, elt) elt = dump_subexp (exp, stream, elt); break; case OP_LONG: - fprintf_filtered (stream, "Type @0x%x (", exp->elts[elt].type); + fprintf_filtered (stream, "Type @"); + gdb_print_host_address (exp->elts[elt].type, stream); + fprintf_filtered (stream, " ("); type_print (exp->elts[elt].type, NULL, stream, 0); fprintf_filtered (stream, "), value %ld (0x%lx)", (long) exp->elts[elt + 1].longconst, @@ -839,16 +841,20 @@ dump_subexp (exp, stream, elt) elt += 3; break; case OP_DOUBLE: - fprintf_filtered (stream, "Type @0x%x (", exp->elts[elt].type); + fprintf_filtered (stream, "Type @"); + gdb_print_host_address (exp->elts[elt].type, stream); + fprintf_filtered (stream, " ("); type_print (exp->elts[elt].type, NULL, stream, 0); fprintf_filtered (stream, "), value %g", (double) exp->elts[elt + 1].doubleconst); elt += 3; break; case OP_VAR_VALUE: - fprintf_filtered (stream, "Block @0x%x, symbol @0x%x (%s)", - exp->elts[elt].block, - exp->elts[elt + 1].symbol, + fprintf_filtered (stream, "Block @"); + gdb_print_host_address (exp->elts[elt].block, stream); + fprintf_filtered (stream, ", symbol @"); + gdb_print_host_address (exp->elts[elt + 1].symbol, stream); + fprintf_filtered (stream, " (%s)", SYMBOL_NAME (exp->elts[elt + 1].symbol)); elt += 3; break; @@ -863,8 +869,9 @@ dump_subexp (exp, stream, elt) elt += 2; break; case OP_INTERNALVAR: - fprintf_filtered (stream, "Internal var @0x%x (%s)", - exp->elts[elt].internalvar, + fprintf_filtered (stream, "Internal var @"); + gdb_print_host_address (exp->elts[elt].internalvar, stream); + fprintf_filtered (stream, " (%s)", exp->elts[elt].internalvar->name); elt += 2; break; @@ -898,15 +905,17 @@ dump_subexp (exp, stream, elt) break; case UNOP_MEMVAL: case UNOP_CAST: - fprintf_filtered (stream, "Type @0x%x (", - exp->elts[elt].type); + fprintf_filtered (stream, "Type @"); + gdb_print_host_address (exp->elts[elt].type, stream); + fprintf_filtered (stream, " ("); type_print (exp->elts[elt].type, NULL, stream, 0); fprintf_filtered (stream, ")"); elt = dump_subexp (exp, stream, elt + 2); break; case OP_TYPE: - fprintf_filtered (stream, "Type @0x%x (", - exp->elts[elt].type); + fprintf_filtered (stream, "Type @"); + gdb_print_host_address (exp->elts[elt].type, stream); + fprintf_filtered (stream, " ("); type_print (exp->elts[elt].type, NULL, stream, 0); fprintf_filtered (stream, ")"); elt += 2; @@ -929,7 +938,9 @@ dump_subexp (exp, stream, elt) char *elem_name; int len; - fprintf_filtered (stream, "Type @0x%x (", exp->elts[elt].type); + fprintf_filtered (stream, "Type @"); + gdb_print_host_address (exp->elts[elt].type, stream); + fprintf_filtered (stream, " ("); type_print (exp->elts[elt].type, NULL, stream, 0); fprintf_filtered (stream, ") "); @@ -972,7 +983,7 @@ dump_postfix_expression (exp, stream, note) int elt; fprintf_filtered (stream, "Dump of expression @ "); - gdb_print_address (exp, stream); + gdb_print_host_address (exp, stream); fprintf_filtered (stream, ", %s:\nExpression: `", note); if (exp->elts[0].opcode != OP_TYPE) print_expression (exp, stream); diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index f3b3114..5d12798 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -431,7 +431,7 @@ f_val_print (type, valaddr, embedded_offset, address, stream, format, deref_ref, } if (addressprint && format != 's') - fprintf_filtered (stream, "0x%x", addr); + fprintf_filtered (stream, "0x%s", paddr_nz (addr)); /* For a pointer to char or unsigned char, also print the string pointed to, unless pointer is null. */ diff --git a/gdb/findvar.c b/gdb/findvar.c index df8475f..3ff8ecc 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -328,6 +328,10 @@ extract_floating (addr, len) else floatformat_to_doublest (TARGET_LONG_DOUBLE_FORMAT, addr, &dretval); } +#ifdef TARGET_EXTRACT_FLOATING + else if (TARGET_EXTRACT_FLOATING (addr, len, &dretval)) + return dretval; +#endif else { error ("Can't deal with a floating point number of %d bytes.", len); @@ -371,6 +375,10 @@ store_floating (addr, len, val) else floatformat_from_doublest (TARGET_LONG_DOUBLE_FORMAT, &val, addr); } +#ifdef TARGET_STORE_FLOATING + else if (TARGET_STORE_FLOATING (addr, len, val)) + return; +#endif else { error ("Can't deal with a floating point number of %d bytes.", len); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index dba4f34..ae44fbd 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1623,11 +1623,11 @@ is_integral_type (t) CHECK_TYPEDEF (t); return ((t != NULL) - && ((TYPE_CODE(t) == TYPE_CODE_INT) - || (TYPE_CODE(t) == TYPE_CODE_ENUM) - || (TYPE_CODE(t) == TYPE_CODE_CHAR) - || (TYPE_CODE(t) == TYPE_CODE_RANGE) - || (TYPE_CODE(t) == TYPE_CODE_BOOL))); + && ((TYPE_CODE (t) == TYPE_CODE_INT) + || (TYPE_CODE (t) == TYPE_CODE_ENUM) + || (TYPE_CODE (t) == TYPE_CODE_CHAR) + || (TYPE_CODE (t) == TYPE_CODE_RANGE) + || (TYPE_CODE (t) == TYPE_CODE_BOOL))); } /* Chill varying string and arrays are represented as follows: @@ -1994,9 +1994,7 @@ int count_virtual_fns (dclass) struct type *dclass; { - int base; /* index for base classes */ int fn, oi; /* function and overloaded instance indices */ - int vfuncs; /* count to return */ /* recurse on bases that can share virtual table */ @@ -2485,7 +2483,7 @@ dump_fn_fieldlists (type, spaces) struct fn_field *f; printfi_filtered (spaces, "fn_fieldlists "); - gdb_print_address (TYPE_FN_FIELDLISTS (type), gdb_stdout); + gdb_print_host_address (TYPE_FN_FIELDLISTS (type), gdb_stdout); printf_filtered ("\n"); for (method_idx = 0; method_idx < TYPE_NFN_FIELDS (type); method_idx++) { @@ -2493,8 +2491,8 @@ dump_fn_fieldlists (type, spaces) printfi_filtered (spaces + 2, "[%d] name '%s' (", method_idx, TYPE_FN_FIELDLIST_NAME (type, method_idx)); - gdb_print_address (TYPE_FN_FIELDLIST_NAME (type, method_idx), - gdb_stdout); + gdb_print_host_address (TYPE_FN_FIELDLIST_NAME (type, method_idx), + gdb_stdout); printf_filtered (") length %d\n", TYPE_FN_FIELDLIST_LENGTH (type, method_idx)); for (overload_idx = 0; @@ -2504,24 +2502,24 @@ dump_fn_fieldlists (type, spaces) printfi_filtered (spaces + 4, "[%d] physname '%s' (", overload_idx, TYPE_FN_FIELD_PHYSNAME (f, overload_idx)); - gdb_print_address (TYPE_FN_FIELD_PHYSNAME (f, overload_idx), - gdb_stdout); + gdb_print_host_address (TYPE_FN_FIELD_PHYSNAME (f, overload_idx), + gdb_stdout); printf_filtered (")\n"); printfi_filtered (spaces + 8, "type "); - gdb_print_address (TYPE_FN_FIELD_TYPE (f, overload_idx), gdb_stdout); + gdb_print_host_address (TYPE_FN_FIELD_TYPE (f, overload_idx), gdb_stdout); printf_filtered ("\n"); recursive_dump_type (TYPE_FN_FIELD_TYPE (f, overload_idx), spaces + 8 + 2); printfi_filtered (spaces + 8, "args "); - gdb_print_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout); + gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout); printf_filtered ("\n"); print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces); printfi_filtered (spaces + 8, "fcontext "); - gdb_print_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx), - gdb_stdout); + gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx), + gdb_stdout); printf_filtered ("\n"); printfi_filtered (spaces + 8, "is_const %d\n", @@ -2555,7 +2553,7 @@ print_cplus_stuff (type, spaces) { printfi_filtered (spaces, "virtual_field_bits (%d bits at *", TYPE_N_BASECLASSES (type)); - gdb_print_address (TYPE_FIELD_VIRTUAL_BITS (type), gdb_stdout); + gdb_print_host_address (TYPE_FIELD_VIRTUAL_BITS (type), gdb_stdout); printf_filtered (")"); print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type), @@ -2568,7 +2566,7 @@ print_cplus_stuff (type, spaces) { printfi_filtered (spaces, "private_field_bits (%d bits at *", TYPE_NFIELDS (type)); - gdb_print_address (TYPE_FIELD_PRIVATE_BITS (type), gdb_stdout); + gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type), gdb_stdout); printf_filtered (")"); print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type), TYPE_NFIELDS (type)); @@ -2578,7 +2576,7 @@ print_cplus_stuff (type, spaces) { printfi_filtered (spaces, "protected_field_bits (%d bits at *", TYPE_NFIELDS (type)); - gdb_print_address (TYPE_FIELD_PROTECTED_BITS (type), gdb_stdout); + gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type), gdb_stdout); printf_filtered (")"); print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type), TYPE_NFIELDS (type)); @@ -2617,7 +2615,7 @@ recursive_dump_type (type, spaces) if (type == first_dont_print[i]) { printfi_filtered (spaces, "type node "); - gdb_print_address (type, gdb_stdout); + gdb_print_host_address (type, gdb_stdout); printf_filtered (" <same as already seen type>\n"); return; } @@ -2627,17 +2625,17 @@ recursive_dump_type (type, spaces) } printfi_filtered (spaces, "type node "); - gdb_print_address (type, gdb_stdout); + gdb_print_host_address (type, gdb_stdout); printf_filtered ("\n"); printfi_filtered (spaces, "name '%s' (", TYPE_NAME (type) ? TYPE_NAME (type) : "<NULL>"); - gdb_print_address (TYPE_NAME (type), gdb_stdout); + gdb_print_host_address (TYPE_NAME (type), gdb_stdout); printf_filtered (")\n"); if (TYPE_TAG_NAME (type) != NULL) { printfi_filtered (spaces, "tagname '%s' (", TYPE_TAG_NAME (type)); - gdb_print_address (TYPE_TAG_NAME (type), gdb_stdout); + gdb_print_host_address (TYPE_TAG_NAME (type), gdb_stdout); printf_filtered (")\n"); } printfi_filtered (spaces, "code 0x%x ", TYPE_CODE (type)); @@ -2710,20 +2708,20 @@ recursive_dump_type (type, spaces) puts_filtered ("\n"); printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type)); printfi_filtered (spaces, "objfile "); - gdb_print_address (TYPE_OBJFILE (type), gdb_stdout); + gdb_print_host_address (TYPE_OBJFILE (type), gdb_stdout); printf_filtered ("\n"); printfi_filtered (spaces, "target_type "); - gdb_print_address (TYPE_TARGET_TYPE (type), gdb_stdout); + gdb_print_host_address (TYPE_TARGET_TYPE (type), gdb_stdout); printf_filtered ("\n"); if (TYPE_TARGET_TYPE (type) != NULL) { recursive_dump_type (TYPE_TARGET_TYPE (type), spaces + 2); } printfi_filtered (spaces, "pointer_type "); - gdb_print_address (TYPE_POINTER_TYPE (type), gdb_stdout); + gdb_print_host_address (TYPE_POINTER_TYPE (type), gdb_stdout); printf_filtered ("\n"); printfi_filtered (spaces, "reference_type "); - gdb_print_address (TYPE_REFERENCE_TYPE (type), gdb_stdout); + gdb_print_host_address (TYPE_REFERENCE_TYPE (type), gdb_stdout); printf_filtered ("\n"); printfi_filtered (spaces, "flags 0x%x", TYPE_FLAGS (type)); if (TYPE_FLAGS (type) & TYPE_FLAG_UNSIGNED) @@ -2736,7 +2734,7 @@ recursive_dump_type (type, spaces) } puts_filtered ("\n"); printfi_filtered (spaces, "nfields %d ", TYPE_NFIELDS (type)); - gdb_print_address (TYPE_FIELDS (type), gdb_stdout); + gdb_print_host_address (TYPE_FIELDS (type), gdb_stdout); puts_filtered ("\n"); for (idx = 0; idx < TYPE_NFIELDS (type); idx++) { @@ -2744,12 +2742,12 @@ recursive_dump_type (type, spaces) "[%d] bitpos %d bitsize %d type ", idx, TYPE_FIELD_BITPOS (type, idx), TYPE_FIELD_BITSIZE (type, idx)); - gdb_print_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout); + gdb_print_host_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout); printf_filtered (" name '%s' (", TYPE_FIELD_NAME (type, idx) != NULL ? TYPE_FIELD_NAME (type, idx) : "<NULL>"); - gdb_print_address (TYPE_FIELD_NAME (type, idx), gdb_stdout); + gdb_print_host_address (TYPE_FIELD_NAME (type, idx), gdb_stdout); printf_filtered (")\n"); if (TYPE_FIELD_TYPE (type, idx) != NULL) { @@ -2757,7 +2755,7 @@ recursive_dump_type (type, spaces) } } printfi_filtered (spaces, "vptr_basetype "); - gdb_print_address (TYPE_VPTR_BASETYPE (type), gdb_stdout); + gdb_print_host_address (TYPE_VPTR_BASETYPE (type), gdb_stdout); puts_filtered ("\n"); if (TYPE_VPTR_BASETYPE (type) != NULL) { @@ -2769,14 +2767,14 @@ recursive_dump_type (type, spaces) case TYPE_CODE_METHOD: case TYPE_CODE_FUNC: printfi_filtered (spaces, "arg_types "); - gdb_print_address (TYPE_ARG_TYPES (type), gdb_stdout); + gdb_print_host_address (TYPE_ARG_TYPES (type), gdb_stdout); puts_filtered ("\n"); print_arg_types (TYPE_ARG_TYPES (type), spaces); break; case TYPE_CODE_STRUCT: printfi_filtered (spaces, "cplus_stuff "); - gdb_print_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout); + gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout); puts_filtered ("\n"); print_cplus_stuff (type, spaces); break; @@ -2786,7 +2784,7 @@ recursive_dump_type (type, spaces) the value. Pick cplus_struct_type, even though we know it isn't any particular one. */ printfi_filtered (spaces, "type_specific "); - gdb_print_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout); + gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout); if (TYPE_CPLUS_SPECIFIC (type) != NULL) { printf_filtered (" (unknown data form)"); diff --git a/gdb/hp-psymtab-read.c b/gdb/hp-psymtab-read.c index 5f243c3..7d53305 100644 --- a/gdb/hp-psymtab-read.c +++ b/gdb/hp-psymtab-read.c @@ -45,7 +45,7 @@ void do_pxdb PARAMS ((bfd *)); void hpread_build_psymtabs - PARAMS ((struct objfile *, struct section_offsets *, int)); + PARAMS ((struct objfile *, int)); void hpread_symfile_finish PARAMS ((struct objfile *)); @@ -57,7 +57,7 @@ static unsigned long hpread_get_textlow PARAMS ((int, int, struct objfile *, int)); static struct partial_symtab *hpread_start_psymtab - PARAMS ((struct objfile *, struct section_offsets *, char *, CORE_ADDR, int, + PARAMS ((struct objfile *, char *, CORE_ADDR, int, struct partial_symbol **, struct partial_symbol **)); static struct partial_symtab *hpread_end_psymtab @@ -516,7 +516,7 @@ find_next_module_isym (index, qMD, curr_md, pxdb_header_p) organized in a separate routine, although it does take lots of arguments. pai/1997-10-08 */ static int -scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile, section_offsets) +scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile) int *curr_pd_p; /* pointer to current proc index */ quick_procedure_entry *qPD; /* the procedure quick lookup table */ int max_procs; /* number of entries in proc. table */ @@ -525,7 +525,6 @@ scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile struct partial_symtab *pst; /* current psymtab */ char *vt_bits; /* strings table of SOM debug space */ struct objfile *objfile; /* current object file */ - struct section_offsets *section_offsets; /* not really used for HP-UX currently */ { union dnttentry *dn_bufp; int symbol_count = 0; /* Total number of symbols in this psymtab */ @@ -602,7 +601,7 @@ scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile LOC_BLOCK, /* "I am a routine" */ &objfile->global_psymbols, (qPD[curr_pd].adrStart + /* Starting address of rtn */ - ANOFFSET (section_offsets, SECT_OFF_TEXT)), + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT)), 0, /* core addr?? */ trans_lang ((enum hp_language) qPD[curr_pd].language), objfile); @@ -615,7 +614,7 @@ scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile LOC_BLOCK, /* "I am a routine" */ &objfile->static_psymbols, (qPD[curr_pd].adrStart + /* Starting address of rtn */ - ANOFFSET (section_offsets, SECT_OFF_TEXT)), + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT)), 0, /* core addr?? */ trans_lang ((enum hp_language) qPD[curr_pd].language), objfile); @@ -647,9 +646,8 @@ scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile entry for it, so in such cases we create a psymtab for the file. */ int -hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header_p) +hpread_quick_traverse (objfile, gntt_bits, vt_bits, pxdb_header_p) struct objfile *objfile; /* The object file descriptor */ - struct section_offsets *section_offsets; /* ?? Null for HP */ char *gntt_bits; /* GNTT entries, loaded in from the file */ char *vt_bits; /* VT (string) entries ditto. */ PXDB_header_ptr pxdb_header_p; /* Pointer to pxdb header ditto */ @@ -862,7 +860,6 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header might help. */ pst = hpread_start_psymtab (objfile, - section_offsets, /* ?? */ mod_name_string, CURR_MODULE_START, /* Low text address: bogus! */ (CURR_MODULE_ISYM * sizeof (struct dntt_type_block)), @@ -964,7 +961,6 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header And it's not even the right byte offset, as we're using the size of a union! FIXME! */ pst = hpread_start_psymtab (objfile, - section_offsets, /* ?? */ full_name_string, start_adr, /* Low text address */ (start_sym * sizeof (struct dntt_type_block)), @@ -980,8 +976,7 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header file, based on the starting addresses. */ syms_in_pst = scan_procs (&curr_pd, qPD, pxdb_header_p->pd_entries, - start_adr, end_adr, - pst, vt_bits, objfile, section_offsets); + start_adr, end_adr, pst, vt_bits, objfile); /* Get ending symbol offset */ @@ -1194,7 +1189,6 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header And it's not even the right byte offset, as we're using the size of a union! FIXME! */ pst = hpread_start_psymtab (objfile, - section_offsets, /* ?? */ full_name_string, start_adr, /* Low text address */ (start_sym * sizeof (struct dntt_type_block)), @@ -1210,8 +1204,7 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header module, based on the starting addresses. */ syms_in_pst = scan_procs (&curr_pd, qPD, pxdb_header_p->pd_entries, - start_adr, end_adr, - pst, vt_bits, objfile, section_offsets); + start_adr, end_adr, pst, vt_bits, objfile); /* Get ending symbol offset */ @@ -1308,7 +1301,6 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header } #endif pst = hpread_start_psymtab (objfile, - section_offsets, /* ?? */ "orphans", start_adr, /* Low text address */ (CURR_PROC_ISYM * sizeof (struct dntt_type_block)), @@ -1317,8 +1309,7 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header static_syms); scan_procs (&curr_pd, qPD, pxdb_header_p->pd_entries, - start_adr, end_adr, - pst, vt_bits, objfile, section_offsets); + start_adr, end_adr, pst, vt_bits, objfile); pst = hpread_end_psymtab (pst, NULL, /* psymtab_include_list */ @@ -1340,7 +1331,6 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header If null psts were kept on the chain, this would be a solution. FIXME */ pst = hpread_start_psymtab (objfile, - section_offsets, "globals", 0, (pxdb_header_p->globals @@ -1578,14 +1568,12 @@ hpread_symfile_init (objfile) We assume hpread_symfile_init has been called to initialize the symbol reader's private data structures. - SECTION_OFFSETS contains offsets relative to which the symbols in the - various sections are (depending where the sections were actually loaded). MAINLINE is true if we are reading the main symbol table (as opposed to a shared lib or dynamically loaded file). */ + void -hpread_build_psymtabs (objfile, section_offsets, mainline) +hpread_build_psymtabs (objfile, mainline) struct objfile *objfile; - struct section_offsets *section_offsets; int mainline; { @@ -1679,7 +1667,6 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) not found we give up on the quick table stuff, and fall back on the slower method */ found_modules_in_program = hpread_quick_traverse (objfile, - section_offsets, GNTT (objfile), VT (objfile), &pxdb_header); @@ -1829,8 +1816,8 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) past_first_source_file = 1; valu = hpread_get_textlow (i, hp_symnum, objfile, symcount); - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); - pst = hpread_start_psymtab (objfile, section_offsets, + valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + pst = hpread_start_psymtab (objfile, namestring, valu, (hp_symnum * sizeof (struct dntt_type_block)), @@ -1863,10 +1850,10 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) /* Now begin a new module and a new psymtab for it */ SET_NAMESTRING (dn_bufp, &namestring, objfile); valu = hpread_get_textlow (i, hp_symnum, objfile, symcount); - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); if (!pst) { - pst = hpread_start_psymtab (objfile, section_offsets, + pst = hpread_start_psymtab (objfile, namestring, valu, (hp_symnum * sizeof (struct dntt_type_block)), @@ -1881,12 +1868,12 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) case DNTT_TYPE_ENTRY: /* The beginning of a function. DNTT_TYPE_ENTRY may also denote a secondary entry point. */ - valu = dn_bufp->dfunc.hiaddr + ANOFFSET (section_offsets, + valu = dn_bufp->dfunc.hiaddr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); if (valu > texthigh) texthigh = valu; valu = dn_bufp->dfunc.lowaddr + - ANOFFSET (section_offsets, SECT_OFF_TEXT); + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); SET_NAMESTRING (dn_bufp, &namestring, objfile); if (dn_bufp->dfunc.global) add_psymbol_to_list (namestring, strlen (namestring), @@ -1902,12 +1889,12 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) continue; case DNTT_TYPE_DOC_FUNCTION: - valu = dn_bufp->ddocfunc.hiaddr + ANOFFSET (section_offsets, + valu = dn_bufp->ddocfunc.hiaddr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); if (valu > texthigh) texthigh = valu; valu = dn_bufp->ddocfunc.lowaddr + - ANOFFSET (section_offsets, SECT_OFF_TEXT); + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); SET_NAMESTRING (dn_bufp, &namestring, objfile); if (dn_bufp->ddocfunc.global) add_psymbol_to_list (namestring, strlen (namestring), @@ -1985,7 +1972,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) SET_NAMESTRING (dn_bufp, &namestring, objfile); if (!pst) { - pst = hpread_start_psymtab (objfile, section_offsets, + pst = hpread_start_psymtab (objfile, "globals", 0, (hp_symnum * sizeof (struct dntt_type_block)), @@ -1997,7 +1984,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) valu = dn_bufp->dsvar.location; /* Relocate in case it's in a shared library */ if (storage == LOC_STATIC) - valu += ANOFFSET (section_offsets, SECT_OFF_DATA); + valu += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA); /* Luckily, dvar, svar, typedef, and tagdef all have their "global" bit in the same place, so it works @@ -2069,7 +2056,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) SET_NAMESTRING (dn_bufp, &namestring, objfile); if (!pst) { - pst = hpread_start_psymtab (objfile, section_offsets, + pst = hpread_start_psymtab (objfile, "globals", 0, (hp_symnum * sizeof (struct dntt_type_block)), @@ -2212,20 +2199,19 @@ hpread_get_textlow (global, index, objfile, symcount) (normal). */ static struct partial_symtab * -hpread_start_psymtab (objfile, section_offsets, +hpread_start_psymtab (objfile, filename, textlow, ldsymoff, global_syms, static_syms) struct objfile *objfile; - struct section_offsets *section_offsets; char *filename; CORE_ADDR textlow; int ldsymoff; struct partial_symbol **global_syms; struct partial_symbol **static_syms; { - int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT); + int offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); extern void hpread_psymtab_to_symtab (); struct partial_symtab *result = - start_psymtab_common (objfile, section_offsets, + start_psymtab_common (objfile, objfile->section_offsets, filename, textlow, global_syms, static_syms); result->textlow += offset; diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 2fdff8a..5751b45 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -419,9 +419,9 @@ static void read_unwind_info (objfile) struct objfile *objfile; { - asection *unwind_sec, *elf_unwind_sec, *stub_unwind_sec; - unsigned unwind_size, elf_unwind_size, stub_unwind_size, total_size; - unsigned index, unwind_entries, elf_unwind_entries; + asection *unwind_sec, *stub_unwind_sec; + unsigned unwind_size, stub_unwind_size, total_size; + unsigned index, unwind_entries; unsigned stub_entries, total_entries; CORE_ADDR text_offset; struct obj_unwind_info *ui; @@ -435,35 +435,32 @@ read_unwind_info (objfile) ui->cache = NULL; ui->last = -1; - /* Get hooks to all unwind sections. Note there is no linker-stub unwind - section in ELF at the moment. */ - unwind_sec = bfd_get_section_by_name (objfile->obfd, "$UNWIND_START$"); - elf_unwind_sec = bfd_get_section_by_name (objfile->obfd, ".PARISC.unwind"); - stub_unwind_sec = bfd_get_section_by_name (objfile->obfd, "$UNWIND_END$"); - - /* Get sizes and unwind counts for all sections. */ - if (unwind_sec) + /* For reasons unknown the HP PA64 tools generate multiple unwinder + sections in a single executable. So we just iterate over every + section in the BFD looking for unwinder sections intead of trying + to do a lookup with bfd_get_section_by_name. + + First determine the total size of the unwind tables so that we + can allocate memory in a nice big hunk. */ + total_entries = 0; + for (unwind_sec = objfile->obfd->sections; + unwind_sec; + unwind_sec = unwind_sec->next) { - unwind_size = bfd_section_size (objfile->obfd, unwind_sec); - unwind_entries = unwind_size / UNWIND_ENTRY_SIZE; - } - else - { - unwind_size = 0; - unwind_entries = 0; - } + if (strcmp (unwind_sec->name, "$UNWIND_START$") == 0 + || strcmp (unwind_sec->name, ".PARISC.unwind") == 0) + { + unwind_size = bfd_section_size (objfile->obfd, unwind_sec); + unwind_entries = unwind_size / UNWIND_ENTRY_SIZE; - if (elf_unwind_sec) - { - elf_unwind_size = bfd_section_size (objfile->obfd, elf_unwind_sec); - elf_unwind_entries = elf_unwind_size / UNWIND_ENTRY_SIZE; - } - else - { - elf_unwind_size = 0; - elf_unwind_entries = 0; + total_entries += unwind_entries; + } } + /* Now compute the size of the stub unwinds. Note the ELF tools do not + use stub unwinds at the curren time. */ + stub_unwind_sec = bfd_get_section_by_name (objfile->obfd, "$UNWIND_END$"); + if (stub_unwind_sec) { stub_unwind_size = bfd_section_size (objfile->obfd, stub_unwind_sec); @@ -476,7 +473,7 @@ read_unwind_info (objfile) } /* Compute total number of unwind entries and their total size. */ - total_entries = unwind_entries + elf_unwind_entries + stub_entries; + total_entries += stub_entries; total_size = total_entries * sizeof (struct unwind_table_entry); /* Allocate memory for the unwind table. */ @@ -484,16 +481,26 @@ read_unwind_info (objfile) obstack_alloc (&objfile->psymbol_obstack, total_size); ui->last = total_entries - 1; - /* Internalize the standard unwind entries. */ + /* Now read in each unwind section and internalize the standard unwind + entries. */ index = 0; - internalize_unwinds (objfile, &ui->table[index], unwind_sec, - unwind_entries, unwind_size, text_offset); - index += unwind_entries; - internalize_unwinds (objfile, &ui->table[index], elf_unwind_sec, - elf_unwind_entries, elf_unwind_size, text_offset); - index += elf_unwind_entries; - - /* Now internalize the stub unwind entries. */ + for (unwind_sec = objfile->obfd->sections; + unwind_sec; + unwind_sec = unwind_sec->next) + { + if (strcmp (unwind_sec->name, "$UNWIND_START$") == 0 + || strcmp (unwind_sec->name, ".PARISC.unwind") == 0) + { + unwind_size = bfd_section_size (objfile->obfd, unwind_sec); + unwind_entries = unwind_size / UNWIND_ENTRY_SIZE; + + internalize_unwinds (objfile, &ui->table[index], unwind_sec, + unwind_entries, unwind_size, text_offset); + index += unwind_entries; + } + } + + /* Now read in and internalize the stub unwind entries. */ if (stub_unwind_size > 0) { unsigned int i; @@ -3272,7 +3279,7 @@ prologue_inst_adjust_sp (inst) /* std,ma X,D(sp) */ if ((inst & 0xffe00008) == 0x73c00008) - return (inst & 0x1 ? -1 << 16 : 0) | (((inst >> 4) & 0x3ff) << 3); + return (inst & 0x1 ? -1 << 13 : 0) | (((inst >> 4) & 0x3ff) << 3); /* addil high21,%r1; ldo low11,(%r1),%r30) save high bits in save_high21 for later use. */ @@ -3703,6 +3710,7 @@ hppa_frame_find_saved_regs (frame_info, frame_saved_regs) int status, i, reg; char buf[4]; int fp_loc = -1; + int final_iteration; /* Zero out everything. */ memset (frame_saved_regs, '\0', sizeof (struct frame_saved_regs)); @@ -3805,7 +3813,9 @@ hppa_frame_find_saved_regs (frame_info, frame_saved_regs) Some unexpected things are expected with debugging optimized code, so we allow this routine to walk past user instructions in optimized GCC code. */ - while (save_gr || save_fr || save_rp || save_sp || stack_remaining > 0) + final_iteration = 0; + while ((save_gr || save_fr || save_rp || save_sp || stack_remaining > 0) + && pc <= frame_info->pc) { status = target_read_memory (pc, buf, 4); inst = extract_unsigned_integer (buf, 4); @@ -3853,7 +3863,7 @@ hppa_frame_find_saved_regs (frame_info, frame_saved_regs) CORE_ADDR offset; if ((inst >> 26) == 0x1c) - offset = (inst & 0x1 ? -1 << 16 : 0) | (((inst >> 4) & 0x3ff) << 3); + offset = (inst & 0x1 ? -1 << 13 : 0) | (((inst >> 4) & 0x3ff) << 3); else if ((inst >> 26) == 0x03) offset = low_sign_extend (inst & 0x1f, 5); else @@ -3908,11 +3918,15 @@ hppa_frame_find_saved_regs (frame_info, frame_saved_regs) } } - /* Quit if we hit any kind of branch. This can happen if a prologue - instruction is in the delay slot of the first call/branch. */ - if (is_branch (inst)) + /* Quit if we hit any kind of branch the previous iteration. + if (final_iteration) break; + /* We want to look precisely one instruction beyond the branch + if we have not found everything yet. */ + if (is_branch (inst)) + final_iteration = 1; + /* Bump the PC. */ pc += 4; } diff --git a/gdb/hpread.c b/gdb/hpread.c index d14474e..4da08e4 100644 --- a/gdb/hpread.c +++ b/gdb/hpread.c @@ -159,12 +159,12 @@ static struct type *hpread_read_struct_type PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); void hpread_build_psymtabs - PARAMS ((struct objfile *, struct section_offsets *, int)); + PARAMS ((struct objfile *, int)); void hpread_symfile_finish PARAMS ((struct objfile *)); static struct partial_symtab *hpread_start_psymtab - PARAMS ((struct objfile *, struct section_offsets *, char *, CORE_ADDR, int, + PARAMS ((struct objfile *, char *, CORE_ADDR, int, struct partial_symbol **, struct partial_symbol **)); static struct partial_symtab *hpread_end_psymtab @@ -305,15 +305,12 @@ hpread_symfile_init (objfile) We assume hpread_symfile_init has been called to initialize the symbol reader's private data structures. - SECTION_OFFSETS contains offsets relative to which the symbols in the - various sections are (depending where the sections were actually loaded). MAINLINE is true if we are reading the main symbol table (as opposed to a shared lib or dynamically loaded file). */ void -hpread_build_psymtabs (objfile, section_offsets, mainline) +hpread_build_psymtabs (objfile, mainline) struct objfile *objfile; - struct section_offsets *section_offsets; int mainline; { char *namestring; @@ -469,8 +466,8 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) past_first_source_file = 1; valu = hpread_get_textlow (i, hp_symnum, objfile); - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); - pst = hpread_start_psymtab (objfile, section_offsets, + valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + pst = hpread_start_psymtab (objfile, namestring, valu, (hp_symnum * sizeof (struct dntt_type_block)), @@ -487,10 +484,10 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) is supposed to be. */ SET_NAMESTRING (dn_bufp, &namestring, objfile); valu = hpread_get_textlow (i, hp_symnum, objfile); - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); if (!pst) { - pst = hpread_start_psymtab (objfile, section_offsets, + pst = hpread_start_psymtab (objfile, namestring, valu, (hp_symnum * sizeof (struct dntt_type_block)), @@ -504,12 +501,12 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) case DNTT_TYPE_ENTRY: /* The beginning of a function. DNTT_TYPE_ENTRY may also denote a secondary entry point. */ - valu = dn_bufp->dfunc.hiaddr + ANOFFSET (section_offsets, + valu = dn_bufp->dfunc.hiaddr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); if (valu > texthigh) texthigh = valu; valu = dn_bufp->dfunc.lowaddr + - ANOFFSET (section_offsets, SECT_OFF_TEXT); + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); SET_NAMESTRING (dn_bufp, &namestring, objfile); add_psymbol_to_list (namestring, strlen (namestring), VAR_NAMESPACE, LOC_BLOCK, @@ -571,7 +568,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) SET_NAMESTRING (dn_bufp, &namestring, objfile); if (!pst) { - pst = hpread_start_psymtab (objfile, section_offsets, + pst = hpread_start_psymtab (objfile, "globals", 0, (hp_symnum * sizeof (struct dntt_type_block)), @@ -602,7 +599,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) SET_NAMESTRING (dn_bufp, &namestring, objfile); if (!pst) { - pst = hpread_start_psymtab (objfile, section_offsets, + pst = hpread_start_psymtab (objfile, "globals", 0, (hp_symnum * sizeof (struct dntt_type_block)), @@ -826,10 +823,9 @@ hpread_has_name (kind) (normal). */ static struct partial_symtab * -hpread_start_psymtab (objfile, section_offsets, - filename, textlow, ldsymoff, global_syms, static_syms) +hpread_start_psymtab (objfile, filename, textlow, ldsymoff, global_syms, + static_syms) struct objfile *objfile; - struct section_offsets *section_offsets; char *filename; CORE_ADDR textlow; int ldsymoff; diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c new file mode 100644 index 0000000..8c63a94 --- /dev/null +++ b/gdb/i386-linux-nat.c @@ -0,0 +1,379 @@ +/* Native-dependent code for Linux running on i386's, for GDB. + +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "defs.h" +#include "inferior.h" +#include "gdbcore.h" + +/* For i386_linux_skip_solib_resolver */ +#include "symtab.h" +#include "frame.h" +#include "symfile.h" +#include "objfiles.h" + +#include <sys/ptrace.h> +#include <sys/user.h> +#include <sys/procfs.h> + +#ifdef HAVE_SYS_REG_H +#include <sys/reg.h> +#endif + +/* This is a duplicate of the table in i386-xdep.c. */ + +static int regmap[] = +{ + EAX, ECX, EDX, EBX, + UESP, EBP, ESI, EDI, + EIP, EFL, CS, SS, + DS, ES, FS, GS, +}; + + +/* FIXME: These routine absolutely depends upon (NUM_REGS - NUM_FREGS) + being less than or equal to the number of registers that can be stored + in a gregset_t. Note that with the current scheme there will typically + be more registers actually stored in a gregset_t that what we know + about. This is bogus and should be fixed. */ + +/* Given a pointer to a general register set in /proc format (gregset_t *), + unpack the register contents and supply them as gdb's idea of the current + register values. */ + +void +supply_gregset (gregsetp) + gregset_t *gregsetp; +{ + register int regi; + register greg_t *regp = (greg_t *) gregsetp; + + for (regi = 0 ; regi < (NUM_REGS - NUM_FREGS) ; regi++) + { + supply_register (regi, (char *) (regp + regmap[regi])); + } +} + +void +fill_gregset (gregsetp, regno) + gregset_t *gregsetp; + int regno; +{ + int regi; + register greg_t *regp = (greg_t *) gregsetp; + + for (regi = 0 ; regi < (NUM_REGS - NUM_FREGS) ; regi++) + { + if ((regno == -1) || (regno == regi)) + { + *(regp + regmap[regi]) = *(int *) ®isters[REGISTER_BYTE (regi)]; + } + } +} + + +/* Given a pointer to a floating point register set in (fpregset_t *) + format, unpack the register contents and supply them as gdb's + idea of the current floating point register values. */ + +void +supply_fpregset (fpregsetp) + fpregset_t *fpregsetp; +{ + register int regi; + char *from; + from = (char *) &(fpregsetp->st_space[0]); + for (regi = FPSTART_REGNUM ; regi <= FPEND_REGNUM ; regi++) + { + supply_register(regi, from); + from += REGISTER_RAW_SIZE(regi); + } +} + +/* Given a pointer to a floating point register set in (fpregset_t *) + format, update all of the registers from gdb's idea + of the current floating point register set. */ + +void +fill_fpregset (fpregsetp, regno) + fpregset_t *fpregsetp; + int regno; +{ + int regi; + char *to; + char *from; + + to = (char *) &(fpregsetp->st_space[0]); + for (regi = FPSTART_REGNUM ; regi <= FPEND_REGNUM ; regi++) + { + from = (char *) ®isters[REGISTER_BYTE (regi)]; + memcpy (to, from, REGISTER_RAW_SIZE (regi)); + to += REGISTER_RAW_SIZE(regi); + } +} + +/* + Get the whole floating point state of the process and + store the floating point stack into registers[]. + */ +static void +fetch_fpregs(void) +{ + int ret, regno; + char buf[FPREG_BYTES]; + + ret = ptrace (PTRACE_GETFPREGS, inferior_pid, 0, (int)buf); + if ( ret < 0 ) + { + warning ("Couldn't get floating point status"); + return; + } + + for ( regno = 0; regno < NUM_FREGS; regno++ ) + { + if ( regno < 7 ) + supply_register (NUM_REGS-NUM_FREGS+regno, buf + regno*4); + else + supply_register (NUM_REGS-NUM_FREGS+regno, + buf + FPENV_BYTES + (regno-7)*FPREG_RAW_SIZE); + } + +} + + +/* + Get the whole floating point state of the process and + replace the contents from registers[]. + */ +static void +store_fpregs(void) +{ + int ret, regno; + char buf[FPREG_BYTES]; + + ret = ptrace (PTRACE_GETFPREGS, inferior_pid, 0, (int)buf); + if ( ret < 0 ) + { + warning ("Couldn't get floating point status"); + return; + } + + for ( regno = 0; regno < NUM_FREGS; regno++ ) + { + if ( register_valid[regno] ) + { + if ( regno < 7 ) + { + read_register_gen (NUM_REGS-NUM_FREGS+regno, + buf + regno*4); + } + else + { + read_register_gen (NUM_REGS-NUM_FREGS+regno, + buf + FPENV_BYTES + (regno-7)*FPREG_RAW_SIZE); + } + } + } + + ret = ptrace (PTRACE_SETFPREGS, inferior_pid, 0, (int)buf); + if ( ret < 0 ) + { + warning ("Couldn't write floating point status"); + return; + } + +} + + +/* + Get state of all non-fp registers of the process and + store into registers[]. + */ +static void +fetch_regs(void) +{ + int ret, regno; + char buf[17*sizeof(unsigned int)]; + + ret = ptrace (PTRACE_GETREGS, inferior_pid, 0, (int)buf); + if ( ret < 0 ) + { + warning ("Couldn't get registers"); + return; + } + + for ( regno = 0; regno < NUM_REGS-NUM_FREGS; regno++ ) + supply_register (regno, buf + register_addr (regno, U_REGS_OFFSET)); + +} + + +/* + Get the whole non-floating-point register state of the process and + replace them in the process from registers[]. + */ +static void +store_regs(void) +{ + int ret, regno; + char buf[17*sizeof(unsigned int)]; + + ret = ptrace (PTRACE_GETREGS, inferior_pid, 0, (int)buf); + if ( ret < 0 ) + { + warning ("Couldn't get registers"); + return; + } + + for ( regno = 0; regno < NUM_REGS-NUM_FREGS; regno++ ) + { + if ( register_valid[regno] ) + read_register_gen (regno, buf + register_addr (regno, U_REGS_OFFSET)); + } + + ret = ptrace (PTRACE_SETREGS, inferior_pid, 0, (int)buf); + + if ( ret < 0 ) + { + warning ("Couldn't write floating point status"); + return; + } + +} + + +/* Fetch registers from the child process. + Fetch all if regno == -1, otherwise fetch all ordinary + registers or all floating point registers depending + upon the value of regno. */ + +void +fetch_inferior_registers (regno) + int regno; +{ + if ( (regno < NUM_REGS - NUM_FREGS) || (regno == -1) ) + fetch_regs(); + + if ( (regno >= NUM_REGS - NUM_FREGS) || (regno == -1) ) + fetch_fpregs(); +} + + +/* Store our register values back into the inferior. + If REGNO is -1, do this for all registers. + Otherwise, REGNO specifies which register, which + then determines whether we store all ordinary + registers or all of the floating point registers. */ + +void +store_inferior_registers (regno) + int regno; +{ + if ( (regno < NUM_REGS - NUM_FREGS) || (regno == -1) ) + store_regs(); + + if ( (regno >= NUM_REGS - NUM_FREGS) || (regno == -1) ) + store_fpregs(); +} + + +/* Find the minimal symbol named NAME, and return both the minsym + struct and its objfile. This probably ought to be in minsym.c, but + everything there is trying to deal with things like C++ and + SOFUN_ADDRESS_MAYBE_TURQUOISE, ... Since this is so simple, it may + be considered too special-purpose for general consumption. */ + +static struct minimal_symbol * +find_minsym_and_objfile (char *name, struct objfile **objfile_p) +{ + struct objfile *objfile; + + ALL_OBJFILES (objfile) + { + struct minimal_symbol *msym; + + ALL_OBJFILE_MSYMBOLS (objfile, msym) + { + if (SYMBOL_NAME (msym) + && STREQ (SYMBOL_NAME (msym), name)) + { + *objfile_p = objfile; + return msym; + } + } + } + + return 0; +} + + +static CORE_ADDR +skip_hurd_resolver (CORE_ADDR pc) +{ + /* The HURD dynamic linker is part of the GNU C library, so many + GNU/Linux distributions use it. (All ELF versions, as far as I + know.) An unresolved PLT entry points to "_dl_runtime_resolve", + which calls "fixup" to patch the PLT, and then passes control to + the function. + + We look for the symbol `_dl_runtime_resolve', and find `fixup' in + the same objfile. If we are at the entry point of `fixup', then + we set a breakpoint at the return address (at the top of the + stack), and continue. + + It's kind of gross to do all these checks every time we're + called, since they don't change once the executable has gotten + started. But this is only a temporary hack --- upcoming versions + of Linux will provide a portable, efficient interface for + debugging programs that use shared libraries. */ + + struct objfile *objfile; + struct minimal_symbol *resolver + = find_minsym_and_objfile ("_dl_runtime_resolve", &objfile); + + if (resolver) + { + struct minimal_symbol *fixup + = lookup_minimal_symbol ("fixup", 0, objfile); + + if (fixup && SYMBOL_VALUE_ADDRESS (fixup) == pc) + return (SAVED_PC_AFTER_CALL (get_current_frame ())); + } + + return 0; +} + + +/* See the comments for SKIP_SOLIB_RESOLVER at the top of infrun.c. + This function: + 1) decides whether a PLT has sent us into the linker to resolve + a function reference, and + 2) if so, tells us where to set a temporary breakpoint that will + trigger when the dynamic linker is done. */ + +CORE_ADDR +i386_linux_skip_solib_resolver (CORE_ADDR pc) +{ + CORE_ADDR result; + + /* Plug in functions for other kinds of resolvers here. */ + result = skip_hurd_resolver (pc); + if (result) + return result; + + return 0; +} diff --git a/gdb/i386-stub.c b/gdb/i386-stub.c index d453fca..157779c 100644 --- a/gdb/i386-stub.c +++ b/gdb/i386-stub.c @@ -43,7 +43,6 @@ * It should use the same privilege level it runs at. It should * install it as an interrupt gate so that interrupts are masked * while the handler runs. - * Also, need to assign exceptionHook and oldExceptionHook. * * Because gdb will sometimes write to the stack area to execute function * calls, this program cannot rely on using the supervisor stack so it @@ -97,14 +96,10 @@ * * external low-level support routines */ -typedef void (*ExceptionHook)(int); /* pointer to function with int parm */ -typedef void (*Function)(); /* pointer to a function */ extern void putDebugChar(); /* write a single character */ extern int getDebugChar(); /* read and return a single char */ - -extern Function exceptionHandler(); /* assign an exception handler */ -extern ExceptionHook exceptionHook; /* hook variable for errors/exceptions */ +extern void exceptionHandler(); /* assign an exception handler */ /************************************************************************/ /* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/ @@ -138,14 +133,6 @@ int registers[NUMREGS]; int remcomStack[STACKSIZE/sizeof(int)]; static int* stackPtr = &remcomStack[STACKSIZE/sizeof(int) - 1]; -/* - * In many cases, the system will want to continue exception processing - * when a continue command is given. - * oldExceptionHook is a function to invoke in this case. - */ - -static ExceptionHook oldExceptionHook; - /*************************** ASSEMBLY CODE MACROS *************************/ /* */ @@ -456,12 +443,15 @@ char ch; return (-1); } +static char remcomInBuffer[BUFMAX]; +static char remcomOutBuffer[BUFMAX]; + /* scan for the sequence $<data>#<checksum> */ unsigned char * -getpacket (buffer) - unsigned char *buffer; +getpacket () { + unsigned char *buffer = &remcomInBuffer[0]; unsigned char checksum; unsigned char xmitcsum; int count; @@ -557,11 +547,6 @@ void putpacket(buffer) } -char remcomInBuffer[BUFMAX]; -char remcomOutBuffer[BUFMAX]; -static short error; - - void debug_error(format, parm) char * format; char * parm; @@ -739,9 +724,8 @@ void handle_exception(int exceptionVector) stepping = 0; while (1==1) { - error = 0; remcomOutBuffer[0] = 0; - ptr = getpacket(remcomInBuffer); + ptr = getpacket(); switch (*ptr++) { case '?' : remcomOutBuffer[0] = 'S'; @@ -839,25 +823,7 @@ void handle_exception(int exceptionVector) /* set the trace bit if we're stepping */ if (stepping) registers[ PS ] |= 0x100; - /* - * If we found a match for the PC AND we are not returning - * as a result of a breakpoint (33), - * trace exception (9), nmi (31), jmp to - * the old exception handler as if this code never ran. - */ -#if 0 - /* Don't really think we need this, except maybe for protection - exceptions. */ - /* - * invoke the previous handler. - */ - if (oldExceptionHook) - (*oldExceptionHook) (frame->exceptionVector); - newPC = registers[ PC ]; /* pc may have changed */ -#endif /* 0 */ - _returnFromException(); /* this is a jump */ - break; /* kill the program */ @@ -900,12 +866,6 @@ int exception; exceptionHandler (14, _catchException14); exceptionHandler (16, _catchException16); - if (exceptionHook != remcomHandler) - { - oldExceptionHook = exceptionHook; - exceptionHook = remcomHandler; - } - initialized = 1; } diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index d0363e6..6aef61b 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -58,9 +58,11 @@ static char *valid_flavors[] = }; static char *disassembly_flavor = att_flavor; +static void i386_print_register PARAMS ((char *, int, int)); + /* This is used to keep the bfd arch_info in sync with the disassembly flavor. */ static void set_disassembly_flavor_sfunc PARAMS ((char *, int, struct cmd_list_element *)); -static void set_disassembly_flavor (); +static void set_disassembly_flavor PARAMS ((void)); /* Stdio style buffering was used to minimize calls to ptrace, but this buffering did not take into account that the code section being accessed @@ -674,21 +676,38 @@ i386_extract_return_value (type, regbuf, valbuf) char regbuf[REGISTER_BYTES]; char *valbuf; { -/* On AIX, floating point values are returned in floating point registers. */ -#ifdef I386_AIX_TARGET + /* On AIX and i386 GNU/Linux, floating point values are returned in + floating point registers. */ +#if defined(I386_AIX_TARGET) || defined(I386_GNULINUX_TARGET) if (TYPE_CODE_FLT == TYPE_CODE (type)) { double d; /* 387 %st(0), gcc uses this */ floatformat_to_double (&floatformat_i387_ext, - ®buf[REGISTER_BYTE (FP0_REGNUM)], + ®buf[REGISTER_BYTE(FPDATA_REGNUM)], &d); store_floating (valbuf, TYPE_LENGTH (type), d); } else -#endif /* I386_AIX_TARGET */ +#endif /* I386_AIX_TARGET || I386_GNULINUX_TARGET*/ { - memcpy (valbuf, regbuf, TYPE_LENGTH (type)); + int len = TYPE_LENGTH (type); + int low_size = REGISTER_RAW_SIZE (LOW_RETURN_REGNUM); + int high_size = REGISTER_RAW_SIZE (HIGH_RETURN_REGNUM); + + if (len <= low_size) + memcpy (valbuf, regbuf + REGISTER_BYTE (LOW_RETURN_REGNUM), len); + else if (len <= (low_size + high_size)) + { + memcpy (valbuf, + regbuf + REGISTER_BYTE (LOW_RETURN_REGNUM), + low_size); + memcpy (valbuf + low_size, + regbuf + REGISTER_BYTE (HIGH_RETURN_REGNUM), + len - low_size); + } + else + error ("GDB bug: i386-tdep.c (i386_extract_return_value): Don't know how to find a return value %d bytes long", len); } } @@ -942,6 +961,51 @@ set_disassembly_flavor () set_architecture_from_arch_mach (bfd_arch_i386, bfd_mach_i386_i386_intel_syntax); } +/* Print the register regnum, or all registers if regnum is -1 */ + +void +i386_do_registers_info (regnum, fpregs) + int regnum; + int fpregs; +{ + char raw_regs [REGISTER_BYTES]; + int i; + + for (i = 0; i < NUM_REGS; i++) + read_relative_register_raw_bytes (i, raw_regs + REGISTER_BYTE (i)); + + if (regnum < FPSTART_REGNUM) + i386_print_register (raw_regs, regnum, fpregs); + else + i387_print_register (raw_regs, regnum); +} + +static void +i386_print_register (raw_regs, regnum, fpregs) + char *raw_regs; + int regnum; + int fpregs; +{ + int i; + long val; + char string[12]; + + for (i = 0; i < FPSTART_REGNUM; i++) + { + if ((regnum != -1) && (i != regnum)) + continue; + + val = extract_signed_integer (raw_regs + REGISTER_BYTE (i), 4); + + sprintf(string, "0x%x", val); + printf_filtered ("%8.8s: %10.10s %11d\n", REGISTER_NAME(i), string, val); + } + + if ((regnum == -1) && fpregs) + for (i = FPSTART_REGNUM; i < FPEND_REGNUM; i++) + i387_print_register (raw_regs, i); +} + void _initialize_i386_tdep () { diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index 253bc26..0621bdf 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -22,13 +22,16 @@ #include "frame.h" #include "inferior.h" #include "language.h" +#include "value.h" #include "gdbcore.h" #include "floatformat.h" void i387_to_double PARAMS ((char *, char *)); - void double_to_i387 PARAMS ((char *, char *)); +static void print_387_control_bits PARAMS ((unsigned int control)); +static void print_387_status_bits PARAMS ((unsigned int status)); + /* FIXME: Eliminate these routines when we have the time to change all the callers. */ @@ -48,95 +51,281 @@ double_to_i387 (from, to) floatformat_from_double (&floatformat_i387_ext, (double *) from, to); } -void -print_387_control_word (control) +static void +print_387_control_bits (control) unsigned int control; { - printf_unfiltered ("control %s: ", local_hex_string (control)); - printf_unfiltered ("compute to "); switch ((control >> 8) & 3) { case 0: - printf_unfiltered ("24 bits; "); + puts_unfiltered (" 24 bit; "); break; case 1: - printf_unfiltered ("(bad); "); + puts_unfiltered (" (bad); "); break; case 2: - printf_unfiltered ("53 bits; "); + puts_unfiltered (" 53 bit; "); break; case 3: - printf_unfiltered ("64 bits; "); + puts_unfiltered (" 64 bit; "); break; } - printf_unfiltered ("round "); switch ((control >> 10) & 3) { case 0: - printf_unfiltered ("NEAREST; "); + puts_unfiltered ("NEAR; "); break; case 1: - printf_unfiltered ("DOWN; "); + puts_unfiltered ("DOWN; "); break; case 2: - printf_unfiltered ("UP; "); + puts_unfiltered ("UP; "); break; case 3: - printf_unfiltered ("CHOP; "); + puts_unfiltered ("CHOP; "); break; } if (control & 0x3f) { - printf_unfiltered ("mask:"); + puts_unfiltered ("mask"); if (control & 0x0001) - printf_unfiltered (" INVALID"); + puts_unfiltered (" INVAL"); if (control & 0x0002) - printf_unfiltered (" DENORM"); + puts_unfiltered (" DENOR"); if (control & 0x0004) - printf_unfiltered (" DIVZ"); + puts_unfiltered (" DIVZ"); if (control & 0x0008) - printf_unfiltered (" OVERF"); + puts_unfiltered (" OVERF"); if (control & 0x0010) - printf_unfiltered (" UNDERF"); + puts_unfiltered (" UNDER"); if (control & 0x0020) - printf_unfiltered (" LOS"); - printf_unfiltered (";"); + puts_unfiltered (" LOS"); + puts_unfiltered (";"); } printf_unfiltered ("\n"); if (control & 0xe080) - warning ("reserved bits on: %s\n", + warning ("\nreserved bits on: %s", local_hex_string (control & 0xe080)); } void -print_387_status_word (status) +print_387_control_word (control) + unsigned int control; +{ + printf_filtered ("control %s:", local_hex_string(control & 0xffff)); + print_387_control_bits (control); + puts_unfiltered ("\n"); +} + +static void +print_387_status_bits (status) unsigned int status; { - printf_unfiltered ("status %s: ", local_hex_string (status)); - if (status & 0xff) - { - printf_unfiltered ("exceptions:"); - if (status & 0x0001) - printf_unfiltered (" INVALID"); - if (status & 0x0002) - printf_unfiltered (" DENORM"); - if (status & 0x0004) - printf_unfiltered (" DIVZ"); - if (status & 0x0008) - printf_unfiltered (" OVERF"); - if (status & 0x0010) - printf_unfiltered (" UNDERF"); - if (status & 0x0020) - printf_unfiltered (" LOS"); - if (status & 0x0040) - printf_unfiltered (" FPSTACK"); - printf_unfiltered ("; "); - } - printf_unfiltered ("flags: %d%d%d%d; ", + printf_unfiltered (" flags %d%d%d%d; ", (status & 0x4000) != 0, (status & 0x0400) != 0, (status & 0x0200) != 0, (status & 0x0100) != 0); + printf_unfiltered ("top %d; ", (status >> 11) & 7); + if (status & 0xff) + { + puts_unfiltered ("excep"); + if (status & 0x0001) puts_unfiltered (" INVAL"); + if (status & 0x0002) puts_unfiltered (" DENOR"); + if (status & 0x0004) puts_unfiltered (" DIVZ"); + if (status & 0x0008) puts_unfiltered (" OVERF"); + if (status & 0x0010) puts_unfiltered (" UNDER"); + if (status & 0x0020) puts_unfiltered (" LOS"); + if (status & 0x0040) puts_unfiltered (" STACK"); + } +} + +void +print_387_status_word (status) + unsigned int status; +{ + printf_filtered ("status %s:", local_hex_string (status & 0xffff)); + print_387_status_bits (status); + puts_unfiltered ("\n"); +} + +void +i387_print_register (raw_regs, regnum) + char *raw_regs; + int regnum; +{ + unsigned char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; + unsigned long val; + int j, sign, special; + unsigned swd, tags, expon, top, norm, ls, ms; + char string[12]; + +#if (FPREG_RAW_SIZE != 10) +#error "Bad FPREG_RAW_SIZE" +#endif + + printf_filtered ("%8.8s: ", REGISTER_NAME (regnum)); + if (regnum < FPDATA_REGNUM) + { + val = extract_unsigned_integer (raw_regs + REGISTER_BYTE (regnum), 4); + if ( (regnum < FPSTART_REGNUM + 3) || + (regnum == FPSTART_REGNUM + 6) ) + /* Don't print the un-modifiable bytes. */ + sprintf(string, "0x%04x", val & 0xffff); + else + sprintf(string, "0x%08x", val); + + printf_unfiltered ("%10.10s", string); - printf_unfiltered ("top %d\n", (status >> 11) & 7); + if (regnum == FPCONTROL_REGNUM) + print_387_control_bits (val); + else if (regnum == FPSTATUS_REGNUM) + print_387_status_bits (val); + } + else + { + /* An FPU stack register. */ + if ( REGISTER_RAW_SIZE (regnum) != FPREG_RAW_SIZE ) + error ("GDB bug: i387-tdep.c (i387_print_register): wrong size for FPU stack register"); + + /* Put the data in the buffer. No conversions are ever necessary. */ + memcpy (virtual_buffer, raw_regs + REGISTER_BYTE (regnum), + FPREG_RAW_SIZE); + + swd = extract_signed_integer (raw_regs + REGISTER_BYTE (FPSTATUS_REGNUM), + 4); + top = (swd >> 11) & 7; + tags = extract_signed_integer (raw_regs + REGISTER_BYTE (FPTAG_REGNUM), + 4); + + puts_unfiltered ("0x"); + for (j = 0; j < FPREG_RAW_SIZE; j++) + printf_unfiltered ("%02x", + (unsigned char)raw_regs[REGISTER_BYTE (regnum) + + FPREG_RAW_SIZE - 1 - j]); + + puts_unfiltered (" "); + special = 0; + switch ((tags >> (((regnum - FPDATA_REGNUM + top) & 7) * 2)) & 3) + { + case 0: puts_unfiltered ("Valid "); break; + case 1: puts_unfiltered ("Zero "); break; + case 2: puts_unfiltered ("Spec "); + special = 1; + break; + case 3: puts_unfiltered ("Empty "); break; + } + + expon = extract_unsigned_integer (raw_regs + REGISTER_BYTE (regnum) + + FPREG_RAW_SIZE - 2, 2); + sign = expon & 0x8000; + expon &= 0x7fff; + ms = extract_unsigned_integer (raw_regs + REGISTER_BYTE (regnum) + 4, 4); + ls = extract_signed_integer (raw_regs + REGISTER_BYTE (regnum), 4); + norm = ms & 0x80000000; + + if ( expon == 0 ) + { + if ( ms | ls ) + { + /* Denormal or Pseudodenormal. */ + if ( norm ) + puts_unfiltered ("Pseudo "); + else + puts_unfiltered ("Denorm "); + } + else + { + /* Zero. */ + puts_unfiltered ("Zero "); + } + } + else if ( expon == 0x7fff ) + { + /* Infinity, NaN or unsupported. */ + if ( (ms == 0x80000000) && + (ls == 0) ) + { + puts_unfiltered ("Infty "); + } + else if ( norm ) + { + if ( ms & 0x40000000 ) + puts_unfiltered ("QNaN "); + else + puts_unfiltered ("SNaN "); + } + else + { + puts_unfiltered ("Unsupp "); + } + } + else + { + /* Normal or unsupported. */ + if ( norm ) + puts_unfiltered ("Normal "); + else + puts_unfiltered ("Unsupp "); + } + + val_print (REGISTER_VIRTUAL_TYPE (regnum), virtual_buffer, 0, 0, + gdb_stdout, 0, + 1, 0, Val_pretty_default); + } + puts_filtered ("\n"); +} + +void i387_float_info(void) +{ + char raw_regs [REGISTER_BYTES]; + int i; + + for (i = FPSTART_REGNUM; i <= FPEND_REGNUM; i++) + read_relative_register_raw_bytes (i, raw_regs + REGISTER_BYTE (i)); + + for (i = FPSTART_REGNUM; i <= FPEND_REGNUM; i++) + i387_print_register (raw_regs, i); +} + +#ifdef LD_I387 +int +i387_extract_floating (PTR addr, int len, DOUBLEST *dretptr) +{ + if (len == TARGET_LONG_DOUBLE_BIT / 8) + { + if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT) + { + DOUBLEST retval; + + memcpy (dretptr, addr, sizeof (retval)); + } + else + floatformat_to_doublest (TARGET_LONG_DOUBLE_FORMAT, addr, dretptr); + + return 1; + } + else + return 0; +} + +int +i387_store_floating (PTR addr, int len, DOUBLEST val) +{ + if (len == TARGET_LONG_DOUBLE_BIT / 8) + { + /* This `if' may be totally stupid. I just put it in here to be + absolutely sure I'm preserving the semantics of the code I'm + frobbing, while I try to maintain portability boundaries; I + don't actually know exactly what it's doing. -JimB, May 1999 */ + if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT) + memcpy (addr, &val, sizeof (val)); + else + floatformat_from_doublest (TARGET_LONG_DOUBLE_FORMAT, &val, addr); + + return 1; + } + else + return 0; } +#endif /* LD_I387 */ diff --git a/gdb/i960-tdep.c b/gdb/i960-tdep.c index 4818b4f..44ac883 100644 --- a/gdb/i960-tdep.c +++ b/gdb/i960-tdep.c @@ -567,7 +567,7 @@ saved_pc_after_call (frame) restoring all saved registers. */ void -pop_frame () +i960_pop_frame (void) { register struct frame_info *current_fi, *prev_fi; register int i; diff --git a/gdb/inferior.h b/gdb/inferior.h index 4f5daf4..8f2f435 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -258,6 +258,12 @@ extern int signal_print_state PARAMS ((int)); extern int signal_pass_state PARAMS ((int)); +extern int signal_stop_update PARAMS ((int, int)); + +extern int signal_print_update PARAMS ((int, int)); + +extern int signal_pass_update PARAMS ((int, int)); + /* From infcmd.c */ extern void tty_command PARAMS ((char *, int)); diff --git a/gdb/infrun.c b/gdb/infrun.c index 1527ed9..a46587e 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -176,15 +176,53 @@ static int use_thread_step_needed = USE_THREAD_STEP_NEEDED; #define DYNAMIC_TRAMPOLINE_NEXTPC(pc) 0 #endif -/* On SVR4 based systems, determining the callee's address is exceedingly - difficult and depends on the implementation of the run time loader. - If we are stepping at the source level, we single step until we exit - the run time loader code and reach the callee's address. */ +/* If the program uses ELF-style shared libraries, then calls to + functions in shared libraries go through stubs, which live in a + table called the PLT (Procedure Linkage Table). The first time the + function is called, the stub sends control to the dynamic linker, + which looks up the function's real address, patches the stub so + that future calls will go directly to the function, and then passes + control to the function. + + If we are stepping at the source level, we don't want to see any of + this --- we just want to skip over the stub and the dynamic linker. + The simple approach is to single-step until control leaves the + dynamic linker. + + However, on some systems (e.g., Red Hat Linux 5.2) the dynamic + linker calls functions in the shared C library, so you can't tell + from the PC alone whether the dynamic linker is still running. In + this case, we use a step-resume breakpoint to get us past the + dynamic linker, as if we were using "next" to step over a function + call. + + IN_SOLIB_DYNSYM_RESOLVE_CODE says whether we're in the dynamic + linker code or not. Normally, this means we single-step. However, + if SKIP_SOLIB_RESOLVER then returns non-zero, then its value is an + address where we can place a step-resume breakpoint to get past the + linker's symbol resolution function. + + IN_SOLIB_DYNSYM_RESOLVE_CODE can generally be implemented in a + pretty portable way, by comparing the PC against the address ranges + of the dynamic linker's sections. + + SKIP_SOLIB_RESOLVER is generally going to be system-specific, since + it depends on internal details of the dynamic linker. It's usually + not too hard to figure out where to put a breakpoint, but it + certainly isn't portable. SKIP_SOLIB_RESOLVER should do plenty of + sanity checking. If it can't figure things out, returning zero and + getting the (possibly confusing) stepping behavior is better than + signalling an error, which will obscure the change in the + inferior's state. */ #ifndef IN_SOLIB_DYNSYM_RESOLVE_CODE #define IN_SOLIB_DYNSYM_RESOLVE_CODE(pc) 0 #endif +#ifndef SKIP_SOLIB_RESOLVER +#define SKIP_SOLIB_RESOLVER(pc) 0 +#endif + /* For SVR4 shared libraries, each call goes through a small piece of trampoline code in the ".plt" section. IN_SOLIB_CALL_TRAMPOLINE evaluates to nonzero if we are current stopped in one of these. */ @@ -1137,8 +1175,10 @@ void init_execution_control_state (struct execution_control_state * ecs); void handle_inferior_event (struct execution_control_state * ecs); static void check_sigtramp2 (struct execution_control_state *ecs); +static void step_over_function (struct execution_control_state *ecs); static void stop_stepping (struct execution_control_state *ecs); static void prepare_to_wait (struct execution_control_state *ecs); +static void keep_going (struct execution_control_state *ecs); /* Wait for control to return from inferior to debugger. If inferior gets a signal, we may decide to start it up again @@ -2108,15 +2148,17 @@ handle_inferior_event (struct execution_control_state *ecs) { trap_expected = 1; stop_signal = TARGET_SIGNAL_0; - goto keep_going; + keep_going (ecs); + return; } } else if (ecs->ws.kind == TARGET_WAITKIND_VFORKED) { if (ecs->random_signal) /* I.e., no catchpoint triggered for this. */ { - stop_signal = TARGET_SIGNAL_0; - goto keep_going; + stop_signal = TARGET_SIGNAL_0; + keep_going (ecs); + return; } } else if (ecs->ws.kind == TARGET_WAITKIND_EXECD) @@ -2126,7 +2168,8 @@ handle_inferior_event (struct execution_control_state *ecs) { trap_expected = 1; stop_signal = TARGET_SIGNAL_0; - goto keep_going; + keep_going (ecs); + return; } } @@ -2182,7 +2225,7 @@ handle_inferior_event (struct execution_control_state *ecs) that case, when we reach this point, there is already a step-resume breakpoint established, right where it should be: immediately after the function call the user is "next"-ing - over. If we jump to step_over_function now, two bad things + over. If we call step_over_function now, two bad things happen: - we'll create a new breakpoint, at wherever the current @@ -2230,7 +2273,10 @@ handle_inferior_event (struct execution_control_state *ecs) remove_breakpoints (); breakpoints_inserted = 0; if (!GET_LONGJMP_TARGET (&jmp_buf_pc)) - goto keep_going; + { + keep_going (ecs); + return; + } /* Need to blow away step-resume breakpoint, as it interferes with us */ @@ -2256,7 +2302,8 @@ handle_inferior_event (struct execution_control_state *ecs) #endif /* 0 */ set_longjmp_resume_breakpoint (jmp_buf_pc, NULL); ecs->handling_longjmp = 1; /* FIXME */ - goto keep_going; + keep_going (ecs); + return; case BPSTAT_WHAT_CLEAR_LONGJMP_RESUME: case BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE: @@ -2269,7 +2316,8 @@ handle_inferior_event (struct execution_control_state *ecs) step_frame_address))) { ecs->another_trap = 1; - goto keep_going; + keep_going (ecs); + return; } #endif /* 0 */ disable_longjmp_breakpoint (); @@ -2452,7 +2500,8 @@ handle_inferior_event (struct execution_control_state *ecs) if (SOLIB_IN_DYNAMIC_LINKER (ecs->pid, stop_pc)) { ecs->another_trap = 1; - goto keep_going; + keep_going (ecs); + return; } #endif /* Else, stop and report the catchpoint(s) whose triggering @@ -2499,7 +2548,8 @@ handle_inferior_event (struct execution_control_state *ecs) /* I'm not sure whether this needs to be check_sigtramp2 or whether it could/should be keep_going. */ check_sigtramp2 (ecs); - goto keep_going; + keep_going (ecs); + return; } if (step_range_end == 0) @@ -2508,7 +2558,8 @@ handle_inferior_event (struct execution_control_state *ecs) /* I'm not sure whether this needs to be check_sigtramp2 or whether it could/should be keep_going. */ check_sigtramp2 (ecs); - goto keep_going; + keep_going (ecs); + return; } /* If stepping through a line, keep going if still within it. @@ -2522,7 +2573,8 @@ handle_inferior_event (struct execution_control_state *ecs) /* We might be doing a BPSTAT_WHAT_SINGLE and getting a signal. So definately need to check for sigtramp here. */ check_sigtramp2 (ecs); - goto keep_going; + keep_going (ecs); + return; } /* We stepped out of the stepping range. */ @@ -2532,7 +2584,27 @@ handle_inferior_event (struct execution_control_state *ecs) until we exit the run time loader code and reach the callee's address. */ if (step_over_calls < 0 && IN_SOLIB_DYNSYM_RESOLVE_CODE (stop_pc)) - goto keep_going; + { + CORE_ADDR pc_after_resolver = SKIP_SOLIB_RESOLVER (stop_pc); + + if (pc_after_resolver) + { + /* Set up a step-resume breakpoint at the address + indicated by SKIP_SOLIB_RESOLVER. */ + struct symtab_and_line sr_sal; + INIT_SAL (&sr_sal); + sr_sal.pc = pc_after_resolver; + + check_for_old_step_resume_breakpoint (); + step_resume_breakpoint = + set_momentary_breakpoint (sr_sal, NULL, bp_step_resume); + if (breakpoints_inserted) + insert_breakpoints (); + } + + keep_going (ecs); + return; + } /* We can't update step_sp every time through the loop, because reading the stack pointer would slow down stepping too much. @@ -2591,7 +2663,7 @@ handle_inferior_event (struct execution_control_state *ecs) /* We just stepped out of a signal handler and into its calling trampoline. - Normally, we'd jump to step_over_function from + Normally, we'd call step_over_function from here, but for some reason GDB can't unwind the stack correctly to find the real PC for the point user code where the signal trampoline will return @@ -2620,7 +2692,8 @@ handle_inferior_event (struct execution_control_state *ecs) step_range_end = (step_range_start = prev_pc) + 1; ecs->remove_breakpoints_on_following_step = 1; - goto keep_going; + keep_going (ecs); + return; } if (stop_pc == ecs->stop_func_start /* Quick test */ @@ -2642,8 +2715,12 @@ handle_inferior_event (struct execution_control_state *ecs) } if (step_over_calls > 0 || IGNORE_HELPER_CALL (stop_pc)) - /* We're doing a "next". */ - goto step_over_function; + { + /* We're doing a "next". */ + step_over_function (ecs); + keep_going (ecs); + return; + } /* If we are in a function call trampoline (a stub between the calling routine and the real function), locate the real @@ -2668,7 +2745,8 @@ handle_inferior_event (struct execution_control_state *ecs) step_resume_breakpoint = set_momentary_breakpoint (xxx, NULL, bp_step_resume); insert_breakpoints (); - goto keep_going; + keep_going (ecs); + return; } } @@ -2685,40 +2763,9 @@ handle_inferior_event (struct execution_control_state *ecs) if (tmp_sal.line != 0) goto step_into_function; } - - step_over_function: - /* A subroutine call has happened. */ - { - /* We've just entered a callee, and we wish to resume until it - returns to the caller. Setting a step_resume breakpoint on - the return address will catch a return from the callee. - - However, if the callee is recursing, we want to be careful - not to catch returns of those recursive calls, but only of - THIS instance of the call. - - To do this, we set the step_resume bp's frame to our current - caller's frame (step_frame_address, which is set by the "next" - or "until" command, before execution begins). */ - struct symtab_and_line sr_sal; - - INIT_SAL (&sr_sal); /* initialize to zeros */ - sr_sal.pc = - ADDR_BITS_REMOVE (SAVED_PC_AFTER_CALL (get_current_frame ())); - sr_sal.section = find_pc_overlay (sr_sal.pc); - - check_for_old_step_resume_breakpoint (); - step_resume_breakpoint = - set_momentary_breakpoint (sr_sal, get_current_frame (), - bp_step_resume); - - if (!IN_SOLIB_DYNSYM_RESOLVE_CODE (sr_sal.pc)) - step_resume_breakpoint->frame = step_frame_address; - - if (breakpoints_inserted) - insert_breakpoints (); - } - goto keep_going; + step_over_function (ecs); + keep_going (ecs); + return; step_into_function: /* Subroutine call with source code we should not step over. @@ -2772,7 +2819,8 @@ handle_inferior_event (struct execution_control_state *ecs) /* And make sure stepping stops right away then. */ step_range_end = step_range_start; } - goto keep_going; + keep_going (ecs); + return; } /* We've wandered out of the step range. */ @@ -2817,7 +2865,8 @@ handle_inferior_event (struct execution_control_state *ecs) /* Restart without fiddling with the step ranges or other state. */ - goto keep_going; + keep_going (ecs); + return; } } @@ -2877,121 +2926,9 @@ handle_inferior_event (struct execution_control_state *ecs) step_frame_address = current_frame; } - keep_going: - /* Come to this label when you need to resume the inferior. - It's really much cleaner to do a goto than a maze of if-else - conditions. */ - - /* ??rehrauer: ttrace on HP-UX theoretically allows one to debug - a vforked child beetween its creation and subsequent exit or - call to exec(). However, I had big problems in this rather - creaky exec engine, getting that to work. The fundamental - problem is that I'm trying to debug two processes via an - engine that only understands a single process with possibly - multiple threads. - - Hence, this spot is known to have problems when - target_can_follow_vfork_prior_to_exec returns 1. */ - - /* Save the pc before execution, to compare with pc after stop. */ - prev_pc = read_pc (); /* Might have been DECR_AFTER_BREAK */ - prev_func_start = ecs->stop_func_start; /* Ok, since if DECR_PC_AFTER - BREAK is defined, the - original pc would not have - been at the start of a - function. */ - prev_func_name = ecs->stop_func_name; - - if (ecs->update_step_sp) - step_sp = read_sp (); - ecs->update_step_sp = 0; - - /* If we did not do break;, it means we should keep - running the inferior and not return to debugger. */ - - if (trap_expected && stop_signal != TARGET_SIGNAL_TRAP) - { - /* We took a signal (which we are supposed to pass through to - the inferior, else we'd have done a break above) and we - haven't yet gotten our trap. Simply continue. */ - resume (currently_stepping (ecs), stop_signal); - } - else - { - /* Either the trap was not expected, but we are continuing - anyway (the user asked that this signal be passed to the - child) - -- or -- - The signal was SIGTRAP, e.g. it was our signal, but we - decided we should resume from it. - - We're going to run this baby now! - - Insert breakpoints now, unless we are trying - to one-proceed past a breakpoint. */ - /* If we've just finished a special step resume and we don't - want to hit a breakpoint, pull em out. */ - if (step_resume_breakpoint == NULL - && through_sigtramp_breakpoint == NULL - && ecs->remove_breakpoints_on_following_step) - { - ecs->remove_breakpoints_on_following_step = 0; - remove_breakpoints (); - breakpoints_inserted = 0; - } - else if (!breakpoints_inserted && - (through_sigtramp_breakpoint != NULL || !ecs->another_trap)) - { - breakpoints_failed = insert_breakpoints (); - if (breakpoints_failed) - { - stop_stepping (ecs); - return; - } - breakpoints_inserted = 1; - } - - trap_expected = ecs->another_trap; - - /* Do not deliver SIGNAL_TRAP (except when the user - explicitly specifies that such a signal should be - delivered to the target program). - - Typically, this would occure when a user is debugging a - target monitor on a simulator: the target monitor sets a - breakpoint; the simulator encounters this break-point and - halts the simulation handing control to GDB; GDB, noteing - that the break-point isn't valid, returns control back to - the simulator; the simulator then delivers the hardware - equivalent of a SIGNAL_TRAP to the program being - debugged. */ - - if (stop_signal == TARGET_SIGNAL_TRAP - && !signal_program[stop_signal]) - stop_signal = TARGET_SIGNAL_0; - -#ifdef SHIFT_INST_REGS - /* I'm not sure when this following segment applies. I do know, - now, that we shouldn't rewrite the regs when we were stopped - by a random signal from the inferior process. */ - /* FIXME: Shouldn't this be based on the valid bit of the SXIP? - (this is only used on the 88k). */ - - if (!bpstat_explains_signal (stop_bpstat) - && (stop_signal != TARGET_SIGNAL_CHLD) - && !stopped_by_random_signal) - SHIFT_INST_REGS (); -#endif /* SHIFT_INST_REGS */ - - resume (currently_stepping (ecs), stop_signal); - } - - prepare_to_wait (ecs); - return; + keep_going (ecs); } /* extra brace, to preserve old indentation */ - - stop_stepping (ecs); } /* Are we in the middle of stepping? */ @@ -3043,6 +2980,39 @@ check_sigtramp2 (struct execution_control_state *ecs) } } + +/* We've just entered a callee, and we wish to resume until it returns + to the caller. Setting a step_resume breakpoint on the return + address will catch a return from the callee. + + However, if the callee is recursing, we want to be careful not to + catch returns of those recursive calls, but only of THIS instance + of the call. + + To do this, we set the step_resume bp's frame to our current + caller's frame (step_frame_address, which is set by the "next" or + "until" command, before execution begins). */ + +static void +step_over_function (struct execution_control_state *ecs) +{ + struct symtab_and_line sr_sal; + + INIT_SAL (&sr_sal); /* initialize to zeros */ + sr_sal.pc = ADDR_BITS_REMOVE (SAVED_PC_AFTER_CALL (get_current_frame ())); + sr_sal.section = find_pc_overlay (sr_sal.pc); + + check_for_old_step_resume_breakpoint (); + step_resume_breakpoint = + set_momentary_breakpoint (sr_sal, get_current_frame (), bp_step_resume); + + if (!IN_SOLIB_DYNSYM_RESOLVE_CODE (sr_sal.pc)) + step_resume_breakpoint->frame = step_frame_address; + + if (breakpoints_inserted) + insert_breakpoints (); +} + static void stop_stepping (struct execution_control_state *ecs) { @@ -3084,6 +3054,118 @@ stop_stepping (struct execution_control_state *ecs) ecs->wait_some_more = 0; } +/* This function handles various cases where we need to continue + waiting for the inferior. */ +/* (Used to be the keep_going: label in the old wait_for_inferior) */ + +static void +keep_going (struct execution_control_state *ecs) +{ + /* ??rehrauer: ttrace on HP-UX theoretically allows one to debug a + vforked child between its creation and subsequent exit or call to + exec(). However, I had big problems in this rather creaky exec + engine, getting that to work. The fundamental problem is that + I'm trying to debug two processes via an engine that only + understands a single process with possibly multiple threads. + + Hence, this spot is known to have problems when + target_can_follow_vfork_prior_to_exec returns 1. */ + + /* Save the pc before execution, to compare with pc after stop. */ + prev_pc = read_pc (); /* Might have been DECR_AFTER_BREAK */ + prev_func_start = ecs->stop_func_start; /* Ok, since if DECR_PC_AFTER + BREAK is defined, the + original pc would not have + been at the start of a + function. */ + prev_func_name = ecs->stop_func_name; + + if (ecs->update_step_sp) + step_sp = read_sp (); + ecs->update_step_sp = 0; + + /* If we did not do break;, it means we should keep running the + inferior and not return to debugger. */ + + if (trap_expected && stop_signal != TARGET_SIGNAL_TRAP) + { + /* We took a signal (which we are supposed to pass through to + the inferior, else we'd have done a break above) and we + haven't yet gotten our trap. Simply continue. */ + resume (currently_stepping (ecs), stop_signal); + } + else + { + /* Either the trap was not expected, but we are continuing + anyway (the user asked that this signal be passed to the + child) + -- or -- + The signal was SIGTRAP, e.g. it was our signal, but we + decided we should resume from it. + + We're going to run this baby now! + + Insert breakpoints now, unless we are trying to one-proceed + past a breakpoint. */ + /* If we've just finished a special step resume and we don't + want to hit a breakpoint, pull em out. */ + if (step_resume_breakpoint == NULL + && through_sigtramp_breakpoint == NULL + && ecs->remove_breakpoints_on_following_step) + { + ecs->remove_breakpoints_on_following_step = 0; + remove_breakpoints (); + breakpoints_inserted = 0; + } + else if (!breakpoints_inserted && + (through_sigtramp_breakpoint != NULL || !ecs->another_trap)) + { + breakpoints_failed = insert_breakpoints (); + if (breakpoints_failed) + { + stop_stepping (ecs); + return; + } + breakpoints_inserted = 1; + } + + trap_expected = ecs->another_trap; + + /* Do not deliver SIGNAL_TRAP (except when the user explicitly + specifies that such a signal should be delivered to the + target program). + + Typically, this would occure when a user is debugging a + target monitor on a simulator: the target monitor sets a + breakpoint; the simulator encounters this break-point and + halts the simulation handing control to GDB; GDB, noteing + that the break-point isn't valid, returns control back to the + simulator; the simulator then delivers the hardware + equivalent of a SIGNAL_TRAP to the program being debugged. */ + + if (stop_signal == TARGET_SIGNAL_TRAP + && !signal_program[stop_signal]) + stop_signal = TARGET_SIGNAL_0; + +#ifdef SHIFT_INST_REGS + /* I'm not sure when this following segment applies. I do know, + now, that we shouldn't rewrite the regs when we were stopped + by a random signal from the inferior process. */ + /* FIXME: Shouldn't this be based on the valid bit of the SXIP? + (this is only used on the 88k). */ + + if (!bpstat_explains_signal (stop_bpstat) + && (stop_signal != TARGET_SIGNAL_CHLD) + && !stopped_by_random_signal) + SHIFT_INST_REGS (); +#endif /* SHIFT_INST_REGS */ + + resume (currently_stepping (ecs), stop_signal); + } + + prepare_to_wait (ecs); +} + /* This function normally comes after a resume, before handle_inferior_event exits. It takes care of any last bits of housekeeping, and sets the all-important wait_some_more flag. */ @@ -3365,6 +3447,33 @@ signal_pass_state (int signo) return signal_program[signo]; } +int signal_stop_update (signo, state) + int signo; + int state; +{ + int ret = signal_stop[signo]; + signal_stop[signo] = state; + return ret; +} + +int signal_print_update (signo, state) + int signo; + int state; +{ + int ret = signal_print[signo]; + signal_print[signo] = state; + return ret; +} + +int signal_pass_update (signo, state) + int signo; + int state; +{ + int ret = signal_program[signo]; + signal_program[signo] = state; + return ret; +} + static void sig_print_header (void) { diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c index e19a307..7e87b15 100644 --- a/gdb/jv-valprint.c +++ b/gdb/jv-valprint.c @@ -126,7 +126,7 @@ java_value_print (val, stream, format, pretty) if (element == 0) fprintf_filtered (stream, "null"); else - fprintf_filtered (stream, "@%x", element); + fprintf_filtered (stream, "@%s", paddr_nz (element)); things_printed++; i += reps; diff --git a/gdb/linux-thread.c b/gdb/linux-thread.c new file mode 100644 index 0000000..9f0a807 --- /dev/null +++ b/gdb/linux-thread.c @@ -0,0 +1,1637 @@ +/* Low level interface for debugging GNU/Linux threads for GDB, + the GNU debugger. + Copyright 1998, 1999 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* This module implements the debugging interface of the linuxthreads package + of the glibc. This package implements a simple clone()-based implementation + of Posix threads for Linux. To use this module, be sure that you have at + least the version of the linuxthreads package that holds the support of + GDB (currently 0.8 included in the glibc-2.0.7). + + Right now, the linuxthreads package does not care of priority scheduling, + so, neither this module does; In particular, the threads are resumed + in any order, which could lead to different scheduling than the one + happening when GDB does not control the execution. + + The latest point is that ptrace(PT_ATTACH, ...) is intrusive in Linux: + When a process is attached, then the attaching process becomes the current + parent of the attached process, and the old parent has lost this child. + If the old parent does a wait[...](), then this child is no longer + considered by the kernel as a child of the old parent, thus leading to + results of the call different when the child is attached and when it's not. + + A fix has been submitted to the Linux community to solve this problem, + which consequences are not visible to the application itself, but on the + process which may wait() for the completion of the application (mostly, + it may consider that the application no longer exists (errno == ECHILD), + although it does, and thus being unable to get the exit status and resource + usage of the child. If by chance, it is able to wait() for the application + after it has died (by receiving first a SIGCHILD, and then doing a wait(), + then the exit status and resource usage may be wrong, because the + linuxthreads package heavily relies on wait() synchronization to keep + them correct. */ + +#include <sys/types.h> /* for pid_t */ +#include <sys/ptrace.h> /* for PT_* flags */ +#include <sys/wait.h> /* for WUNTRACED and __WCLONE flags */ +#include <signal.h> /* for struct sigaction and NSIG */ +#include <sys/utsname.h> + +#include "defs.h" +#include "target.h" +#include "inferior.h" +#include "gdbcore.h" +#include "gdbthread.h" +#include "wait.h" +#include "gdbcmd.h" +#include "breakpoint.h" + +#ifndef PT_ATTACH +#define PT_ATTACH PTRACE_ATTACH +#endif +#ifndef PT_KILL +#define PT_KILL PTRACE_KILL +#endif +#ifndef PT_READ_U +#define PT_READ_U PTRACE_PEEKUSR +#endif + +#ifdef NSIG +#define LINUXTHREAD_NSIG NSIG +#else +#ifdef _NSIG +#define LINUXTHREAD_NSIG _NSIG +#endif +#endif + +extern int child_suppress_run; /* make inftarg.c non-runnable */ +struct target_ops linuxthreads_ops; /* Forward declaration */ +extern struct target_ops child_ops; /* target vector for inftarg.c */ + +static CORE_ADDR linuxthreads_handles; /* array of linuxthreads handles */ +static CORE_ADDR linuxthreads_manager; /* pid of linuxthreads manager thread */ +static CORE_ADDR linuxthreads_initial; /* pid of linuxthreads initial thread */ +static CORE_ADDR linuxthreads_debug; /* linuxthreads internal debug flag */ +static CORE_ADDR linuxthreads_num; /* number of valid handle entries */ + +static int linuxthreads_max; /* Maximum number of linuxthreads. + Zero if this executable doesn't use + threads, or wasn't linked with a + debugger-friendly version of the + linuxthreads library. */ + +static int linuxthreads_sizeof_handle; /* size of a linuxthreads handle */ +static int linuxthreads_offset_descr; /* h_descr offset of the linuxthreads + handle */ +static int linuxthreads_offset_pid; /* p_pid offset of the linuxthreads + descr */ + +static int linuxthreads_manager_pid; /* manager pid */ +static int linuxthreads_initial_pid; /* initial pid */ + +/* These variables form a bag of threads with interesting status. If + wait_thread (PID) finds that PID stopped for some interesting + reason (i.e. anything other than stopped with SIGSTOP), then it + records its status in this queue. linuxthreads_wait and + linuxthreads_find_trap extract processes from here. */ +static int *linuxthreads_wait_pid; /* wait array of pid */ +static int *linuxthreads_wait_status; /* wait array of status */ +static int linuxthreads_wait_last; /* index of last valid elt in + linuxthreads_wait_{pid,status} */ + +static sigset_t linuxthreads_wait_mask; /* sigset with SIGCHLD */ + +static int linuxthreads_step_pid; /* current stepped pid */ +static int linuxthreads_step_signo; /* current stepped target signal */ +static int linuxthreads_exit_status; /* exit status of initial thread */ + +static int linuxthreads_inferior_pid; /* temporary internal inferior pid */ +static int linuxthreads_breakpoint_pid; /* last pid that hit a breakpoint */ +static int linuxthreads_attach_pending; /* attach command without wait */ + +static int linuxthreads_breakpoints_inserted; /* any breakpoints inserted */ + +/* LinuxThreads uses certain signals for communication between + processes; we need to tell GDB to pass them through silently to the + inferior. The LinuxThreads library has global variables we can + read containing the relevant signal numbers, but since the signal + numbers are chosen at run-time, those variables aren't initialized + until the shared library's constructors have had a chance to run. */ + +struct linuxthreads_signal { + + /* The name of the LinuxThreads library variable that contains + the signal number. */ + char *var; + + /* True if this variable must exist for us to debug properly. */ + int required; + + /* The variable's address in the inferior, or zero if the + LinuxThreads library hasn't been loaded into this inferior yet. */ + CORE_ADDR addr; + + /* The signal number, or zero if we don't know yet (either because + we haven't found the variable, or it hasn't been initialized). + This is an actual target signal number that you could pass to + `kill', not a GDB signal number. */ + int signal; + + /* GDB's original settings for `stop' and `print' for this signal. + We restore them when the user selects a different executable. + Invariant: if sig->signal != 0, then sig->{stop,print} contain + the original settings. */ + int stop, print; +}; + +struct linuxthreads_signal linuxthreads_sig_restart = { + "__pthread_sig_restart", 1, 0, 0, 0 +}; +struct linuxthreads_signal linuxthreads_sig_cancel = { + "__pthread_sig_cancel", 1, 0, 0, 0 +}; +struct linuxthreads_signal linuxthreads_sig_debug = { + "__pthread_sig_debug", 0, 0, 0, 0 +}; + +/* A table of breakpoint locations, one per PID. */ +static struct linuxthreads_breakpoint { + CORE_ADDR pc; /* PC of breakpoint */ + int pid; /* pid of breakpoint */ + int step; /* whether the pc has been reached after sstep */ +} *linuxthreads_breakpoint_zombie; /* Zombie breakpoints array */ +static int linuxthreads_breakpoint_last; /* Last zombie breakpoint */ + +/* linuxthreads_{insert,remove}_breakpoint pass the breakpoint address + to {insert,remove}_breakpoint via this variable, since + iterate_active_threads doesn't provide any way to pass values + through to the worker function. */ +static CORE_ADDR linuxthreads_breakpoint_addr; + +#define REMOVE_BREAKPOINT_ZOMBIE(_i) \ +{ \ + if ((_i) < linuxthreads_breakpoint_last) \ + linuxthreads_breakpoint_zombie[(_i)] = \ + linuxthreads_breakpoint_zombie[linuxthreads_breakpoint_last]; \ + linuxthreads_breakpoint_last--; \ +} + + + +#ifndef PTRACE_XFER_TYPE +#define PTRACE_XFER_TYPE int +#endif +/* Check to see if the given thread is alive. */ +static int +linuxthreads_thread_alive (pid) + int pid; +{ + errno = 0; + return ptrace (PT_READ_U, pid, (PTRACE_ARG3_TYPE)0, 0) >= 0 || errno == 0; +} + +/* On detach(), find a SIGTRAP status. If stop is non-zero, find a + SIGSTOP one, too. + + Make sure PID is ready to run, and free of interference from our + efforts to debug it (e.g., pending SIGSTOP or SIGTRAP signals). If + STOP is zero, just look for a SIGTRAP. If STOP is non-zero, look + for a SIGSTOP, too. Return non-zero if PID is alive and ready to + run; return zero if PID is dead. + + PID may or may not be stopped at the moment, and we may or may not + have waited for it already. We check the linuxthreads_wait bag in + case we've already got a status for it. We may possibly wait for + it ourselves. + + PID may have signals waiting to be delivered. If they're caused by + our efforts to debug it, accept them with wait, but don't pass them + through to PID. Do pass all other signals through. */ +static int +linuxthreads_find_trap (pid, stop) + int pid; + int stop; +{ + int i; + int rpid; + int status; + int found_stop = 0; + int found_trap = 0; + + /* PID may have any number of signals pending. The kernel will + report each of them to us via wait, and then it's up to us to + pass them along to the process via ptrace, if we so choose. + + We need to paw through the whole set until we've found a SIGTRAP + (or a SIGSTOP, if `stop' is set). We don't pass the SIGTRAP (or + SIGSTOP) through, but we do re-send all the others, so PID will + receive them when we resume it. */ + int *wstatus = alloca (LINUXTHREAD_NSIG * sizeof (int)); + int last = 0; + + /* Look at the pending status */ + for (i = linuxthreads_wait_last; i >= 0; i--) + if (linuxthreads_wait_pid[i] == pid) + { + status = linuxthreads_wait_status[i]; + + /* Delete the i'th member of the table. Since the table is + unordered, we can do this simply by copying the table's + last element to the i'th position, and shrinking the table + by one element. */ + if (i < linuxthreads_wait_last) + { + linuxthreads_wait_status[i] = + linuxthreads_wait_status[linuxthreads_wait_last]; + linuxthreads_wait_pid[i] = + linuxthreads_wait_pid[linuxthreads_wait_last]; + } + linuxthreads_wait_last--; + + if (!WIFSTOPPED(status)) /* Thread has died */ + return 0; + + if (WSTOPSIG(status) == SIGTRAP) + { + if (stop) + found_trap = 1; + else + return 1; + } + else if (WSTOPSIG(status) == SIGSTOP) + { + if (stop) + found_stop = 1; + } + else + { + wstatus[0] = status; + last = 1; + } + + break; + } + + if (stop) + { + /* Make sure that we'll find what we're looking for. */ + if (!found_trap) + kill (pid, SIGTRAP); + if (!found_stop) + kill (pid, SIGSTOP); + } + + /* Catch all status until SIGTRAP and optionally SIGSTOP show up. */ + for (;;) + { + child_resume (pid, 1, TARGET_SIGNAL_0); + + for (;;) + { + rpid = waitpid (pid, &status, __WCLONE); + if (rpid > 0) + break; + if (errno == EINTR) + continue; + + /* There are a few reasons the wait call above may have + failed. If the thread manager dies, its children get + reparented, and this interferes with GDB waiting for + them, in some cases. Another possibility is that the + initial thread was not cloned, so calling wait with + __WCLONE won't find it. I think neither of these should + occur in modern Linux kernels --- they don't seem to in + 2.0.36. */ + rpid = waitpid (pid, &status, 0); + if (rpid > 0) + break; + if (errno != EINTR) + perror_with_name ("waitpid"); + } + + if (!WIFSTOPPED(status)) /* Thread has died */ + return 0; + + if (WSTOPSIG(status) == SIGTRAP) + if (!stop || found_stop) + break; + else + found_trap = 1; + else if (WSTOPSIG(status) != SIGSTOP) + wstatus[last++] = status; + else if (stop) + if (found_trap) + break; + else + found_stop = 1; + } + + /* Resend any other signals we noticed to the thread, to be received + when we continue it. */ + while (--last >= 0) + kill (pid, WSTOPSIG(wstatus[last])); + + return 1; +} + +/* Cleanup stub for save_inferior_pid. */ +static void +restore_inferior_pid (arg) + void *arg; +{ + int pid = (int) arg; + inferior_pid = pid; +} + +/* Register a cleanup to restore the value of inferior_pid. */ +static struct cleanup * +save_inferior_pid () +{ + return make_cleanup (restore_inferior_pid, (void *) inferior_pid); +} + +static void +sigchld_handler (signo) + int signo; +{ + /* This handler is used to get an EINTR while doing waitpid() + when an event is received */ +} + +/* Have we already collected a wait status for PID in the + linuxthreads_wait bag? */ +static int +linuxthreads_pending_status (pid) + int pid; +{ + int i; + for (i = linuxthreads_wait_last; i >= 0; i--) + if (linuxthreads_wait_pid[i] == pid) + return 1; + return 0; +} + + +/* Internal linuxthreads signal management */ + +/* Check in OBJFILE for the variable that holds the number for signal SIG. + We assume that we've already found other LinuxThreads-ish variables + in OBJFILE, so we complain if it's required, but not there. + Return true iff things are okay. */ +static int +find_signal_var (sig, objfile) + struct linuxthreads_signal *sig; + struct objfile *objfile; +{ + struct minimal_symbol *ms = lookup_minimal_symbol (sig->var, NULL, objfile); + + if (! ms) + { + if (sig->required) + { + fprintf_unfiltered (gdb_stderr, + "Unable to find linuxthreads symbol \"%s\"\n", + sig->var); + return 0; + } + else + { + sig->addr = 0; + return 1; + } + } + + sig->addr = SYMBOL_VALUE_ADDRESS (ms); + + return 1; +} + +static int +find_all_signal_vars (objfile) + struct objfile *objfile; +{ + return ( find_signal_var (&linuxthreads_sig_restart, objfile) + && find_signal_var (&linuxthreads_sig_cancel, objfile) + && find_signal_var (&linuxthreads_sig_debug, objfile)); +} + +/* A struct complaint isn't appropriate here. */ +static int complained_cannot_determine_thread_signal_number = 0; + +/* Check to see if the variable holding the signal number for SIG has + been initialized yet. If it has, tell GDB to pass that signal + through to the inferior silently. */ +static void +check_signal_number (sig) + struct linuxthreads_signal *sig; +{ + int num; + + if (sig->signal) + /* We already know this signal number. */ + return; + + if (! sig->addr) + /* We don't know the variable's address yet. */ + return; + + if (target_read_memory (sig->addr, (char *)&num, sizeof (num)) + != 0) + { + /* If this happens once, it'll probably happen for all the + signals, so only complain once. */ + if (! complained_cannot_determine_thread_signal_number) + warning ("Cannot determine thread signal number; " + "GDB may report spurious signals."); + complained_cannot_determine_thread_signal_number = 1; + return; + } + + if (num == 0) + /* It hasn't been initialized yet. */ + return; + + /* We know sig->signal was zero, and is becoming non-zero, so it's + okay to sample GDB's original settings. */ + sig->signal = num; + sig->stop = signal_stop_update (target_signal_from_host (num), 0); + sig->print = signal_print_update (target_signal_from_host (num), 0); +} + + +static void +check_all_signal_numbers () +{ + /* If this isn't a LinuxThreads program, quit early. */ + if (! linuxthreads_max) + return; + + check_signal_number (&linuxthreads_sig_restart); + check_signal_number (&linuxthreads_sig_cancel); + check_signal_number (&linuxthreads_sig_debug); + + /* handle linuxthread exit */ + if (linuxthreads_sig_debug.signal + || linuxthreads_sig_restart.signal) + { + struct sigaction sact; + + sact.sa_handler = sigchld_handler; + sigemptyset(&sact.sa_mask); + sact.sa_flags = 0; + if (linuxthreads_sig_debug.signal > 0) + sigaction(linuxthreads_sig_cancel.signal, &sact, NULL); + else + sigaction(linuxthreads_sig_restart.signal, &sact, NULL); + } +} + + +/* Restore GDB's original settings for SIG. + This should only be called when we're no longer sure if we're + talking to an executable that uses LinuxThreads, so we clear the + signal number and variable address too. */ +static void +restore_signal (sig) + struct linuxthreads_signal *sig; +{ + if (! sig->signal) + return; + + /* We know sig->signal was non-zero, and is becoming zero, so it's + okay to restore GDB's original settings. */ + signal_stop_update (target_signal_from_host (sig->signal), sig->stop); + signal_print_update (target_signal_from_host (sig->signal), sig->print); + + sig->signal = 0; + sig->addr = 0; +} + + +/* Restore GDB's original settings for all LinuxThreads signals. + This should only be called when we're no longer sure if we're + talking to an executable that uses LinuxThreads, so we clear the + signal number and variable address too. */ +static void +restore_all_signals () +{ + restore_signal (&linuxthreads_sig_restart); + restore_signal (&linuxthreads_sig_cancel); + restore_signal (&linuxthreads_sig_debug); + + /* If it happens again, we should complain again. */ + complained_cannot_determine_thread_signal_number = 0; +} + + + + +/* Apply FUNC to the pid of each active thread. This consults the + inferior's handle table to find active threads. + + If ALL is non-zero, process all threads. + If ALL is zero, skip threads with pending status. */ +static void +iterate_active_threads (func, all) + void (*func)(int); + int all; +{ + CORE_ADDR descr; + int pid; + int i; + int num; + + read_memory (linuxthreads_num, (char *)&num, sizeof (int)); + + for (i = 0; i < linuxthreads_max && num > 0; i++) + { + read_memory (linuxthreads_handles + + linuxthreads_sizeof_handle * i + linuxthreads_offset_descr, + (char *)&descr, sizeof (void *)); + if (descr) + { + num--; + read_memory (descr + linuxthreads_offset_pid, + (char *)&pid, sizeof (pid_t)); + if (pid > 0 && pid != linuxthreads_manager_pid + && (all || (!linuxthreads_pending_status (pid)))) + (*func)(pid); + } + } + +} + +/* Insert a thread breakpoint at linuxthreads_breakpoint_addr. + This is the worker function for linuxthreads_insert_breakpoint, + which passes it to iterate_active_threads. */ +static void +insert_breakpoint (pid) + int pid; +{ + int j; + + /* Remove (if any) the positive zombie breakpoint. */ + for (j = linuxthreads_breakpoint_last; j >= 0; j--) + if (linuxthreads_breakpoint_zombie[j].pid == pid) + { + if ((linuxthreads_breakpoint_zombie[j].pc - DECR_PC_AFTER_BREAK + == linuxthreads_breakpoint_addr) + && !linuxthreads_breakpoint_zombie[j].step) + REMOVE_BREAKPOINT_ZOMBIE(j); + break; + } +} + +/* Note that we're about to remove a thread breakpoint at + linuxthreads_breakpoint_addr. + + This is the worker function for linuxthreads_remove_breakpoint, + which passes it to iterate_active_threads. The actual work of + overwriting the breakpoint instruction is done by + child_ops.to_remove_breakpoint; here, we simply create a zombie + breakpoint if the thread's PC is pointing at the breakpoint being + removed. */ +static void +remove_breakpoint (pid) + int pid; +{ + int j; + + /* Insert a positive zombie breakpoint (if needed). */ + for (j = 0; j <= linuxthreads_breakpoint_last; j++) + if (linuxthreads_breakpoint_zombie[j].pid == pid) + break; + + if (in_thread_list (pid) && linuxthreads_thread_alive (pid)) + { + CORE_ADDR pc = read_pc_pid (pid); + if (linuxthreads_breakpoint_addr == pc - DECR_PC_AFTER_BREAK + && j > linuxthreads_breakpoint_last) + { + linuxthreads_breakpoint_zombie[j].pid = pid; + linuxthreads_breakpoint_zombie[j].pc = pc; + linuxthreads_breakpoint_zombie[j].step = 0; + linuxthreads_breakpoint_last++; + } + } +} + +/* Kill a thread */ +static void +kill_thread (pid) + int pid; +{ + if (in_thread_list (pid)) + ptrace (PT_KILL, pid, (PTRACE_ARG3_TYPE) 0, 0); + else + kill (pid, SIGKILL); +} + +/* Resume a thread */ +static void +resume_thread (pid) + int pid; +{ + if (pid != inferior_pid + && in_thread_list (pid) + && linuxthreads_thread_alive (pid)) + if (pid == linuxthreads_step_pid) + child_resume (pid, 1, linuxthreads_step_signo); + else + child_resume (pid, 0, TARGET_SIGNAL_0); +} + +/* Detach a thread */ +static void +detach_thread (pid) + int pid; +{ + if (in_thread_list (pid) && linuxthreads_thread_alive (pid)) + { + /* Remove pending SIGTRAP and SIGSTOP */ + linuxthreads_find_trap (pid, 1); + + inferior_pid = pid; + detach (TARGET_SIGNAL_0); + inferior_pid = linuxthreads_manager_pid; + } +} + +/* Stop a thread */ +static void +stop_thread (pid) + int pid; +{ + if (pid != inferior_pid) + if (in_thread_list (pid)) + kill (pid, SIGSTOP); + else if (ptrace (PT_ATTACH, pid, (PTRACE_ARG3_TYPE) 0, 0) == 0) + { + if (!linuxthreads_attach_pending) + printf_unfiltered ("[New %s]\n", target_pid_to_str (pid)); + add_thread (pid); + if (linuxthreads_sig_debug.signal) + /* After a new thread in glibc 2.1 signals gdb its existence, + it suspends itself and wait for linuxthreads_sig_restart, + now we can wake up it. */ + kill (pid, linuxthreads_sig_restart.signal); + } + else + perror_with_name ("ptrace in stop_thread"); +} + +/* Wait for a thread */ +static void +wait_thread (pid) + int pid; +{ + int status; + int rpid; + + if (pid != inferior_pid && in_thread_list (pid)) + { + for (;;) + { + /* Get first pid status. */ + rpid = waitpid(pid, &status, __WCLONE); + if (rpid > 0) + break; + if (errno == EINTR) + continue; + + /* There are two reasons this might have failed: + + 1) PID is the initial thread, which wasn't cloned, so + passing the __WCLONE flag to waitpid prevented us from + finding it. + + 2) The manager thread is the parent of all but the + initial thread; if it dies, the children will all be + reparented to init, which will wait for them. This means + our call to waitpid won't find them. + + Actually, based on a casual look at the 2.0.36 kernel + code, I don't think either of these cases happen. But I + don't have things set up for remotely debugging the + kernel, so I'm not sure. And perhaps older kernels + didn't work. */ + rpid = waitpid(pid, &status, 0); + if (rpid > 0) + break; + if (errno != EINTR && linuxthreads_thread_alive (pid)) + perror_with_name ("waitpid"); + + /* the thread is dead. */ + return; + } + if (!WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP) + { + linuxthreads_wait_pid[++linuxthreads_wait_last] = pid; + linuxthreads_wait_status[linuxthreads_wait_last] = status; + } + } +} + +/* Walk through the linuxthreads handles in order to detect all + threads and stop them */ +static void +update_stop_threads (test_pid) + int test_pid; +{ + struct cleanup *old_chain = NULL; + + check_all_signal_numbers (); + + if (linuxthreads_manager_pid == 0) + { + if (linuxthreads_manager) + { + if (test_pid > 0 && test_pid != inferior_pid) + { + old_chain = save_inferior_pid (); + inferior_pid = test_pid; + } + read_memory (linuxthreads_manager, + (char *)&linuxthreads_manager_pid, sizeof (pid_t)); + } + if (linuxthreads_initial) + { + if (test_pid > 0 && test_pid != inferior_pid) + { + old_chain = save_inferior_pid (); + inferior_pid = test_pid; + } + read_memory(linuxthreads_initial, + (char *)&linuxthreads_initial_pid, sizeof (pid_t)); + } + } + + if (linuxthreads_manager_pid != 0) + { + if (old_chain == NULL && test_pid > 0 && + test_pid != inferior_pid && linuxthreads_thread_alive (test_pid)) + { + old_chain = save_inferior_pid (); + inferior_pid = test_pid; + } + + if (linuxthreads_thread_alive (inferior_pid)) + { + if (test_pid > 0) + { + if (test_pid != linuxthreads_manager_pid + && !linuxthreads_pending_status (linuxthreads_manager_pid)) + { + stop_thread (linuxthreads_manager_pid); + wait_thread (linuxthreads_manager_pid); + } + if (!in_thread_list (test_pid)) + { + if (!linuxthreads_attach_pending) + printf_unfiltered ("[New %s]\n", + target_pid_to_str (test_pid)); + add_thread (test_pid); + if (linuxthreads_sig_debug.signal + && inferior_pid == test_pid) + /* After a new thread in glibc 2.1 signals gdb its + existence, it suspends itself and wait for + linuxthreads_sig_restart, now we can wake up + it. */ + kill (test_pid, linuxthreads_sig_restart.signal); + } + } + iterate_active_threads (stop_thread, 0); + iterate_active_threads (wait_thread, 0); + } + } + + if (old_chain != NULL) + do_cleanups (old_chain); +} + +/* This routine is called whenever a new symbol table is read in, or when all + symbol tables are removed. libpthread can only be initialized when it + finds the right variables in libpthread.so. Since it's a shared library, + those variables don't show up until the library gets mapped and the symbol + table is read in. */ + +void +linuxthreads_new_objfile (objfile) + struct objfile *objfile; +{ + struct minimal_symbol *ms; + + if (!objfile) + { + /* We're starting an entirely new executable, so we can no + longer be sure that it uses LinuxThreads. Restore the signal + flags to their original states. */ + restore_all_signals (); + + /* Indicate that we don't know anything's address any more. */ + linuxthreads_max = 0; + + return; + } + + /* If we've already found our variables in another objfile, don't + bother looking for them again. */ + if (linuxthreads_max) + return; + + if (! lookup_minimal_symbol ("__pthread_initial_thread", NULL, objfile)) + /* This object file isn't the pthreads library. */ + return; + + if ((ms = lookup_minimal_symbol ("__pthread_threads_debug", + NULL, objfile)) == NULL) + { + /* The debugging-aware libpthreads is not present in this objfile */ + warning ("\ +This program seems to use POSIX threads, but the thread library used\n\ +does not support debugging. This may make using GDB difficult. Don't\n\ +set breakpoints or single-step through code that might be executed by\n\ +any thread other than the main thread."); + return; + } + linuxthreads_debug = SYMBOL_VALUE_ADDRESS (ms); + + /* Read internal structures configuration */ + if ((ms = lookup_minimal_symbol ("__pthread_sizeof_handle", + NULL, objfile)) == NULL + || target_read_memory (SYMBOL_VALUE_ADDRESS (ms), + (char *)&linuxthreads_sizeof_handle, + sizeof (linuxthreads_sizeof_handle)) != 0) + { + fprintf_unfiltered (gdb_stderr, + "Unable to find linuxthreads symbol \"%s\"\n", + "__pthread_sizeof_handle"); + return; + } + + if ((ms = lookup_minimal_symbol ("__pthread_offsetof_descr", + NULL, objfile)) == NULL + || target_read_memory (SYMBOL_VALUE_ADDRESS (ms), + (char *)&linuxthreads_offset_descr, + sizeof (linuxthreads_offset_descr)) != 0) + { + fprintf_unfiltered (gdb_stderr, + "Unable to find linuxthreads symbol \"%s\"\n", + "__pthread_offsetof_descr"); + return; + } + + if ((ms = lookup_minimal_symbol ("__pthread_offsetof_pid", + NULL, objfile)) == NULL + || target_read_memory (SYMBOL_VALUE_ADDRESS (ms), + (char *)&linuxthreads_offset_pid, + sizeof (linuxthreads_offset_pid)) != 0) + { + fprintf_unfiltered (gdb_stderr, + "Unable to find linuxthreads symbol \"%s\"\n", + "__pthread_offsetof_pid"); + return; + } + + if (! find_all_signal_vars (objfile)) + return; + + /* Read adresses of internal structures to access */ + if ((ms = lookup_minimal_symbol ("__pthread_handles", + NULL, objfile)) == NULL) + { + fprintf_unfiltered (gdb_stderr, + "Unable to find linuxthreads symbol \"%s\"\n", + "__pthread_handles"); + return; + } + linuxthreads_handles = SYMBOL_VALUE_ADDRESS (ms); + + if ((ms = lookup_minimal_symbol ("__pthread_handles_num", + NULL, objfile)) == NULL) + { + fprintf_unfiltered (gdb_stderr, + "Unable to find linuxthreads symbol \"%s\"\n", + "__pthread_handles_num"); + return; + } + linuxthreads_num = SYMBOL_VALUE_ADDRESS (ms); + + if ((ms = lookup_minimal_symbol ("__pthread_manager_thread", + NULL, objfile)) == NULL) + { + fprintf_unfiltered (gdb_stderr, + "Unable to find linuxthreads symbol \"%s\"\n", + "__pthread_manager_thread"); + return; + } + linuxthreads_manager = SYMBOL_VALUE_ADDRESS (ms) + linuxthreads_offset_pid; + + if ((ms = lookup_minimal_symbol ("__pthread_initial_thread", + NULL, objfile)) == NULL) + { + fprintf_unfiltered (gdb_stderr, + "Unable to find linuxthreads symbol \"%s\"\n", + "__pthread_initial_thread"); + return; + } + linuxthreads_initial = SYMBOL_VALUE_ADDRESS (ms) + linuxthreads_offset_pid; + + /* Search for this last, so it won't be set to a non-zero value unless + we successfully found all the symbols above. */ + if ((ms = lookup_minimal_symbol ("__pthread_threads_max", + NULL, objfile)) == NULL + || target_read_memory (SYMBOL_VALUE_ADDRESS (ms), + (char *)&linuxthreads_max, + sizeof (linuxthreads_max)) != 0) + { + fprintf_unfiltered (gdb_stderr, + "Unable to find linuxthreads symbol \"%s\"\n", + "__pthread_threads_max"); + return; + } + + /* Allocate gdb internal structures */ + linuxthreads_wait_pid = + (int *) xmalloc (sizeof (int) * (linuxthreads_max + 1)); + linuxthreads_wait_status = + (int *) xmalloc (sizeof (int) * (linuxthreads_max + 1)); + linuxthreads_breakpoint_zombie = (struct linuxthreads_breakpoint *) + xmalloc (sizeof (struct linuxthreads_breakpoint) * (linuxthreads_max + 1)); + + if (inferior_pid && !linuxthreads_attach_pending) + { + int on = 1; + target_write_memory (linuxthreads_debug, (char *)&on, sizeof (on)); + linuxthreads_attach_pending = 1; + update_stop_threads (inferior_pid); + linuxthreads_attach_pending = 0; + } +} + +/* If we have switched threads from a one that stopped at breakpoint, + return 1 otherwise 0. */ + +int +linuxthreads_prepare_to_proceed (step) + int step; +{ + if (!linuxthreads_max + || !linuxthreads_manager_pid + || !linuxthreads_breakpoint_pid + || !breakpoint_here_p (read_pc_pid (linuxthreads_breakpoint_pid))) + return 0; + + if (step) + { + /* Mark the current inferior as single stepping process. */ + linuxthreads_step_pid = inferior_pid; + } + + linuxthreads_inferior_pid = linuxthreads_breakpoint_pid; + return linuxthreads_breakpoint_pid; +} + +/* Convert a pid to printable form. */ + +char * +linuxthreads_pid_to_str (pid) + int pid; +{ + static char buf[100]; + + sprintf (buf, "%s %d%s", linuxthreads_max ? "Thread" : "Pid", pid, + (pid == linuxthreads_manager_pid) ? " (manager thread)" + : (pid == linuxthreads_initial_pid) ? " (initial thread)" + : ""); + + return buf; +} + +/* Attach to process PID, then initialize for debugging it + and wait for the trace-trap that results from attaching. */ + +static void +linuxthreads_attach (args, from_tty) + char *args; + int from_tty; +{ + if (!args) + error_no_arg ("process-id to attach"); + + push_target (&linuxthreads_ops); + linuxthreads_breakpoints_inserted = 1; + linuxthreads_breakpoint_last = -1; + linuxthreads_wait_last = -1; + linuxthreads_exit_status = __W_STOPCODE(0); + + child_ops.to_attach (args, from_tty); + + if (linuxthreads_max) + linuxthreads_attach_pending = 1; +} + +/* Take a program previously attached to and detaches it. + The program resumes execution and will no longer stop + on signals, etc. We'd better not have left any breakpoints + in the program or it'll die when it hits one. For this + to work, it may be necessary for the process to have been + previously attached. It *might* work if the program was + started via the normal ptrace (PTRACE_TRACEME). */ + +static void +linuxthreads_detach (args, from_tty) + char *args; + int from_tty; +{ + if (linuxthreads_max) + { + int i; + int pid; + int off = 0; + target_write_memory (linuxthreads_debug, (char *)&off, sizeof (off)); + + /* Walk through linuxthreads array in order to detach known threads. */ + if (linuxthreads_manager_pid != 0) + { + /* Get rid of all positive zombie breakpoints. */ + for (i = 0; i <= linuxthreads_breakpoint_last; i++) + { + if (linuxthreads_breakpoint_zombie[i].step) + continue; + + pid = linuxthreads_breakpoint_zombie[i].pid; + if (!linuxthreads_thread_alive (pid)) + continue; + + if (linuxthreads_breakpoint_zombie[i].pc != read_pc_pid (pid)) + continue; + + /* Continue in STEP mode until the thread pc has moved or + until SIGTRAP is found on the same PC. */ + if (linuxthreads_find_trap (pid, 0) + && linuxthreads_breakpoint_zombie[i].pc == read_pc_pid (pid)) + write_pc_pid (linuxthreads_breakpoint_zombie[i].pc + - DECR_PC_AFTER_BREAK, pid); + } + + /* Detach thread after thread. */ + inferior_pid = linuxthreads_manager_pid; + iterate_active_threads (detach_thread, 1); + + /* Remove pending SIGTRAP and SIGSTOP */ + linuxthreads_find_trap (inferior_pid, 1); + + linuxthreads_wait_last = -1; + linuxthreads_exit_status = __W_STOPCODE(0); + } + + linuxthreads_inferior_pid = 0; + linuxthreads_breakpoint_pid = 0; + linuxthreads_step_pid = 0; + linuxthreads_step_signo = TARGET_SIGNAL_0; + linuxthreads_manager_pid = 0; + linuxthreads_initial_pid = 0; + linuxthreads_attach_pending = 0; + init_thread_list (); /* Destroy thread info */ + } + + child_ops.to_detach (args, from_tty); + + unpush_target (&linuxthreads_ops); +} + +/* Resume execution of process PID. If STEP is nozero, then + just single step it. If SIGNAL is nonzero, restart it with that + signal activated. */ + +static void +linuxthreads_resume (pid, step, signo) + int pid; + int step; + enum target_signal signo; +{ + if (!linuxthreads_max || stop_soon_quietly || linuxthreads_manager_pid == 0) + child_ops.to_resume (pid, step, signo); + else + { + int rpid; + if (linuxthreads_inferior_pid) + { + /* Prepare resume of the last thread that hit a breakpoint */ + linuxthreads_breakpoints_inserted = 0; + rpid = linuxthreads_inferior_pid; + linuxthreads_step_signo = signo; + } + else + { + struct cleanup *old_chain = NULL; + int i; + + if (pid < 0) + { + linuxthreads_step_pid = step ? inferior_pid : 0; + linuxthreads_step_signo = signo; + rpid = inferior_pid; + } + else + rpid = pid; + + if (pid < 0 || !step) + { + linuxthreads_breakpoints_inserted = 1; + + /* Walk through linuxthreads array in order to resume threads */ + if (pid >= 0 && inferior_pid != pid) + { + old_chain = save_inferior_pid (); + inferior_pid = pid; + } + + iterate_active_threads (resume_thread, 0); + if (linuxthreads_manager_pid != inferior_pid + && !linuxthreads_pending_status (linuxthreads_manager_pid)) + resume_thread (linuxthreads_manager_pid); + } + else + linuxthreads_breakpoints_inserted = 0; + + /* Deal with zombie breakpoint */ + for (i = 0; i <= linuxthreads_breakpoint_last; i++) + if (linuxthreads_breakpoint_zombie[i].pid == rpid) + { + if (linuxthreads_breakpoint_zombie[i].pc != read_pc_pid (rpid)) + { + /* The current pc is out of zombie breakpoint. */ + REMOVE_BREAKPOINT_ZOMBIE(i); + } + break; + } + + if (old_chain != NULL) + do_cleanups (old_chain); + } + + /* Resume initial thread. */ + if (!linuxthreads_pending_status (rpid)) + child_ops.to_resume (rpid, step, signo); + } +} + +/* Wait for any threads to stop. We may have to convert PID from a thread id + to a LWP id, and vice versa on the way out. */ + +static int +linuxthreads_wait (pid, ourstatus) + int pid; + struct target_waitstatus *ourstatus; +{ + int status; + int rpid; + int i; + int last; + int *wstatus; + + if (linuxthreads_max && !linuxthreads_breakpoints_inserted) + wstatus = alloca (LINUXTHREAD_NSIG * sizeof (int)); + + /* See if the inferior has chosen values for its signals yet. By + checking for them here, we can be sure we've updated GDB's signal + handling table before the inferior ever gets one of them. (Well, + before we notice, anyway.) */ + check_all_signal_numbers (); + + for (;;) + { + if (!linuxthreads_max) + rpid = 0; + else if (!linuxthreads_breakpoints_inserted) + { + if (linuxthreads_inferior_pid) + pid = linuxthreads_inferior_pid; + else if (pid < 0) + pid = inferior_pid; + last = rpid = 0; + } + else if (pid < 0 && linuxthreads_wait_last >= 0) + { + status = linuxthreads_wait_status[linuxthreads_wait_last]; + rpid = linuxthreads_wait_pid[linuxthreads_wait_last--]; + } + else if (pid > 0 && linuxthreads_pending_status (pid)) + { + for (i = linuxthreads_wait_last; i >= 0; i--) + if (linuxthreads_wait_pid[i] == pid) + break; + if (i < 0) + rpid = 0; + else + { + status = linuxthreads_wait_status[i]; + rpid = pid; + if (i < linuxthreads_wait_last) + { + linuxthreads_wait_status[i] = + linuxthreads_wait_status[linuxthreads_wait_last]; + linuxthreads_wait_pid[i] = + linuxthreads_wait_pid[linuxthreads_wait_last]; + } + linuxthreads_wait_last--; + } + } + else + rpid = 0; + + if (rpid == 0) + { + int save_errno; + sigset_t omask; + + set_sigint_trap(); /* Causes SIGINT to be passed on to the + attached process. */ + set_sigio_trap (); + + sigprocmask(SIG_BLOCK, &linuxthreads_wait_mask, &omask); + for (;;) + { + rpid = waitpid (pid, &status, __WCLONE | WNOHANG); + if (rpid > 0) + break; + if (rpid == 0) + save_errno = 0; + else if (errno != EINTR) + save_errno = errno; + else + continue; + + rpid = waitpid (pid, &status, WNOHANG); + if (rpid > 0) + break; + if (rpid < 0) + if (errno == EINTR) + continue; + else if (save_errno != 0) + break; + + sigsuspend(&omask); + } + sigprocmask(SIG_SETMASK, &omask, NULL); + + save_errno = errno; + clear_sigio_trap (); + + clear_sigint_trap(); + + if (rpid == -1) + { + if (WIFEXITED(linuxthreads_exit_status)) + { + store_waitstatus (ourstatus, linuxthreads_exit_status); + return inferior_pid; + } + else + { + fprintf_unfiltered + (gdb_stderr, "Child process unexpectedly missing: %s.\n", + safe_strerror (save_errno)); + /* Claim it exited with unknown signal. */ + ourstatus->kind = TARGET_WAITKIND_SIGNALLED; + ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN; + return -1; + } + } + + /* Signals arrive in any order. So get all signals until SIGTRAP + and resend previous ones to be held after. */ + if (linuxthreads_max + && !linuxthreads_breakpoints_inserted + && WIFSTOPPED(status)) + if (WSTOPSIG(status) == SIGTRAP) + { + while (--last >= 0) + kill (rpid, WSTOPSIG(wstatus[last])); + + /* insert negative zombie breakpoint */ + for (i = 0; i <= linuxthreads_breakpoint_last; i++) + if (linuxthreads_breakpoint_zombie[i].pid == rpid) + break; + if (i > linuxthreads_breakpoint_last) + { + linuxthreads_breakpoint_zombie[i].pid = rpid; + linuxthreads_breakpoint_last++; + } + linuxthreads_breakpoint_zombie[i].pc = read_pc_pid (rpid); + linuxthreads_breakpoint_zombie[i].step = 1; + } + else + { + if (WSTOPSIG(status) != SIGSTOP) + { + for (i = 0; i < last; i++) + if (wstatus[i] == status) + break; + if (i >= last) + wstatus[last++] = status; + } + child_resume (rpid, 1, TARGET_SIGNAL_0); + continue; + } + if (linuxthreads_inferior_pid) + linuxthreads_inferior_pid = 0; + } + + if (linuxthreads_max && !stop_soon_quietly) + { + if (linuxthreads_max + && WIFSTOPPED(status) + && WSTOPSIG(status) == SIGSTOP) + { + /* Skip SIGSTOP signals. */ + if (!linuxthreads_pending_status (rpid)) + if (linuxthreads_step_pid == rpid) + child_resume (rpid, 1, linuxthreads_step_signo); + else + child_resume (rpid, 0, TARGET_SIGNAL_0); + continue; + } + + /* Do no report exit status of cloned threads. */ + if (WIFEXITED(status)) + { + if (rpid == linuxthreads_initial_pid) + linuxthreads_exit_status = status; + + /* Remove any zombie breakpoint. */ + for (i = 0; i <= linuxthreads_breakpoint_last; i++) + if (linuxthreads_breakpoint_zombie[i].pid == rpid) + { + REMOVE_BREAKPOINT_ZOMBIE(i); + break; + } + if (pid > 0) + pid = -1; + continue; + } + + /* Deal with zombie breakpoint */ + for (i = 0; i <= linuxthreads_breakpoint_last; i++) + if (linuxthreads_breakpoint_zombie[i].pid == rpid) + break; + + if (i <= linuxthreads_breakpoint_last) + { + /* There is a potential zombie breakpoint */ + if (WIFEXITED(status) + || linuxthreads_breakpoint_zombie[i].pc != read_pc_pid (rpid)) + { + /* The current pc is out of zombie breakpoint. */ + REMOVE_BREAKPOINT_ZOMBIE(i); + } + else if (!linuxthreads_breakpoint_zombie[i].step + && WIFSTOPPED(status) && WSTOPSIG(status) == SIGTRAP) + { + /* This is a real one ==> decrement PC and restart. */ + write_pc_pid (linuxthreads_breakpoint_zombie[i].pc + - DECR_PC_AFTER_BREAK, rpid); + if (linuxthreads_step_pid == rpid) + child_resume (rpid, 1, linuxthreads_step_signo); + else + child_resume (rpid, 0, TARGET_SIGNAL_0); + continue; + } + } + + /* Walk through linuxthreads array in order to stop them */ + if (linuxthreads_breakpoints_inserted) + update_stop_threads (rpid); + + } + else if (rpid != inferior_pid) + continue; + + store_waitstatus (ourstatus, status); + + if (linuxthreads_attach_pending && !stop_soon_quietly) + { + int on = 1; + target_write_memory (linuxthreads_debug, (char *)&on, sizeof (on)); + update_stop_threads (rpid); + linuxthreads_attach_pending = 0; + } + + if (linuxthreads_breakpoints_inserted + && WIFSTOPPED(status) + && WSTOPSIG(status) == SIGTRAP) + linuxthreads_breakpoint_pid = rpid; + else if (linuxthreads_breakpoint_pid) + linuxthreads_breakpoint_pid = 0; + + return rpid; + } +} + +/* Fork an inferior process, and start debugging it with ptrace. */ + +static void +linuxthreads_create_inferior (exec_file, allargs, env) + char *exec_file; + char *allargs; + char **env; +{ + if (!exec_file && !exec_bfd) + { + error ("No executable file specified.\n\ +Use the \"file\" or \"exec-file\" command."); + return; + } + + push_target (&linuxthreads_ops); + linuxthreads_breakpoints_inserted = 1; + linuxthreads_breakpoint_last = -1; + linuxthreads_wait_last = -1; + linuxthreads_exit_status = __W_STOPCODE(0); + + if (linuxthreads_max) + linuxthreads_attach_pending = 1; + + child_ops.to_create_inferior (exec_file, allargs, env); +} + +/* Clean up after the inferior dies. */ + +static void +linuxthreads_mourn_inferior () +{ + if (linuxthreads_max) + { + int off = 0; + target_write_memory (linuxthreads_debug, (char *)&off, sizeof (off)); + + linuxthreads_inferior_pid = 0; + linuxthreads_breakpoint_pid = 0; + linuxthreads_step_pid = 0; + linuxthreads_step_signo = TARGET_SIGNAL_0; + linuxthreads_manager_pid = 0; + linuxthreads_initial_pid = 0; + linuxthreads_attach_pending = 0; + init_thread_list(); /* Destroy thread info */ + } + + child_ops.to_mourn_inferior (); + + unpush_target (&linuxthreads_ops); +} + +/* Kill the inferior process */ + +static void +linuxthreads_kill () +{ + int rpid; + int status; + + if (inferior_pid == 0) + return; + + if (linuxthreads_max && linuxthreads_manager_pid != 0) + { + /* Remove all threads status. */ + inferior_pid = linuxthreads_manager_pid; + iterate_active_threads (kill_thread, 1); + } + + kill_thread (inferior_pid); + +#if 0 + /* doing_quit_force solves a real problem, but I think a properly + placed call to catch_errors would do the trick much more cleanly. */ + if (doing_quit_force >= 0) + { + if (linuxthreads_max && linuxthreads_manager_pid != 0) + { + /* Wait for thread to complete */ + while ((rpid = waitpid (-1, &status, __WCLONE)) > 0) + if (!WIFEXITED(status)) + kill_thread (rpid); + + while ((rpid = waitpid (-1, &status, 0)) > 0) + if (!WIFEXITED(status)) + kill_thread (rpid); + } + else + while ((rpid = waitpid (inferior_pid, &status, 0)) > 0) + if (!WIFEXITED(status)) + ptrace (PT_KILL, inferior_pid, (PTRACE_ARG3_TYPE) 0, 0); + } +#endif + + /* Wait for all threads. */ + do + rpid = waitpid (-1, &status, __WCLONE | WNOHANG); + while (rpid > 0 || errno == EINTR); + + do + rpid = waitpid (-1, &status, WNOHANG); + while (rpid > 0 || errno == EINTR); + + linuxthreads_mourn_inferior (); +} + +/* Insert a breakpoint */ + +static int +linuxthreads_insert_breakpoint (addr, contents_cache) + CORE_ADDR addr; + char *contents_cache; +{ + if (linuxthreads_max && linuxthreads_manager_pid != 0) + { + linuxthreads_breakpoint_addr = addr; + iterate_active_threads (insert_breakpoint, 1); + insert_breakpoint (linuxthreads_manager_pid); + } + + return child_ops.to_insert_breakpoint (addr, contents_cache); +} + +/* Remove a breakpoint */ + +static int +linuxthreads_remove_breakpoint (addr, contents_cache) + CORE_ADDR addr; + char *contents_cache; +{ + if (linuxthreads_max && linuxthreads_manager_pid != 0) + { + linuxthreads_breakpoint_addr = addr; + iterate_active_threads (remove_breakpoint, 1); + remove_breakpoint (linuxthreads_manager_pid); + } + + return child_ops.to_remove_breakpoint (addr, contents_cache); +} + +/* Mark our target-struct as eligible for stray "run" and "attach" commands. */ + +static int +linuxthreads_can_run () +{ + return child_suppress_run; +} + +static void +init_linuxthreads_ops () +{ + linuxthreads_ops.to_shortname = "linuxthreads"; + linuxthreads_ops.to_longname = "LINUX threads and pthread."; + linuxthreads_ops.to_doc = "LINUX threads and pthread support."; + linuxthreads_ops.to_attach = linuxthreads_attach; + linuxthreads_ops.to_detach = linuxthreads_detach; + linuxthreads_ops.to_resume = linuxthreads_resume; + linuxthreads_ops.to_wait = linuxthreads_wait; + linuxthreads_ops.to_kill = linuxthreads_kill; + linuxthreads_ops.to_can_run = linuxthreads_can_run; + linuxthreads_ops.to_stratum = thread_stratum; + linuxthreads_ops.to_insert_breakpoint = linuxthreads_insert_breakpoint; + linuxthreads_ops.to_remove_breakpoint = linuxthreads_remove_breakpoint; + linuxthreads_ops.to_create_inferior = linuxthreads_create_inferior; + linuxthreads_ops.to_mourn_inferior = linuxthreads_mourn_inferior; + linuxthreads_ops.to_thread_alive = linuxthreads_thread_alive; + linuxthreads_ops.to_magic = OPS_MAGIC; +} + +void +_initialize_linuxthreads () +{ + struct sigaction sact; + + init_linuxthreads_ops (); + add_target (&linuxthreads_ops); + child_suppress_run = 1; + + /* Attach SIGCHLD handler */ + sact.sa_handler = sigchld_handler; + sigemptyset (&sact.sa_mask); + sact.sa_flags = 0; + sigaction (SIGCHLD, &sact, NULL); + + /* initialize SIGCHLD mask */ + sigemptyset (&linuxthreads_wait_mask); + sigaddset (&linuxthreads_wait_mask, SIGCHLD); +} diff --git a/gdb/m32r-rom.c b/gdb/m32r-rom.c index bbcc1c0..f6ea251 100644 --- a/gdb/m32r-rom.c +++ b/gdb/m32r-rom.c @@ -35,7 +35,8 @@ #include <time.h> /* for time_t */ #include "gdb_string.h" #include "objfiles.h" /* for ALL_OBJFILES etc. */ - +#include "inferior.h" /* for write_pc() */ +#include <ctype.h> extern void report_transfer_performance PARAMS ((unsigned long, time_t, time_t)); @@ -79,7 +80,7 @@ m32r_load_section (abfd, s, data_count) print_address_numeric (section_base, 1, gdb_stdout); printf_filtered ("\n"); gdb_flush (gdb_stdout); - monitor_printf ("%x mw\r", section_base); + monitor_printf ("%s mw\r", paddr_nz (section_base)); for (i = 0; i < section_size; i += 4) { QUIT; diff --git a/gdb/m32r-stub.c b/gdb/m32r-stub.c index 56ae5ef..bc5e599 100644 --- a/gdb/m32r-stub.c +++ b/gdb/m32r-stub.c @@ -179,7 +179,7 @@ extern void breakpoint(void); static int computeSignal(int); static void putpacket(unsigned char *); -static unsigned char *getpacket(unsigned char *); +static unsigned char *getpacket(void); static unsigned char *mem2hex(unsigned char *, unsigned char *, int, int); static unsigned char *hex2mem(unsigned char *, unsigned char *, int, int); @@ -310,7 +310,7 @@ handle_exception(int exceptionVector) while (1==1) { remcomOutBuffer[0] = 0; - ptr = getpacket(remcomInBuffer); + ptr = getpacket(); binary = 0; switch (*ptr++) { default: /* Unknown code. Return an empty reply message. */ @@ -575,9 +575,9 @@ hex(ch) /* scan for the sequence $<data>#<checksum> */ unsigned char * -getpacket (buffer) - unsigned char *buffer; +getpacket () { + unsigned char *buffer = &remcomInBuffer[0]; unsigned char checksum; unsigned char xmitcsum; int count; diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c index 476dcf3..a4a791b 100644 --- a/gdb/m32r-tdep.c +++ b/gdb/m32r-tdep.c @@ -514,9 +514,9 @@ m32r_frame_chain (fi) return 0; /* in _start fn, don't chain further */ if (fi->framesize == 0) { - printf_filtered ("cannot determine frame size @ %08x , pc(%08x)\n", - (unsigned long) fi->frame, - (unsigned long) fi->pc); + printf_filtered ("cannot determine frame size @ %s , pc(%s)\n", + paddr (fi->frame), + paddr (fi->pc)); return 0; } insn_debug (("m32rx frame %08x\n", fi->frame + fi->framesize)); diff --git a/gdb/m68k-stub.c b/gdb/m68k-stub.c index 97adaba..3915fda 100644 --- a/gdb/m68k-stub.c +++ b/gdb/m68k-stub.c @@ -522,10 +522,15 @@ char ch; return (-1); } +static char remcomInBuffer[BUFMAX]; +static char remcomOutBuffer[BUFMAX]; +/* scan for the sequence $<data>#<checksum> */ + unsigned char * -getpacket (unsigned char *buffer) +getpacket () { + unsigned char *buffer = &remcomInBuffer[0]; unsigned char checksum; unsigned char xmitcsum; int count; @@ -622,11 +627,6 @@ char * buffer; } -char remcomInBuffer[BUFMAX]; -char remcomOutBuffer[BUFMAX]; -static short error; - - void debug_error(format, parm) char * format; char * parm; @@ -777,9 +777,8 @@ void handle_exception(int exceptionVector) stepping = 0; while (1==1) { - error = 0; remcomOutBuffer[0] = 0; - ptr = getpacket(remcomInBuffer); + ptr = getpacket(); switch (*ptr++) { case '?' : remcomOutBuffer[0] = 'S'; remcomOutBuffer[1] = hexchars[sigval >> 4]; @@ -119,8 +119,6 @@ main (argc, argv) long time_at_startup = get_run_time (); - int gdb_file_size; - START_PROGRESS (argv[0], 0); #ifdef MPW diff --git a/gdb/maint.c b/gdb/maint.c index c257613..725c6c5 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -347,13 +347,13 @@ maintenance_translate_address (arg, from_tty) sym = lookup_minimal_symbol_by_pc (address); if (sym) - printf_filtered ("%s+%u\n", + printf_filtered ("%s+%s\n", SYMBOL_SOURCE_NAME (sym), - address - SYMBOL_VALUE_ADDRESS (sym)); + paddr_u (address - SYMBOL_VALUE_ADDRESS (sym))); else if (sect) - printf_filtered ("no symbol at %s:0x%08x\n", sect->name, address); + printf_filtered ("no symbol at %s:0x%s\n", sect->name, paddr (address)); else - printf_filtered ("no symbol at 0x%08x\n", address); + printf_filtered ("no symbol at 0x%s\n", paddr (address)); return; } diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 44f61bf..085cd09 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -353,8 +353,7 @@ static int upgrade_type PARAMS ((int, struct type **, int, union aux_ext *, int, char *)); static void -parse_partial_symbols PARAMS ((struct objfile *, - struct section_offsets *)); +parse_partial_symbols PARAMS ((struct objfile *)); static FDR * get_rfd PARAMS ((int, int)); @@ -407,7 +406,7 @@ static int compare_blocks PARAMS ((const void *, const void *)); static struct partial_symtab * - new_psymtab PARAMS ((char *, struct objfile *, struct section_offsets *)); + new_psymtab PARAMS ((char *, struct objfile *)); static void psymtab_to_symtab_1 PARAMS ((struct partial_symtab *, char *)); @@ -520,11 +519,10 @@ fdr_name (f) different sections are relocated via the SECTION_OFFSETS. */ void -mdebug_build_psymtabs (objfile, swap, info, section_offsets) +mdebug_build_psymtabs (objfile, swap, info) struct objfile *objfile; const struct ecoff_debug_swap *swap; struct ecoff_debug_info *info; - struct section_offsets *section_offsets; { cur_bfd = objfile->obfd; debug_swap = swap; @@ -548,7 +546,7 @@ mdebug_build_psymtabs (objfile, swap, info, section_offsets) (*swap->swap_fdr_in) (objfile->obfd, fdr_src, fdr_ptr); } - parse_partial_symbols (objfile, section_offsets); + parse_partial_symbols (objfile); #if 0 /* Check to make sure file was compiled with -g. If not, warn the @@ -2274,9 +2272,8 @@ parse_lines (fh, pr, lt, maxlines, pst, lowest_pdr_addr) into a partial_symtab. */ static void -parse_partial_symbols (objfile, section_offsets) +parse_partial_symbols (objfile) struct objfile *objfile; - struct section_offsets *section_offsets; { const bfd_size_type external_sym_size = debug_swap->external_sym_size; const bfd_size_type external_rfd_size = debug_swap->external_rfd_size; @@ -2363,7 +2360,7 @@ parse_partial_symbols (objfile, section_offsets) old_chain = make_cleanup (free, fdr_to_pst); fdr_to_pst++; { - struct partial_symtab *pst = new_psymtab ("", objfile, section_offsets); + struct partial_symtab *pst = new_psymtab ("", objfile); fdr_to_pst[-1].pst = pst; FDR_IDX (pst) = -1; } @@ -2477,12 +2474,12 @@ parse_partial_symbols (objfile, section_offsets) { case stProc: /* Beginnning of Procedure */ - svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT); + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); break; case stStaticProc: /* Load time only static procs */ ms_type = mst_file_text; - svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT); + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); break; case stGlobal: /* External symbol */ @@ -2495,12 +2492,12 @@ parse_partial_symbols (objfile, section_offsets) else if (SC_IS_DATA (ext_in->asym.sc)) { ms_type = mst_data; - svalue += ANOFFSET (section_offsets, SECT_OFF_DATA); + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA); } else if (SC_IS_BSS (ext_in->asym.sc)) { ms_type = mst_bss; - svalue += ANOFFSET (section_offsets, SECT_OFF_BSS); + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS); } else ms_type = mst_abs; @@ -2510,17 +2507,17 @@ parse_partial_symbols (objfile, section_offsets) if (SC_IS_TEXT (ext_in->asym.sc)) { ms_type = mst_file_text; - svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT); + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); } else if (SC_IS_DATA (ext_in->asym.sc)) { ms_type = mst_file_data; - svalue += ANOFFSET (section_offsets, SECT_OFF_DATA); + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA); } else if (SC_IS_BSS (ext_in->asym.sc)) { ms_type = mst_file_bss; - svalue += ANOFFSET (section_offsets, SECT_OFF_BSS); + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS); } else ms_type = mst_abs; @@ -2564,11 +2561,11 @@ parse_partial_symbols (objfile, section_offsets) { textlow = fh->adr; if (relocatable || textlow != 0) - textlow += ANOFFSET (section_offsets, SECT_OFF_TEXT); + textlow += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); } else textlow = 0; - pst = start_psymtab_common (objfile, section_offsets, + pst = start_psymtab_common (objfile, objfile->section_offsets, fdr_name (fh), textlow, objfile->global_psymbols.next, @@ -2652,7 +2649,7 @@ parse_partial_symbols (objfile, section_offsets) CORE_ADDR procaddr; long isym; - sh.value += ANOFFSET (section_offsets, SECT_OFF_TEXT); + sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); if (sh.st == stStaticProc) { namestring = debug_info->ss + fh->issBase + sh.iss; @@ -2703,7 +2700,7 @@ parse_partial_symbols (objfile, section_offsets) case scPData: case scXData: namestring = debug_info->ss + fh->issBase + sh.iss; - sh.value += ANOFFSET (section_offsets, SECT_OFF_DATA); + sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA); prim_record_minimal_symbol_and_info (namestring, sh.value, mst_file_data, @@ -2717,7 +2714,7 @@ parse_partial_symbols (objfile, section_offsets) /* FIXME! Shouldn't this use cases for bss, then have the default be abs? */ namestring = debug_info->ss + fh->issBase + sh.iss; - sh.value += ANOFFSET (section_offsets, SECT_OFF_BSS); + sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS); prim_record_minimal_symbol_and_info (namestring, sh.value, mst_file_bss, @@ -2769,7 +2766,7 @@ parse_partial_symbols (objfile, section_offsets) namestring = stabstring #define CUR_SYMBOL_TYPE type_code #define CUR_SYMBOL_VALUE sh.value -#define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms)\ +#define START_PSYMTAB(ofile,fname,low,symoff,global_syms,static_syms)\ pst = save_pst #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set) (void)0 #define HANDLE_RBRAC(val) \ @@ -2821,18 +2818,18 @@ parse_partial_symbols (objfile, section_offsets) /* The value of a stEnd symbol is the displacement from the corresponding start symbol value, do not relocate it. */ if (sh.st != stEnd) - sh.value += ANOFFSET (section_offsets, SECT_OFF_TEXT); + sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); break; case scData: case scSData: case scRData: case scPData: case scXData: - sh.value += ANOFFSET (section_offsets, SECT_OFF_DATA); + sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA); break; case scBss: case scSBss: - sh.value += ANOFFSET (section_offsets, SECT_OFF_BSS); + sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS); break; } @@ -3029,18 +3026,18 @@ parse_partial_symbols (objfile, section_offsets) { case scText: case scRConst: - svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT); + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); break; case scData: case scSData: case scRData: case scPData: case scXData: - svalue += ANOFFSET (section_offsets, SECT_OFF_DATA); + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA); break; case scBss: case scSBss: - svalue += ANOFFSET (section_offsets, SECT_OFF_BSS); + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS); break; } @@ -3564,7 +3561,7 @@ psymtab_to_symtab_1 (pst, filename) (*swap_sym_in) (cur_bfd, sym_ptr, &sh); c = parse_symbol (&sh, debug_info->external_aux + fh->iauxBase, - sym_ptr, fh->fBigendian, pst->section_offsets); + sym_ptr, fh->fBigendian, pst->section_offsets); sym_ptr += c * external_sym_size; } @@ -4131,15 +4128,14 @@ new_symtab (name, maxsyms, maxlines, objfile) /* Allocate a new partial_symtab NAME */ static struct partial_symtab * -new_psymtab (name, objfile, section_offsets) +new_psymtab (name, objfile) char *name; struct objfile *objfile; - struct section_offsets *section_offsets; { struct partial_symtab *psymtab; psymtab = allocate_psymtab (name, objfile); - psymtab->section_offsets = section_offsets; + psymtab->section_offsets = objfile->section_offsets; /* Keep a backpointer to the file's symbols */ @@ -4288,11 +4284,10 @@ new_type (name) it as normal. */ void -elfmdebug_build_psymtabs (objfile, swap, sec, section_offsets) +elfmdebug_build_psymtabs (objfile, swap, sec) struct objfile *objfile; const struct ecoff_debug_swap *swap; asection *sec; - struct section_offsets *section_offsets; { bfd *abfd = objfile->obfd; struct ecoff_debug_info *info; @@ -4305,7 +4300,7 @@ elfmdebug_build_psymtabs (objfile, swap, sec, section_offsets) error ("Error reading ECOFF debugging information: %s", bfd_errmsg (bfd_get_error ())); - mdebug_build_psymtabs (objfile, swap, info, section_offsets); + mdebug_build_psymtabs (objfile, swap, info); } diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 786508e..b54b753 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -87,8 +87,6 @@ static CORE_ADDR heuristic_proc_start PARAMS ((CORE_ADDR)); static CORE_ADDR read_next_frame_reg PARAMS ((struct frame_info *, int)); -void mips_set_processor_type_command PARAMS ((char *, int)); - int mips_set_processor_type PARAMS ((char *)); static void mips_show_processor_type_command PARAMS ((char *, int)); @@ -247,9 +245,9 @@ mips_print_extra_frame_info (fi) && fi->extra_info && fi->extra_info->proc_desc && fi->extra_info->proc_desc->pdr.framereg < NUM_REGS) - printf_filtered (" frame pointer is at %s+%d\n", + printf_filtered (" frame pointer is at %s+%s\n", REGISTER_NAME (fi->extra_info->proc_desc->pdr.framereg), - fi->extra_info->proc_desc->pdr.frameoffset); + paddr_d (fi->extra_info->proc_desc->pdr.frameoffset)); } /* Convert between RAW and VIRTUAL registers. The RAW register size @@ -689,8 +687,8 @@ static void print_unpack (char *comment, struct upk_mips16 *u) { - printf ("%s %04x ,f(%d) off(%08x) (x(%x) y(%x)\n", - comment, u->inst, u->fmt, u->offset, u->regx, u->regy); + printf ("%s %04x ,f(%d) off(%s) (x(%x) y(%x)\n", + comment, u->inst, u->fmt, paddr (u->offset), u->regx, u->regy); } /* The EXT-I, EXT-ri nad EXT-I8 instructions all have the same diff --git a/gdb/mipsread.c b/gdb/mipsread.c index a388e76..d137a9a 100644 --- a/gdb/mipsread.c +++ b/gdb/mipsread.c @@ -104,7 +104,7 @@ mipscoff_symfile_read (objfile, mainline) error ("Error reading symbol table: %s", bfd_errmsg (bfd_get_error ())); mdebug_build_psymtabs (objfile, &ecoff_backend (abfd)->debug_swap, - &ecoff_data (abfd)->debug_info, objfile->section_offsets); + &ecoff_data (abfd)->debug_info); /* Add alpha coff dynamic symbols. */ diff --git a/gdb/mon960-rom.c b/gdb/mon960-rom.c index ab78b41..549be3e 100644 --- a/gdb/mon960-rom.c +++ b/gdb/mon960-rom.c @@ -28,7 +28,7 @@ #include "xmodem.h" #include "symtab.h" #include "symfile.h" /* for generic_load */ - +#include "inferior.h" /* for write_pc() */ #define USE_GENERIC_LOAD diff --git a/gdb/monitor.c b/gdb/monitor.c index 01fda27..1ef041d 100644 --- a/gdb/monitor.c +++ b/gdb/monitor.c @@ -143,6 +143,8 @@ static DCACHE *remote_dcache; static int first_time = 0; /* is this the first time we're executing after gaving created the child proccess? */ +#define TARGET_BUF_SIZE 2048 + /* Convert a string into a printable representation, Return # byte in the new string. */ @@ -217,8 +219,7 @@ monitor_error (format, memaddr, len, string, final_char) { int real_len = (len == 0 && string != (char *) 0) ? strlen (string) : len; char *safe_string = alloca ((real_len * 4) + 1); - char *p, *q; - int ch; + char *p; int safe_len = monitor_printable_string (safe_string, string); if (final_char) @@ -451,7 +452,6 @@ readchar (timeout) if (c >= 0) { c &= 0x7f; -#if 0 /* This seems to interfere with proper function of the input stream */ if (remote_debug > 0) @@ -462,7 +462,6 @@ readchar (timeout) puts_debug ("read -->", buf, "<--"); } -#endif } /* Canonicialize \n\r combinations into one \r */ @@ -634,8 +633,8 @@ monitor_expect_regexp (pat, buf, buflen) mybuf = buf; else { - mybuf = alloca (1024); - buflen = 1024; + mybuf = alloca (TARGET_BUF_SIZE); + buflen = TARGET_BUF_SIZE; } p = mybuf; @@ -905,14 +904,35 @@ monitor_supply_register (regno, valstr) int regno; char *valstr; { - unsigned int val; + ULONGEST val; unsigned char regbuf[MAX_REGISTER_RAW_SIZE]; char *p; - val = strtoul (valstr, &p, 16); + p = valstr; + while (p && *p != '\0') + { + if (*p == '\r' || *p == '\n') + { + while (*p != '\0') + p++; + break; + } + if (isspace (*p)) + { + p++; + continue; + } + if (!isxdigit (*p) && *p != 'x') + { + break; + } + + val <<= 4; + val += fromhex (*p++); + } RDEBUG (("Supplying Register %d %s\n", regno, valstr)); - if (val == 0 && valstr == p) + if (*p != '\0') error ("monitor_supply_register (%d): bad value from monitor: %s.", regno, valstr); @@ -1098,7 +1118,7 @@ monitor_wait (pid, status) struct target_waitstatus *status; { int old_timeout = timeout; - char buf[1024]; + char buf[TARGET_BUF_SIZE]; int resp_len; struct cleanup *old_chain; @@ -1282,7 +1302,7 @@ monitor_fetch_register (regno) int monitor_dump_reg_block (char *block_cmd) { - char buf[1024]; + char buf[TARGET_BUF_SIZE]; int resp_len; monitor_printf (block_cmd); resp_len = monitor_expect_prompt (buf, sizeof (buf)); @@ -1297,7 +1317,7 @@ monitor_dump_reg_block (char *block_cmd) static void monitor_dump_regs () { - char buf[1024]; + char buf[TARGET_BUF_SIZE]; int resp_len; if (current_monitor->dumpregs) (*(current_monitor->dumpregs)) (); /* call supplied function */ @@ -1340,7 +1360,7 @@ monitor_store_register (regno) int regno; { char *name; - unsigned int val; + ULONGEST val; name = current_monitor->regnames[regno]; if (!name || (*name == '\0')) @@ -1350,7 +1370,7 @@ monitor_store_register (regno) } val = read_register (regno); - RDEBUG (("MON storeg %d %08x\n", regno, (unsigned int) val)) + RDEBUG (("MON storeg %d %08lx\n", regno, (ULONGEST) val)) /* send the register deposit command */ @@ -1366,7 +1386,7 @@ monitor_store_register (regno) RDEBUG (("EXP setreg.term\n")) monitor_expect (current_monitor->setreg.term, NULL, 0); if (current_monitor->flags & MO_SETREG_INTERACTIVE) - monitor_printf ("%x\r", val); + monitor_printf ("%A\r", val); monitor_expect_prompt (NULL, 0); } else @@ -2148,7 +2168,7 @@ monitor_remove_breakpoint (addr, shadow) static int monitor_wait_srec_ack () { - int i, ch; + int ch; if (current_monitor->flags & MO_SREC_ACK_PLUS) { diff --git a/gdb/objfiles.c b/gdb/objfiles.c index a763a66..7e57562 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -521,9 +521,8 @@ objfile_relocate (objfile, new_offsets) struct objfile *objfile; struct section_offsets *new_offsets; { - struct section_offsets *delta = (struct section_offsets *) - alloca (sizeof (struct section_offsets) - + objfile->num_sections * sizeof (delta->offsets)); + struct section_offsets *delta = + (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS); { int i; @@ -289,7 +289,6 @@ ocd_open (name, from_tty, target_type, ops) struct target_ops *ops; { unsigned char buf[10], *p; - int status; int pktlen; if (name == 0) @@ -1066,7 +1065,6 @@ ocd_get_packet (cmd, lenp, timeout) { int ch; int len; - int i; static unsigned char packet[512]; unsigned char *packet_ptr; unsigned char checksum; @@ -1411,7 +1409,7 @@ bdm_update_flash_command (args, from_tty) int from_tty; { int status, pktlen; - struct cleanup *old_chain; + struct cleanup *old_chain; void (*store_registers_tmp) PARAMS ((int)); if (!ocd_desc) diff --git a/gdb/os9kread.c b/gdb/os9kread.c index 92b2824..f820fe8 100644 --- a/gdb/os9kread.c +++ b/gdb/os9kread.c @@ -127,7 +127,7 @@ static struct complaint lbrac_mismatch_complaint = /* Local function prototypes */ static void -read_minimal_symbols PARAMS ((struct objfile *, struct section_offsets *)); +read_minimal_symbols PARAMS ((struct objfile *)); static void os9k_read_ofile_symtab PARAMS ((struct partial_symtab *)); @@ -139,8 +139,7 @@ static void os9k_psymtab_to_symtab_1 PARAMS ((struct partial_symtab *)); static void -read_os9k_psymtab PARAMS ((struct section_offsets *, struct objfile *, - CORE_ADDR, int)); +read_os9k_psymtab PARAMS ((struct objfile *, CORE_ADDR, int)); static int fill_sym PARAMS ((FILE *, bfd *)); @@ -162,7 +161,7 @@ os9k_process_one_symbol PARAMS ((int, int, CORE_ADDR, char *, struct section_offsets *, struct objfile *)); static struct partial_symtab * - os9k_start_psymtab PARAMS ((struct objfile *, struct section_offsets *, char *, + os9k_start_psymtab PARAMS ((struct objfile *, char *, CORE_ADDR, int, int, struct partial_symbol **, struct partial_symbol **)); @@ -171,8 +170,7 @@ static struct partial_symtab * struct partial_symtab **, int)); static void -record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *, - struct section_offsets *)); +record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *)); #define HANDLE_RBRAC(val) \ if ((val) > pst->texthigh) pst->texthigh = (val); @@ -198,12 +196,11 @@ record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *, #define N_ABS 6 static void -record_minimal_symbol (name, address, type, objfile, section_offsets) +record_minimal_symbol (name, address, type, objfile) char *name; CORE_ADDR address; int type; struct objfile *objfile; - struct section_offsets *section_offsets; { enum minimal_symbol_type ms_type; @@ -211,7 +208,7 @@ record_minimal_symbol (name, address, type, objfile, section_offsets) { case N_TEXT: ms_type = mst_text; - address += ANOFFSET (section_offsets, SECT_OFF_TEXT); + address += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); break; case N_DATA: ms_type = mst_data; @@ -257,9 +254,8 @@ struct stbsymbol #define STBSYMSIZE 10 static void -read_minimal_symbols (objfile, section_offsets) +read_minimal_symbols (objfile) struct objfile *objfile; - struct section_offsets *section_offsets; { FILE *fp; bfd *abfd; @@ -314,7 +310,7 @@ read_minimal_symbols (objfile, section_offsets) break; ch = getc (fp); }; - record_minimal_symbol (buf1, sym.value, sym.type & 7, objfile, section_offsets); + record_minimal_symbol (buf1, sym.value, sym.type & 7, objfile); off += STBSYMSIZE; }; install_minimal_symbols (objfile); @@ -326,8 +322,6 @@ read_minimal_symbols (objfile, section_offsets) put all the relevant info into a "struct os9k_symfile_info", hung off the objfile structure. - SECTION_OFFSETS contains offsets relative to which the symbols in the - various sections are (depending where the sections were actually loaded). MAINLINE is true if we are reading the main symbol table (as opposed to a shared lib or dynamically loaded file). */ @@ -349,11 +343,11 @@ os9k_symfile_read (objfile, mainline) back_to = make_cleanup (really_free_pendings, 0); make_cleanup ((make_cleanup_func) discard_minimal_symbols, 0); - read_minimal_symbols (objfile, objfile->section_offsets); + read_minimal_symbols (objfile); /* Now that the symbol table data of the executable file are all in core, process them and define symbols accordingly. */ - read_os9k_psymtab (objfile->section_offsets, objfile, + read_os9k_psymtab (objfile, DBX_TEXT_ADDR (objfile), DBX_TEXT_SIZE (objfile)); @@ -565,13 +559,10 @@ fill_sym (dbg_file, abfd) /* Given pointers to an a.out symbol table in core containing dbx style data, setup partial_symtab's describing each source file for which debugging information is available. - SYMFILE_NAME is the name of the file we are reading from - and SECTION_OFFSETS is the set of offsets for the various sections - of the file (a set of zeros if the mainline program). */ + SYMFILE_NAME is the name of the file we are reading from. */ static void -read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) - struct section_offsets *section_offsets; +read_os9k_psymtab (objfile, text_addr, text_size) struct objfile *objfile; CORE_ADDR text_addr; int text_size; @@ -617,7 +608,7 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) #ifdef END_OF_TEXT_DEFAULT end_of_text_addr = END_OF_TEXT_DEFAULT; #else - end_of_text_addr = text_addr + section_offsets->offsets[SECT_OFF_TEXT] + end_of_text_addr = text_addr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT) + text_size; /* Relocate */ #endif @@ -664,7 +655,7 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) continue; case N_SYM_SE: - CUR_SYMBOL_VALUE += ANOFFSET (section_offsets, SECT_OFF_TEXT); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); if (psymfile_depth == 1 && pst) { os9k_end_psymtab (pst, psymtab_include_list, includes_used, @@ -701,7 +692,7 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) valu = CUR_SYMBOL_VALUE; if (valu) - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); past_first_source_file = 1; p = strchr (namestring, ':'); @@ -716,7 +707,7 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) if (psymfile_depth == 0) { if (!pst) - pst = os9k_start_psymtab (objfile, section_offsets, + pst = os9k_start_psymtab (objfile, str, valu, cursymoffset, symnum - 1, @@ -893,7 +884,7 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) continue; case 'f': - CUR_SYMBOL_VALUE += ANOFFSET (section_offsets, SECT_OFF_TEXT); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); if (pst && pst->textlow == 0) pst->textlow = CUR_SYMBOL_VALUE; @@ -904,7 +895,7 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) continue; case 'F': - CUR_SYMBOL_VALUE += ANOFFSET (section_offsets, SECT_OFF_TEXT); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); if (pst && pst->textlow == 0) pst->textlow = CUR_SYMBOL_VALUE; @@ -942,7 +933,7 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) } case N_SYM_RBRAC: - CUR_SYMBOL_VALUE += ANOFFSET (section_offsets, SECT_OFF_TEXT); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); #ifdef HANDLE_RBRAC HANDLE_RBRAC (CUR_SYMBOL_VALUE); continue; @@ -992,10 +983,9 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) static struct partial_symtab * -os9k_start_psymtab (objfile, section_offsets, +os9k_start_psymtab (objfile, filename, textlow, ldsymoff, ldsymcnt, global_syms, static_syms) struct objfile *objfile; - struct section_offsets *section_offsets; char *filename; CORE_ADDR textlow; int ldsymoff; @@ -1004,7 +994,7 @@ os9k_start_psymtab (objfile, section_offsets, struct partial_symbol **static_syms; { struct partial_symtab *result = - start_psymtab_common (objfile, section_offsets, + start_psymtab_common (objfile, objfile->section_offsets, filename, textlow, global_syms, static_syms); result->read_symtab_private = (char *) @@ -1313,7 +1303,6 @@ os9k_read_ofile_symtab (pst) int sym_offset; /* Offset to start of symbols to read */ CORE_ADDR text_offset; /* Start of text segment for symbols */ int text_size; /* Size of text segment for symbols */ - struct section_offsets *section_offsets; FILE *dbg_file; objfile = pst->objfile; @@ -1321,7 +1310,6 @@ os9k_read_ofile_symtab (pst) max_symnum = LDSYMCNT (pst); text_offset = pst->textlow; text_size = pst->texthigh - pst->textlow; - section_offsets = pst->section_offsets; current_objfile = objfile; subfile_stack = NULL; @@ -1386,7 +1374,7 @@ os9k_read_ofile_symtab (pst) type = bufp->n_type; os9k_process_one_symbol ((int) type, (int) bufp->n_desc, - (CORE_ADDR) bufp->n_value, bufp->n_strx, section_offsets, objfile); + (CORE_ADDR) bufp->n_value, bufp->n_strx, pst->section_offsets, objfile); /* We skip checking for a new .o or -l file; that should never happen in this routine. */ diff --git a/gdb/parse.c b/gdb/parse.c index c28d283..b178465 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -602,8 +602,6 @@ parse_nested_classes_for_hpacc (name, len, token, class_prefix, argptr) struct symbol *sym_class = NULL; struct symbol *sym_var = NULL; struct type *t; - register int i; - int colons_found = 0; int prefix_len = 0; int done = 0; char *q; diff --git a/gdb/partial-stab.h b/gdb/partial-stab.h index 2a8c010..b4ba251 100644 --- a/gdb/partial-stab.h +++ b/gdb/partial-stab.h @@ -24,7 +24,6 @@ CUR_SYMBOL_TYPE --Type code of current symbol. CUR_SYMBOL_VALUE --Value field of current symbol. May be adjusted here. namestring - variable pointing to the name of the stab. - section_offsets - variable pointing to the section offsets. pst - the partial symbol table being built. psymtab_include_list, includes_used, includes_allocated - list of include @@ -266,7 +265,7 @@ switch (CUR_SYMBOL_TYPE) immediately follow the first. */ if (!pst) - pst = START_PSYMTAB (objfile, objfile->section_offsets, + pst = START_PSYMTAB (objfile, namestring, valu, first_so_symnum * symbol_size, objfile->global_psymbols.next, diff --git a/gdb/ppcbug-rom.c b/gdb/ppcbug-rom.c index 3eac535..123161a 100644 --- a/gdb/ppcbug-rom.c +++ b/gdb/ppcbug-rom.c @@ -27,8 +27,6 @@ #include "monitor.h" #include "serial.h" -static void ppcbug_open PARAMS ((char *args, int from_tty)); - static void ppcbug_supply_register (regname, regnamelen, val, vallen) char *regname; @@ -36,7 +34,7 @@ ppcbug_supply_register (regname, regnamelen, val, vallen) char *val; int vallen; { - int regno = 0, base = 0; + int regno = 0; if (regnamelen < 2 || regnamelen > 4) return; diff --git a/gdb/remote-array.c b/gdb/remote-array.c index 932166f..a5a78c8 100644 --- a/gdb/remote-array.c +++ b/gdb/remote-array.c @@ -37,6 +37,8 @@ #include "serial.h" #include "monitor.h" #include "remote-utils.h" +#include "inferior.h" +#include "version.h" extern int baud_rate; @@ -88,8 +90,6 @@ static int array_get_packet (); static unsigned long ascii2hexword (); static void hexword2ascii (); -extern char *version; - #define LOG_FILE "monitor.log" #if defined (LOG_FILE) FILE *log_file; @@ -625,7 +625,7 @@ array_open (args, name, from_tty) log_file = fopen (LOG_FILE, "w"); if (log_file == NULL) perror_with_name (LOG_FILE); - fprintf (log_file, "GDB %s (%s", version); + fprintf (log_file, "GDB %s (%s", version, host_name); fprintf (log_file, " --target %s)\n", array_ops.to_shortname); fprintf (log_file, "Remote target %s connected to %s\n\n", array_ops.to_shortname, dev_name); #endif @@ -1025,7 +1025,7 @@ array_read_inferior_memory (memaddr, myaddr, len) /* Fetch the bytes */ debuglogs (3, "read %d bytes from inferior address %x", len_this_pass, startaddr); - sprintf (buf, "m%08x,%04x", startaddr, len_this_pass); + sprintf (buf, "m%08lx,%04x", startaddr, len_this_pass); make_gdb_packet (packet, buf); if (array_send_packet (packet) == 0) { @@ -1112,7 +1112,7 @@ array_insert_breakpoint (addr, shadow) { breakaddr[i] = addr; if (sr_get_debug () > 4) - printf ("Breakpoint at %x\n", addr); + printf ("Breakpoint at %s\n", paddr_nz (addr)); array_read_inferior_memory (bp_addr, shadow, bp_size); printf_monitor ("b 0x%x\n", addr); expect_prompt (1); @@ -1147,7 +1147,8 @@ array_remove_breakpoint (addr, shadow) return 0; } } - fprintf (stderr, "Can't find breakpoint associated with 0x%x\n", addr); + fprintf (stderr, "Can't find breakpoint associated with 0x%s\n", + paddr_nz (addr)); return 1; } diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c index c92c82f..87997ad 100644 --- a/gdb/remote-mips.c +++ b/gdb/remote-mips.c @@ -41,7 +41,6 @@ #define S_IROTH S_IREAD #endif -extern void mips_set_processor_type_command PARAMS ((char *, int)); /* Breakpoint types. Values 0, 1, and 2 must agree with the watch @@ -394,7 +393,7 @@ static int interrupt_count; static int mips_wait_flag = 0; /* If non-zero, monitor supports breakpoint commands. */ -static monitor_supports_breakpoints = 0; +static int monitor_supports_breakpoints = 0; /* Data cache header. */ @@ -2545,7 +2544,7 @@ remote_mips_remove_watchpoint (addr, len, type) } int -remote_mips_stopped_by_watchpoint () +remote_mips_stopped_by_watchpoint (void) { return hit_watchpoint; } @@ -2864,7 +2863,7 @@ send_srec (srec, len, addr) case 0x6: /* ACK */ return; case 0x15: /* NACK */ - fprintf_unfiltered (gdb_stderr, "Download got a NACK at byte %d! Retrying.\n", addr); + fprintf_unfiltered (gdb_stderr, "Download got a NACK at byte %s! Retrying.\n", paddr_u (addr)); continue; default: error ("Download got unexpected ack char: 0x%x, retrying.\n", ch); @@ -2910,9 +2909,10 @@ mips_load_srec (args) { unsigned int numbytes; - /* FIXME! vma too small?? */ - printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, s->vma, - s->vma + s->_raw_size); + /* FIXME! vma too small????? */ + printf_filtered ("%s\t: 0x%4lx .. 0x%4lx ", s->name, + (long) s->vma, + (long) (s->vma + s->_raw_size)); gdb_flush (gdb_stdout); for (i = 0; i < s->_raw_size; i += numbytes) diff --git a/gdb/remote-os9k.c b/gdb/remote-os9k.c index b14b460..a523c3c 100644 --- a/gdb/remote-os9k.c +++ b/gdb/remote-os9k.c @@ -512,12 +512,8 @@ rombug_wait (pid, status) { if (obj_sec->objfile != symfile_objfile) new_symfile_objfile (obj_sec->objfile, 1, 0); - offs = ((struct section_offsets *) - alloca (sizeof (struct section_offsets) - + (symfile_objfile->num_sections * sizeof (offs->offsets)))); - memcpy (offs, symfile_objfile->section_offsets, - (sizeof (struct section_offsets) + - (symfile_objfile->num_sections * sizeof (offs->offsets)))); + offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS); + memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS); ANOFFSET (offs, SECT_OFF_DATA) = addr; ANOFFSET (offs, SECT_OFF_BSS) = addr; diff --git a/gdb/remote-rdi.c b/gdb/remote-rdi.c index 49ed2c7..a9e9d9e 100644 --- a/gdb/remote-rdi.c +++ b/gdb/remote-rdi.c @@ -373,7 +373,7 @@ arm_rdi_create_inferior (exec_file, args, env) /* Set up memory limit */ top_of_memory = strtoul (*env + sizeof ("MEMSIZE=") - 1, &end_of_num, 0); - printf_filtered ("Setting top-of-memory to 0x%x\n", + printf_filtered ("Setting top-of-memory to 0x%lx\n", top_of_memory); rslt = angel_RDI_info (RDIInfo_SetTopMem, &top_of_memory, &arg2); diff --git a/gdb/remote-sds.c b/gdb/remote-sds.c index ca665ec..bdf2077 100644 --- a/gdb/remote-sds.c +++ b/gdb/remote-sds.c @@ -498,7 +498,6 @@ sds_fetch_registers (regno) { unsigned char buf[PBUFSIZ]; int i, retlen; - char *p; char regs[REGISTER_BYTES]; /* Unimplemented registers read as all bits zero. */ @@ -780,8 +779,6 @@ putmessage (buf, len) unsigned char csum = 0; char buf2[PBUFSIZ], buf3[PBUFSIZ]; unsigned char header[3]; - int ch; - int tcount = 0; char *p; /* Copy the packet into buffer BUF2, encapsulating it @@ -831,8 +828,6 @@ putmessage (buf, len) while (1) { - int started_error_output = 0; - if (remote_debug) { *p = '\0'; @@ -846,9 +841,7 @@ putmessage (buf, len) perror_with_name ("putmessage: write failed"); return 1; - } - } /* Come here after finding the start of the frame. Collect the rest diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 6f3af0c..dc24f57 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -131,7 +131,7 @@ dump_mem (buf, len) { long l[2]; memcpy (l, buf, len); - printf_filtered ("\t0x%x", l[0]); + printf_filtered ("\t0x%lx", l[0]); printf_filtered (len == 8 ? " 0x%x\n" : "\n", l[1]); } else @@ -290,6 +290,10 @@ gdb_os_error (host_callback * p, const char *format,...) } } +#ifndef REGISTER_SIM_REGNO +#define REGISTER_SIM_REGNO(N) (N) +#endif + static void gdbsim_fetch_register (regno) int regno; @@ -300,19 +304,28 @@ gdbsim_fetch_register (regno) for (regno = 0; regno < NUM_REGS; regno++) gdbsim_fetch_register (regno); } - else if (REGISTER_NAME (regno) != NULL && *REGISTER_NAME (regno) != '\0') + else if (REGISTER_NAME (regno) != NULL + && *REGISTER_NAME (regno) != '\0') { char buf[MAX_REGISTER_RAW_SIZE]; - int nr_bytes = sim_fetch_register (gdbsim_desc, regno, buf, REGISTER_RAW_SIZE (regno)); + int nr_bytes; + if (REGISTER_SIM_REGNO (regno) >= 0) + nr_bytes = sim_fetch_register (gdbsim_desc, + REGISTER_SIM_REGNO (regno), + buf, REGISTER_RAW_SIZE (regno)); + else + nr_bytes = 0; if (nr_bytes == 0) /* register not applicable, supply zero's */ memset (buf, 0, MAX_REGISTER_RAW_SIZE); else if (nr_bytes > 0 && nr_bytes != REGISTER_RAW_SIZE (regno) && warn_user) { - printf_unfiltered ("Size of register %s (%d) incorrect (%d instead of %d))", - REGISTER_NAME (regno), regno, - nr_bytes, REGISTER_RAW_SIZE (regno)); + fprintf_unfiltered (gdb_stderr, + "Size of register %s (%d/%d) incorrect (%d instead of %d))", + REGISTER_NAME (regno), + regno, REGISTER_SIM_REGNO (regno), + nr_bytes, REGISTER_RAW_SIZE (regno)); warn_user = 0; } supply_register (regno, buf); @@ -335,12 +348,16 @@ gdbsim_store_register (regno) for (regno = 0; regno < NUM_REGS; regno++) gdbsim_store_register (regno); } - else if (REGISTER_NAME (regno) != NULL && *REGISTER_NAME (regno) != '\0') + else if (REGISTER_NAME (regno) != NULL + && *REGISTER_NAME (regno) != '\0' + && REGISTER_SIM_REGNO (regno) >= 0) { char tmp[MAX_REGISTER_RAW_SIZE]; int nr_bytes; read_register_gen (regno, tmp); - nr_bytes = sim_store_register (gdbsim_desc, regno, tmp, REGISTER_RAW_SIZE (regno)); + nr_bytes = sim_store_register (gdbsim_desc, + REGISTER_SIM_REGNO (regno), + tmp, REGISTER_RAW_SIZE (regno)); if (nr_bytes > 0 && nr_bytes != REGISTER_RAW_SIZE (regno)) internal_error ("Register size different to expected"); if (sr_get_debug ()) @@ -743,8 +760,11 @@ gdbsim_xfer_inferior_memory (memaddr, myaddr, len, write, target) if (sr_get_debug ()) { - printf_filtered ("gdbsim_xfer_inferior_memory: myaddr 0x%x, memaddr 0x%x, len %d, write %d\n", - myaddr, memaddr, len, write); + /* FIXME: Send to something other than STDOUT? */ + printf_filtered ("gdbsim_xfer_inferior_memory: myaddr 0x"); + gdb_print_host_address (myaddr, gdb_stdout); + printf_filtered (", memaddr 0x%s, len %d, write %d\n", + paddr_nz (memaddr), len, write); if (sr_get_debug () && write) dump_mem (myaddr, len); } diff --git a/gdb/remote-vx.c b/gdb/remote-vx.c index 8c09d2c..4d7c6c9 100644 --- a/gdb/remote-vx.c +++ b/gdb/remote-vx.c @@ -708,12 +708,8 @@ vx_add_symbols (name, from_tty, text_addr, data_addr, bss_addr) free_objfile it. */ objfile_to_front (objfile); - offs = (struct section_offsets *) - alloca (sizeof (struct section_offsets) - + objfile->num_sections * sizeof (offs->offsets)); - memcpy (offs, objfile->section_offsets, - sizeof (struct section_offsets) - + objfile->num_sections * sizeof (offs->offsets)); + offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS); + memcpy (offs, objfile->section_offsets, SIZEOF_SECTION_OFFSETS); ss.text_start = 0; ss.data_start = 0; diff --git a/gdb/remote.c b/gdb/remote.c index be285b6..1275e51 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1499,13 +1499,8 @@ get_offsets () if (symfile_objfile == NULL) return; - offs = alloca (sizeof (struct section_offsets) - + symfile_objfile->num_sections - * sizeof (offs->offsets)); - memcpy (offs, symfile_objfile->section_offsets, - sizeof (struct section_offsets) - + symfile_objfile->num_sections - * sizeof (offs->offsets)); + offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS); + memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS); ANOFFSET (offs, SECT_OFF_TEXT) = text_addr; @@ -1592,8 +1587,10 @@ remote_cisco_section_offsets (text_addr, data_addr, bss_addr, sprintf_vma (tmp + strlen (tmp), bss_addr); fprintf_filtered (gdb_stdlog, tmp); fprintf_filtered (gdb_stdlog, - "Reloc offset: text = 0x%x data = 0x%x bss = 0x%x\n", - (long) *text_offs, (long) *data_offs, (long) *bss_offs); + "Reloc offset: text = 0x%s data = 0x%s bss = 0x%s\n", + paddr_nz (*text_offs), + paddr_nz (*data_offs), + paddr_nz (*bss_offs)); } return 0; @@ -1619,15 +1616,8 @@ remote_cisco_objfile_relocate (text_off, data_off, bss_off) broken for xcoff, dwarf, sdb-coff, etc. But there is no simple canonical representation for this stuff. */ - offs = ((struct section_offsets *) - alloca (sizeof (struct section_offsets) - + (symfile_objfile->num_sections - * sizeof (offs->offsets)))); - - memcpy (offs, symfile_objfile->section_offsets, - (sizeof (struct section_offsets) - + (symfile_objfile->num_sections - * sizeof (offs->offsets)))); + offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS); + memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS); ANOFFSET (offs, SECT_OFF_TEXT) = text_off; ANOFFSET (offs, SECT_OFF_DATA) = data_off; @@ -2389,7 +2379,7 @@ Packet: '%s'\n", if (symfile_objfile == NULL) { - warning ("Relocation packet recieved with no symbol file. \ + warning ("Relocation packet received with no symbol file. \ Packet Dropped"); goto got_status; } @@ -3453,7 +3443,7 @@ putpkt_binary (buf, cnt) *p = '\0'; fprintf_unfiltered (gdb_stdlog, "Sending packet: "); fputstrn_unfiltered (buf2, p - buf2, 0, gdb_stdlog); - fprintf_unfiltered (gdb_stdlog, "...", buf2); + fprintf_unfiltered (gdb_stdlog, "..."); gdb_flush (gdb_stdlog); } if (SERIAL_WRITE (remote_desc, buf2, p - buf2)) @@ -3994,7 +3984,6 @@ remote_remove_breakpoint (addr, contents_cache) CORE_ADDR addr; char *contents_cache; { - char buf[PBUFSIZ]; int bp_size; if ((remote_protocol_Z.support == PACKET_ENABLE) @@ -4040,7 +4029,7 @@ remote_insert_watchpoint (addr, len, type) p = strchr (buf, '\0'); addr = remote_address_masked (addr); p += hexnumstr (p, (ULONGEST) addr); - sprintf (p, ",%lx", len); + sprintf (p, ",%x", len); putpkt (buf); getpkt (buf, 0); @@ -4063,7 +4052,7 @@ remote_remove_watchpoint (addr, len, type) p = strchr (buf, '\0'); addr = remote_address_masked (addr); p += hexnumstr (p, (ULONGEST) addr); - sprintf (p, ",%lx", len); + sprintf (p, ",%x", len); putpkt (buf); getpkt (buf, 0); @@ -4258,8 +4247,8 @@ compare_sections_command (args, from_tty) for (target_crc = 0, tmp = &buf[1]; *tmp; tmp++) target_crc = target_crc * 16 + fromhex (*tmp); - printf_filtered ("Section %s, range 0x%08x -- 0x%08x: ", - sectname, lma, lma + size); + printf_filtered ("Section %s, range 0x%s -- 0x%s: ", + sectname, paddr (lma), paddr (lma + size)); if (host_crc == target_crc) printf_filtered ("matched.\n"); else @@ -4287,7 +4276,6 @@ remote_query (query_type, buf, outbuf, bufsiz) int i; char *buf2 = alloca (PBUFSIZ); char *p2 = &buf2[0]; - char *p = buf; if (!bufsiz) error ("null pointer to remote bufer size specified"); @@ -4877,7 +4865,6 @@ readsocket () static int readtty () { - int status; int tty_bytecount; /* First, read a buffer full from the terminal */ diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index b0a0021..abd5362 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -343,9 +343,7 @@ vmap_symtab (vp) objfile = symfile_objfile; } - new_offsets = alloca - (sizeof (struct section_offsets) - + sizeof (new_offsets->offsets) * objfile->num_sections); + new_offsets = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS); for (i = 0; i < objfile->num_sections; ++i) ANOFFSET (new_offsets, i) = ANOFFSET (objfile->section_offsets, i); diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 812e9a8..48db7d5 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -1281,7 +1281,6 @@ frame_get_saved_regs (fi, fdatap) struct frame_info *fi; struct rs6000_framedata *fdatap; { - int ii; CORE_ADDR frame_addr; struct rs6000_framedata work_fdata; @@ -1806,8 +1805,6 @@ show_current_variant () static void set_processor (char *arg, int from_tty) { - int i; - if (!arg || arg[0] == '\0') { list_variants (); diff --git a/gdb/scm-valprint.c b/gdb/scm-valprint.c index d29a96c..8ddfb7f 100644 --- a/gdb/scm-valprint.c +++ b/gdb/scm-valprint.c @@ -145,7 +145,7 @@ scm_ipruk (hdr, ptr, stream) if (SCM_CELLP (ptr)) fprintf_filtered (stream, " (0x%lx . 0x%lx) @", (long) SCM_CAR (ptr), (long) SCM_CDR (ptr)); - fprintf_filtered (stream, " 0x%x>", ptr); + fprintf_filtered (stream, " 0x%s>", paddr_nz (ptr)); } void @@ -217,7 +217,7 @@ taloop: (sizet) LENGTH (name), port); #endif - fprintf_filtered (stream, " #X%lX>", svalue); + fprintf_filtered (stream, " #X%s>", paddr_nz (svalue)); break; } case scm_tcs_cons_imcar: diff --git a/gdb/ser-pipe.c b/gdb/ser-pipe.c index 04839f4..0c36a31 100644 --- a/gdb/ser-pipe.c +++ b/gdb/ser-pipe.c @@ -274,7 +274,7 @@ pipe_readchar (scb, timeout) else if (timeout == 0) { - status == SERIAL_TIMEOUT; + status = SERIAL_TIMEOUT; break; } } diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c index 8e7da06..f565328 100644 --- a/gdb/ser-tcp.c +++ b/gdb/ser-tcp.c @@ -281,7 +281,7 @@ tcp_readchar (scb, timeout) else if (timeout == 0) { - status == SERIAL_TIMEOUT; + status = SERIAL_TIMEOUT; break; } } diff --git a/gdb/sh-stub.c b/gdb/sh-stub.c index dc7ec33..4eedbc1 100644 --- a/gdb/sh-stub.c +++ b/gdb/sh-stub.c @@ -199,7 +199,7 @@ static int hex (char); static char *mem2hex (char *, char *, int); static char *hex2mem (char *, char *, int); static int hexToInt (char **, int *); -static unsigned char *getpacket (unsigned char *); +static unsigned char *getpacket (void); static void putpacket (char *); static void handle_buserror (void); static int computeSignal (int exceptionVector); @@ -277,8 +277,8 @@ int registers[NUMREGBYTES / 4]; stepData instrBuffer; char stepped; static const char hexchars[] = "0123456789abcdef"; -char remcomInBuffer[BUFMAX]; -char remcomOutBuffer[BUFMAX]; +static char remcomInBuffer[BUFMAX]; +static char remcomOutBuffer[BUFMAX]; char highhex(int x) { @@ -383,9 +383,9 @@ hexToInt (char **ptr, int *intValue) /* scan for the sequence $<data>#<checksum> */ char * -getpacket (buffer) - char *buffer; +getpacket () { + unsigned char *buffer = &remcomInBuffer[0]; unsigned char checksum; unsigned char xmitcsum; int count; @@ -689,7 +689,7 @@ gdb_handle_exception (int exceptionVector) while (1) { remcomOutBuffer[0] = 0; - ptr = getpacket (remcomInBuffer); + ptr = getpacket (); switch (*ptr++) { diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index 38d7929..6003e82 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -640,67 +640,67 @@ sh_show_regs (args, from_tty) if (cpu == bfd_mach_sh4) cpu = bfd_mach_sh3; - printf_filtered ("PC=%08x SR=%08x PR=%08x MACH=%08x MACHL=%08x\n", - read_register (PC_REGNUM), - read_register (SR_REGNUM), - read_register (PR_REGNUM), - read_register (MACH_REGNUM), - read_register (MACL_REGNUM)); - - printf_filtered ("GBR=%08x VBR=%08x", - read_register (GBR_REGNUM), - read_register (VBR_REGNUM)); + printf_filtered ("PC=%s SR=%08lx PR=%08lx MACH=%08lx MACHL=%08lx\n", + paddr (read_register (PC_REGNUM)), + (long) read_register (SR_REGNUM), + (long) read_register (PR_REGNUM), + (long) read_register (MACH_REGNUM), + (long) read_register (MACL_REGNUM)); + + printf_filtered ("GBR=%08lx VBR=%08lx", + (long) read_register (GBR_REGNUM), + (long) read_register (VBR_REGNUM)); if (cpu == bfd_mach_sh3 || cpu == bfd_mach_sh3e) { - printf_filtered (" SSR=%08x SPC=%08x", - read_register (SSR_REGNUM), - read_register (SPC_REGNUM)); + printf_filtered (" SSR=%08lx SPC=%08lx", + (long) read_register (SSR_REGNUM), + (long) read_register (SPC_REGNUM)); if (cpu == bfd_mach_sh3e) { - printf_filtered (" FPUL=%08x FPSCR=%08x", - read_register (FPUL_REGNUM), - read_register (FPSCR_REGNUM)); + printf_filtered (" FPUL=%08lx FPSCR=%08lx", + (long) read_register (FPUL_REGNUM), + (long) read_register (FPSCR_REGNUM)); } } - printf_filtered ("\nR0-R7 %08x %08x %08x %08x %08x %08x %08x %08x\n", - read_register (0), - read_register (1), - read_register (2), - read_register (3), - read_register (4), - read_register (5), - read_register (6), - read_register (7)); - printf_filtered ("R8-R15 %08x %08x %08x %08x %08x %08x %08x %08x\n", - read_register (8), - read_register (9), - read_register (10), - read_register (11), - read_register (12), - read_register (13), - read_register (14), - read_register (15)); + printf_filtered ("\nR0-R7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", + (long) read_register (0), + (long) read_register (1), + (long) read_register (2), + (long) read_register (3), + (long) read_register (4), + (long) read_register (5), + (long) read_register (6), + (long) read_register (7)); + printf_filtered ("R8-R15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", + (long) read_register (8), + (long) read_register (9), + (long) read_register (10), + (long) read_register (11), + (long) read_register (12), + (long) read_register (13), + (long) read_register (14), + (long) read_register (15)); if (cpu == bfd_mach_sh3e) { - printf_filtered ("FP0-FP7 %08x %08x %08x %08x %08x %08x %08x %08x\n", - read_register (FP0_REGNUM + 0), - read_register (FP0_REGNUM + 1), - read_register (FP0_REGNUM + 2), - read_register (FP0_REGNUM + 3), - read_register (FP0_REGNUM + 4), - read_register (FP0_REGNUM + 5), - read_register (FP0_REGNUM + 6), - read_register (FP0_REGNUM + 7)); - printf_filtered ("FP8-FP15 %08x %08x %08x %08x %08x %08x %08x %08x\n", - read_register (FP0_REGNUM + 8), - read_register (FP0_REGNUM + 9), - read_register (FP0_REGNUM + 10), - read_register (FP0_REGNUM + 11), - read_register (FP0_REGNUM + 12), - read_register (FP0_REGNUM + 13), - read_register (FP0_REGNUM + 14), - read_register (FP0_REGNUM + 15)); + printf_filtered ("FP0-FP7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", + (long) read_register (FP0_REGNUM + 0), + (long) read_register (FP0_REGNUM + 1), + (long) read_register (FP0_REGNUM + 2), + (long) read_register (FP0_REGNUM + 3), + (long) read_register (FP0_REGNUM + 4), + (long) read_register (FP0_REGNUM + 5), + (long) read_register (FP0_REGNUM + 6), + (long) read_register (FP0_REGNUM + 7)); + printf_filtered ("FP8-FP15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", + (long) read_register (FP0_REGNUM + 8), + (long) read_register (FP0_REGNUM + 9), + (long) read_register (FP0_REGNUM + 10), + (long) read_register (FP0_REGNUM + 11), + (long) read_register (FP0_REGNUM + 12), + (long) read_register (FP0_REGNUM + 13), + (long) read_register (FP0_REGNUM + 14), + (long) read_register (FP0_REGNUM + 15)); } } diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index 6c9ec45..68cde8a 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -119,12 +119,16 @@ static void sol_core_close PARAMS ((int quitting)); static void init_sol_thread_ops PARAMS ((void)); static void init_sol_core_ops PARAMS ((void)); -#define THREAD_FLAG 0x80000000 -#define is_thread(ARG) (((ARG) & THREAD_FLAG) != 0) -#define is_lwp(ARG) (((ARG) & THREAD_FLAG) == 0) -#define GET_LWP(LWP_ID) (TIDGET(LWP_ID)) -#define GET_THREAD(THREAD_ID) (((THREAD_ID) >> 16) & 0x7fff) -#define BUILD_LWP(LWP_ID, PID) ((LWP_ID) << 16 | (PID)) +/* Default definitions: These must be defined in tm.h + if they are to be shared with a process module such as procfs. */ + +#define THREAD_FLAG 0x80000000 +#define is_thread(ARG) (((ARG) & THREAD_FLAG) != 0) +#define is_lwp(ARG) (((ARG) & THREAD_FLAG) == 0) +#define GET_LWP(PID) TIDGET (PID) +#define GET_THREAD(PID) (((PID) >> 16) & 0x7fff) +#define BUILD_LWP(TID, PID) ((TID) << 16 | (PID)) + #define BUILD_THREAD(THREAD_ID, PID) (THREAD_FLAG | BUILD_LWP (THREAD_ID, PID)) /* Pointers to routines from lithread_db resolved by dlopen() */ @@ -492,6 +496,7 @@ sol_thread_detach (args, from_tty) char *args; int from_tty; { + inferior_pid = PIDGET (main_ph.pid); unpush_target (&sol_thread_ops); procfs_ops.to_detach (args, from_tty); } @@ -987,30 +992,40 @@ typedef size_t gdb_ps_size_t; by the time we call anything in thread_db, these routines need to do nothing. */ +/* Process stop */ + ps_err_e ps_pstop (gdb_ps_prochandle_t ph) { return PS_OK; } +/* Process continue */ + ps_err_e ps_pcontinue (gdb_ps_prochandle_t ph) { return PS_OK; } +/* LWP stop */ + ps_err_e ps_lstop (gdb_ps_prochandle_t ph, lwpid_t lwpid) { return PS_OK; } +/* LWP continue */ + ps_err_e ps_lcontinue (gdb_ps_prochandle_t ph, lwpid_t lwpid) { return PS_OK; } +/* Looks up the symbol LD_SYMBOL_NAME in the debugger's symbol table. */ + ps_err_e ps_pglobal_lookup (gdb_ps_prochandle_t ph, const char *ld_object_name, const char *ld_symbol_name, paddr_t * ld_symbol_addr) @@ -1071,6 +1086,8 @@ rw_common (int dowrite, const struct ps_prochandle *ph, paddr_t addr, return PS_OK; } +/* Copies SIZE bytes from target process .data segment to debugger memory. */ + ps_err_e ps_pdread (gdb_ps_prochandle_t ph, paddr_t addr, gdb_ps_read_buf_t buf, gdb_ps_size_t size) @@ -1078,6 +1095,8 @@ ps_pdread (gdb_ps_prochandle_t ph, paddr_t addr, return rw_common (0, ph, addr, buf, size); } +/* Copies SIZE bytes from debugger memory .data segment to target process. */ + ps_err_e ps_pdwrite (gdb_ps_prochandle_t ph, paddr_t addr, gdb_ps_write_buf_t buf, gdb_ps_size_t size) @@ -1085,6 +1104,8 @@ ps_pdwrite (gdb_ps_prochandle_t ph, paddr_t addr, return rw_common (1, ph, addr, (char *) buf, size); } +/* Copies SIZE bytes from target process .text segment to debugger memory. */ + ps_err_e ps_ptread (gdb_ps_prochandle_t ph, paddr_t addr, gdb_ps_read_buf_t buf, gdb_ps_size_t size) @@ -1092,6 +1113,8 @@ ps_ptread (gdb_ps_prochandle_t ph, paddr_t addr, return rw_common (0, ph, addr, buf, size); } +/* Copies SIZE bytes from debugger memory .text segment to target process. */ + ps_err_e ps_ptwrite (gdb_ps_prochandle_t ph, paddr_t addr, gdb_ps_write_buf_t buf, gdb_ps_size_t size) @@ -1099,7 +1122,7 @@ ps_ptwrite (gdb_ps_prochandle_t ph, paddr_t addr, return rw_common (1, ph, addr, (char *) buf, size); } -/* Get integer regs */ +/* Get integer regs for LWP */ ps_err_e ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, @@ -1122,7 +1145,7 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, return PS_OK; } -/* Set integer regs */ +/* Set integer regs for LWP */ ps_err_e ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, @@ -1145,6 +1168,8 @@ ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, return PS_OK; } +/* Log a message (sends to gdb_stderr). */ + void ps_plog (const char *fmt,...) { @@ -1229,7 +1254,7 @@ ps_lsetxregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, caddr_t xregset) return PS_OK; } -/* Get floating-point regs. */ +/* Get floating-point regs for LWP */ ps_err_e ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, @@ -1252,7 +1277,7 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, return PS_OK; } -/* Set floating-point regs. */ +/* Set floating-point regs for LWP */ ps_err_e ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, @@ -1286,6 +1311,8 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, static int nldt_allocated = 0; static struct ssd *ldt_bufp = NULL; +/* Reads the local descriptor table of a LWP. */ + ps_err_e ps_lgetLDT (gdb_ps_prochandle_t ph, lwpid_t lwpid, struct ssd *pldt) @@ -1391,7 +1418,7 @@ sol_find_new_threads_callback (th, ignored) return 0; } -void +static void sol_find_new_threads () { /* don't do anything if init failed to resolve the libthread_db library */ diff --git a/gdb/somread.c b/gdb/somread.c index 55092b8..cb1c850 100644 --- a/gdb/somread.c +++ b/gdb/somread.c @@ -52,13 +52,13 @@ static void som_symtab_read PARAMS ((bfd *, struct objfile *, struct section_offsets *)); -static struct section_offsets * +static void som_symfile_offsets PARAMS ((struct objfile *, CORE_ADDR)); /* FIXME: These should really be in a common header somewhere */ extern void -hpread_build_psymtabs PARAMS ((struct objfile *, struct section_offsets *, int)); +hpread_build_psymtabs PARAMS ((struct objfile *, int)); extern void hpread_symfile_finish PARAMS ((struct objfile *)); @@ -398,7 +398,7 @@ som_symfile_read (objfile, mainline) This builds the psymtab. This used to be done via a scan of the DNTT, but is now done via the PXDB-built quick-lookup tables together with a scan of the GNTT. See hp-psymtab-read.c. */ - hpread_build_psymtabs (objfile, objfile->section_offsets, mainline); + hpread_build_psymtabs (objfile, mainline); /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. @@ -459,27 +459,24 @@ som_symfile_init (objfile) Plain and simple for now. */ -static struct section_offsets * +static void som_symfile_offsets (objfile, addr) struct objfile *objfile; CORE_ADDR addr; { - struct section_offsets *section_offsets; int i; objfile->num_sections = SECT_OFF_MAX; - section_offsets = (struct section_offsets *) + objfile->section_offsets = (struct section_offsets *) obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS); /* First see if we're a shared library. If so, get the section offsets from the library, else get them from addr. */ - if (!som_solib_section_offsets (objfile, section_offsets)) + if (!som_solib_section_offsets (objfile, objfile->section_offsets)) { for (i = 0; i < SECT_OFF_MAX; i++) - ANOFFSET (section_offsets, i) = addr; + ANOFFSET (objfile->section_offsets, i) = addr; } - - return section_offsets; } /* Read in and initialize the SOM import list which is present diff --git a/gdb/source.c b/gdb/source.c index 7982529..4293e59 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1311,19 +1311,12 @@ list_command (arg, from_tty) error ("No default source file yet. Do \"help list\"."); else if (no_end) { - if (lines_to_list % 2 == 0) - print_source_lines (sal.symtab, - max (sal.line - (lines_to_list / 2), 1), - sal.line + (lines_to_list / 2), 0); - else - /* If lines_to_list is odd, then we round down in - * one of the lines_to_list/2 computations, round up in - * the other, so the total window size around the specified - * line comes out right. - */ - print_source_lines (sal.symtab, - max (sal.line - (lines_to_list / 2), 1), - sal.line + ((1 + lines_to_list) / 2), 0); + int first_line = sal.line - lines_to_list / 2; + + if (first_line < 1) first_line = 1; + + print_source_lines (sal.symtab, first_line, first_line + lines_to_list, + 0); } else print_source_lines (sal.symtab, sal.line, diff --git a/gdb/sparc-stub.c b/gdb/sparc-stub.c index 8e88e56..ce2aadd 100644 --- a/gdb/sparc-stub.c +++ b/gdb/sparc-stub.c @@ -62,9 +62,6 @@ * * ? What was the last sigval ? SNN (signal NN) * - * bBB..BB Set baud rate to BB..BB OK or BNN, then sets - * baud rate - * * All commands and responses are sent with a packet which includes a * checksum. A packet consists of * @@ -284,12 +281,15 @@ hex(ch) return -1; } +static char remcomInBuffer[BUFMAX]; +static char remcomOutBuffer[BUFMAX]; + /* scan for the sequence $<data>#<checksum> */ unsigned char * -getpacket (buffer) - unsigned char *buffer; +getpacket () { + unsigned char *buffer = &remcomInBuffer[0]; unsigned char checksum; unsigned char xmitcsum; int count; @@ -382,9 +382,6 @@ putpacket(buffer) while (getDebugChar() != '+'); } -static char remcomInBuffer[BUFMAX]; -static char remcomOutBuffer[BUFMAX]; - /* Indicate to caller of mem2hex or hex2mem that there has been an error. */ static volatile int mem_err = 0; @@ -653,7 +650,7 @@ handle_exception (registers) { remcomOutBuffer[0] = 0; - ptr = getpacket(remcomInBuffer); + ptr = getpacket(); switch (*ptr++) { case '?': @@ -769,43 +766,6 @@ handle_exception (registers) asm ("call 0 nop "); break; - -#if 0 -Disabled until we can unscrew this properly - - case 'b': /* bBB... Set baud rate to BB... */ - { - int baudrate; - extern void set_timer_3(); - - if (!hexToInt(&ptr, &baudrate)) - { - strcpy(remcomOutBuffer,"B01"); - break; - } - - /* Convert baud rate to uart clock divider */ - switch (baudrate) - { - case 38400: - baudrate = 16; - break; - case 19200: - baudrate = 33; - break; - case 9600: - baudrate = 65; - break; - default: - strcpy(remcomOutBuffer,"B02"); - goto x1; - } - - putpacket("OK"); /* Ack before changing speed */ - set_timer_3(baudrate); /* Set it */ - } -x1: break; -#endif } /* switch */ /* reply to the request */ diff --git a/gdb/sparcl-stub.c b/gdb/sparcl-stub.c index 4f04b97..dbdf6d4 100644 --- a/gdb/sparcl-stub.c +++ b/gdb/sparcl-stub.c @@ -64,9 +64,6 @@ * * ? What was the last sigval ? SNN (signal NN) * - * bBB..BB Set baud rate to BB..BB OK or BNN, then sets - * baud rate - * * All commands and responses are sent with a packet which includes a * checksum. A packet consists of * @@ -380,12 +377,15 @@ hex(ch) return -1; } +static char remcomInBuffer[BUFMAX]; +static char remcomOutBuffer[BUFMAX]; + /* scan for the sequence $<data>#<checksum> */ unsigned char * -getpacket (buffer) - unsigned char *buffer; +getpacket () { + unsigned char *buffer = &remcomInBuffer[0]; unsigned char checksum; unsigned char xmitcsum; int count; @@ -478,9 +478,6 @@ putpacket(buffer) while (getDebugChar() != '+'); } -static char remcomInBuffer[BUFMAX]; -static char remcomOutBuffer[BUFMAX]; - /* Indicate to caller of mem2hex or hex2mem that there has been an error. */ static volatile int mem_err = 0; @@ -796,7 +793,7 @@ handle_exception (registers) { remcomOutBuffer[0] = 0; - ptr = getpacket(remcomInBuffer); + ptr = getpacket(); switch (*ptr++) { case '?': @@ -936,43 +933,6 @@ handle_exception (registers) asm ("call 0 nop "); break; - -#if 0 -Disabled until we can unscrew this properly - - case 'b': /* bBB... Set baud rate to BB... */ - { - int baudrate; - extern void set_timer_3(); - - if (!hexToInt(&ptr, &baudrate)) - { - strcpy(remcomOutBuffer,"B01"); - break; - } - - /* Convert baud rate to uart clock divider */ - switch (baudrate) - { - case 38400: - baudrate = 16; - break; - case 19200: - baudrate = 33; - break; - case 9600: - baudrate = 65; - break; - default: - strcpy(remcomOutBuffer,"B02"); - goto x1; - } - - putpacket("OK"); /* Ack before changing speed */ - set_timer_3(baudrate); /* Set it */ - } -x1: break; -#endif } /* switch */ /* reply to the request */ diff --git a/gdb/sparclet-stub.c b/gdb/sparclet-stub.c index 8415aa5..4d859f9 100644 --- a/gdb/sparclet-stub.c +++ b/gdb/sparclet-stub.c @@ -65,9 +65,6 @@ * * ? What was the last sigval ? SNN (signal NN) * - * bBB..BB Set baud rate to BB..BB OK or BNN, then sets - * baud rate - * * All commands and responses are sent with a packet which includes a * checksum. A packet consists of * @@ -450,12 +447,15 @@ hex(ch) return -1; } +static char remcomInBuffer[BUFMAX]; +static char remcomOutBuffer[BUFMAX]; + /* scan for the sequence $<data>#<checksum> */ unsigned char * -getpacket (buffer) - unsigned char *buffer; +getpacket () { + unsigned char *buffer = &remcomInBuffer[0]; unsigned char checksum; unsigned char xmitcsum; int count; @@ -548,9 +548,6 @@ putpacket(buffer) while (getDebugChar() != '+'); } -static char remcomInBuffer[BUFMAX]; -static char remcomOutBuffer[BUFMAX]; - /* Indicate to caller of mem2hex or hex2mem that there has been an error. */ static volatile int mem_err = 0; @@ -881,7 +878,7 @@ handle_exception (registers) { remcomOutBuffer[0] = 0; - ptr = getpacket(remcomInBuffer); + ptr = getpacket(); switch (*ptr++) { case '?': @@ -1039,43 +1036,6 @@ handle_exception (registers) asm ("call 0 nop "); break; - -#if 0 -Disabled until we can unscrew this properly - - case 'b': /* bBB... Set baud rate to BB... */ - { - int baudrate; - extern void set_timer_3(); - - if (!hexToInt(&ptr, &baudrate)) - { - strcpy(remcomOutBuffer,"B01"); - break; - } - - /* Convert baud rate to uart clock divider */ - switch (baudrate) - { - case 38400: - baudrate = 16; - break; - case 19200: - baudrate = 33; - break; - case 9600: - baudrate = 65; - break; - default: - strcpy(remcomOutBuffer,"B02"); - goto x1; - } - - putpacket("OK"); /* Ack before changing speed */ - set_timer_3(baudrate); /* Set it */ - } -x1: break; -#endif } /* switch */ /* reply to the request */ diff --git a/gdb/stabsread.h b/gdb/stabsread.h index 648eea3..c5e1ce7 100644 --- a/gdb/stabsread.h +++ b/gdb/stabsread.h @@ -188,11 +188,6 @@ struct stab_section_list they are only used by some stabs readers. */ extern struct partial_symtab * - start_psymtab PARAMS ((struct objfile *, struct section_offsets *, char *, - CORE_ADDR, int, struct partial_symbol **, - struct partial_symbol **)); - -extern struct partial_symtab * end_psymtab PARAMS ((struct partial_symtab * pst, char **include_list, int num_includes, diff --git a/gdb/symfile.c b/gdb/symfile.c index ce9a609..642501f 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -457,23 +457,20 @@ find_lowest_section (abfd, sect, obj) don't need to do anything special. It allocates a section_offsets table for the objectfile OBJFILE and stuffs ADDR into all of the offsets. */ -struct section_offsets * +void default_symfile_offsets (objfile, addr) struct objfile *objfile; CORE_ADDR addr; { - struct section_offsets *section_offsets; int i; objfile->num_sections = SECT_OFF_MAX; - section_offsets = (struct section_offsets *) + objfile->section_offsets = (struct section_offsets *) obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS); - memset (section_offsets, 0, SIZEOF_SECTION_OFFSETS); + memset (objfile->section_offsets, 0, SIZEOF_SECTION_OFFSETS); for (i = 0; i < SECT_OFF_MAX; i++) - ANOFFSET (section_offsets, i) = addr; - - return section_offsets; + ANOFFSET (objfile->section_offsets, i) = addr; } @@ -563,8 +560,7 @@ syms_from_objfile (objfile, addr, mainline, verbo) (*objfile->sf->sym_init) (objfile); clear_complaints (1, verbo); - section_offsets = (*objfile->sf->sym_offsets) (objfile, addr); - objfile->section_offsets = section_offsets; + (*objfile->sf->sym_offsets) (objfile, addr); #ifndef IBM6000_TARGET /* This is a SVR4/SunOS specific hack, I think. In any event, it @@ -1193,7 +1189,7 @@ generic_load (filename, from_tty) { unsigned long entry; entry = bfd_get_start_address (loadfile_bfd); - printf_filtered ("Start address 0x%lx , load size %d\n", entry, data_count); + printf_filtered ("Start address 0x%lx , load size %ld\n", entry, data_count); /* We were doing this in remote-mips.c, I suspect it is right for other targets too. */ write_pc (entry); @@ -1219,10 +1215,10 @@ report_transfer_performance (data_count, start_time, end_time) { printf_filtered ("Transfer rate: "); if (end_time != start_time) - printf_filtered ("%d bits/sec", + printf_filtered ("%ld bits/sec", (data_count * 8) / (end_time - start_time)); else - printf_filtered ("%d bits in <1 sec", (data_count * 8)); + printf_filtered ("%ld bits in <1 sec", (data_count * 8)); printf_filtered (".\n"); } @@ -1379,7 +1375,6 @@ reread_symbols () struct cleanup *old_cleanups; struct section_offsets *offsets; int num_offsets; - int section_offsets_size; char *obfd_filename; printf_filtered ("`%s' has changed; re-reading symbols.\n", @@ -1418,11 +1413,8 @@ reread_symbols () /* Save the offsets, we will nuke them with the rest of the psymbol_obstack. */ num_offsets = objfile->num_sections; - section_offsets_size = - sizeof (struct section_offsets) - + sizeof (objfile->section_offsets->offsets) * num_offsets; - offsets = (struct section_offsets *) alloca (section_offsets_size); - memcpy (offsets, objfile->section_offsets, section_offsets_size); + offsets = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS); + memcpy (offsets, objfile->section_offsets, SIZEOF_SECTION_OFFSETS); /* Nuke all the state that we will re-read. Much of the following code which sets things to NULL really is necessary to tell @@ -1479,8 +1471,8 @@ reread_symbols () /* We use the same section offsets as from last time. I'm not sure whether that is always correct for shared libraries. */ objfile->section_offsets = (struct section_offsets *) - obstack_alloc (&objfile->psymbol_obstack, section_offsets_size); - memcpy (objfile->section_offsets, offsets, section_offsets_size); + obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS); + memcpy (objfile->section_offsets, offsets, SIZEOF_SECTION_OFFSETS); objfile->num_sections = num_offsets; /* What the hell is sym_new_init for, anyway? The concept of @@ -2037,10 +2029,7 @@ again2: /* Allocate and partially fill a partial symtab. It will be completely filled at the end of the symbol list. - SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR - is the address relative to which its symbols are (incremental) or 0 - (normal). */ - + FILENAME is the name of the symbol-file we are reading from. */ struct partial_symtab * start_psymtab_common (objfile, section_offsets, diff --git a/gdb/symfile.h b/gdb/symfile.h index 875f1b5..7287c8f 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -77,12 +77,9 @@ struct sym_fns void (*sym_init) PARAMS ((struct objfile *)); - /* sym_read (objfile, addr, mainline) + /* sym_read (objfile, mainline) Reads a symbol file into a psymtab (or possibly a symtab). OBJFILE is the objfile struct for the file we are reading. - SECTION_OFFSETS - are the offset between the file's specified section addresses and - their true addresses in memory. MAINLINE is 1 if this is the main symbol table being read, and 0 if a secondary symbol file (e.g. shared library or dynamically loaded file) @@ -100,9 +97,9 @@ struct sym_fns The parameter is currently a CORE_ADDR (FIXME!) for backward compatibility with the higher levels of GDB. It should probably be changed to a string, where NULL means the default, and others are parsed in a file - dependent way. The result of this function is handed in to sym_read. */ + dependent way. */ - struct section_offsets *(*sym_offsets) PARAMS ((struct objfile *, CORE_ADDR)); + void (*sym_offsets) PARAMS ((struct objfile *, CORE_ADDR)); /* Finds the next struct sym_fns. They are allocated and initialized in whatever module implements the functions pointed to; an @@ -115,7 +112,7 @@ struct sym_fns /* The default version of sym_fns.sym_offsets for readers that don't do anything special. */ -extern struct section_offsets * +extern void default_symfile_offsets PARAMS ((struct objfile * objfile, CORE_ADDR addr)); @@ -270,16 +267,15 @@ extern CORE_ADDR /* From dwarfread.c */ extern void -dwarf_build_psymtabs PARAMS ((struct objfile *, struct section_offsets *, int, - file_ptr, unsigned int, file_ptr, unsigned int)); +dwarf_build_psymtabs PARAMS ((struct objfile *, int, file_ptr, unsigned int, + file_ptr, unsigned int)); /* From dwarf2read.c */ extern int dwarf2_has_info PARAMS ((bfd * abfd)); -extern void dwarf2_build_psymtabs PARAMS ((struct objfile *, - struct section_offsets *, - int)); +extern void dwarf2_build_psymtabs PARAMS ((struct objfile *, int)); + /* From mdebugread.c */ /* Hack to force structures to exist before use in parameter list. */ @@ -291,13 +287,11 @@ struct ecoff_debug_hack extern void mdebug_build_psymtabs PARAMS ((struct objfile *, const struct ecoff_debug_swap *, - struct ecoff_debug_info *, - struct section_offsets *)); + struct ecoff_debug_info *)); extern void elfmdebug_build_psymtabs PARAMS ((struct objfile *, const struct ecoff_debug_swap *, - asection *, - struct section_offsets *)); + asection *)); #endif /* !defined(SYMFILE_H) */ diff --git a/gdb/symmisc.c b/gdb/symmisc.c index ca40a69..2bf70c2 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -218,9 +218,9 @@ dump_objfile (objfile) printf_filtered ("\nObject file %s: ", objfile->name); printf_filtered ("Objfile at "); - gdb_print_address (objfile, gdb_stdout); + gdb_print_host_address (objfile, gdb_stdout); printf_filtered (", bfd at "); - gdb_print_address (objfile->obfd, gdb_stdout); + gdb_print_host_address (objfile->obfd, gdb_stdout); printf_filtered (", %d minsyms\n\n", objfile->minimal_symbol_count); @@ -233,7 +233,7 @@ dump_objfile (objfile) { printf_filtered ("%s at ", psymtab->filename); - gdb_print_address (psymtab, gdb_stdout); + gdb_print_host_address (psymtab, gdb_stdout); printf_filtered (", "); if (psymtab->objfile != objfile) { @@ -252,7 +252,7 @@ dump_objfile (objfile) symtab = symtab->next) { printf_filtered ("%s at ", symtab->filename); - gdb_print_address (symtab, gdb_stdout); + gdb_print_host_address (symtab, gdb_stdout); printf_filtered (", "); if (symtab->objfile != objfile) { @@ -353,20 +353,20 @@ dump_psymtab (objfile, psymtab, outfile) fprintf_filtered (outfile, "\nPartial symtab for source file %s ", psymtab->filename); fprintf_filtered (outfile, "(object "); - gdb_print_address (psymtab, outfile); + gdb_print_host_address (psymtab, outfile); fprintf_filtered (outfile, ")\n\n"); fprintf_unfiltered (outfile, " Read from object file %s (", objfile->name); - gdb_print_address (objfile, outfile); + gdb_print_host_address (objfile, outfile); fprintf_unfiltered (outfile, ")\n"); if (psymtab->readin) { fprintf_filtered (outfile, " Full symtab was read (at "); - gdb_print_address (psymtab->symtab, outfile); + gdb_print_host_address (psymtab->symtab, outfile); fprintf_filtered (outfile, " by function at "); - gdb_print_address ((PTR) psymtab->read_symtab, outfile); + gdb_print_host_address ((PTR) psymtab->read_symtab, outfile); fprintf_filtered (outfile, ")\n"); } @@ -392,7 +392,7 @@ dump_psymtab (objfile, psymtab, outfile) for (i = 0; i < psymtab->number_of_dependencies; i++) { fprintf_filtered (outfile, " %d ", i); - gdb_print_address (psymtab->dependencies[i], outfile); + gdb_print_host_address (psymtab->dependencies[i], outfile); fprintf_filtered (outfile, " %s\n", psymtab->dependencies[i]->filename); } @@ -429,7 +429,7 @@ dump_symtab (objfile, symtab, outfile) fprintf_filtered (outfile, "Compilation directory is %s\n", symtab->dirname); fprintf_filtered (outfile, "Read from object file %s (", objfile->name); - gdb_print_address (objfile, outfile); + gdb_print_host_address (objfile, outfile); fprintf_filtered (outfile, ")\n"); fprintf_filtered (outfile, "Language: %s\n", language_str (symtab->language)); @@ -459,11 +459,11 @@ dump_symtab (objfile, symtab, outfile) depth = block_depth (b) * 2; print_spaces (depth, outfile); fprintf_filtered (outfile, "block #%03d, object at ", i); - gdb_print_address (b, outfile); + gdb_print_host_address (b, outfile); if (BLOCK_SUPERBLOCK (b)) { fprintf_filtered (outfile, " under "); - gdb_print_address (BLOCK_SUPERBLOCK (b), outfile); + gdb_print_host_address (BLOCK_SUPERBLOCK (b), outfile); } blen = BLOCK_NSYMS (b); fprintf_filtered (outfile, ", %d syms in ", blen); @@ -705,7 +705,7 @@ print_symbol (args) case LOC_BLOCK: fprintf_filtered (outfile, "block object "); - gdb_print_address (SYMBOL_BLOCK_VALUE (symbol), outfile); + gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol), outfile); fprintf_filtered (outfile, ", "); print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (symbol)), 1, diff --git a/gdb/symtab.c b/gdb/symtab.c index 2ade65fc..e6a67b0 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1073,7 +1073,6 @@ lookup_transparent_type (name) struct blockvector *bv; register struct objfile *objfile; register struct block *block; - register struct minimal_symbol *msymbol; /* Now search all the global symbols. Do the symtab's first, then check the psymtab's. If a psymtab indicates the existence @@ -2664,7 +2663,6 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical) *argptr = *argptr + 1; if (p[0] == '.' || p[1] == ':') { - int ix; char *saved_arg2 = *argptr; char *temp_end; /* First check for "global" namespace specification, @@ -4464,11 +4462,10 @@ make_symbol_overload_list (fsym) register struct symbol *sym; register struct symtab *s; register struct partial_symtab *ps; - register struct minimal_symbol *msymbol; register struct objfile *objfile; + register struct minimal_symbol *msymbol; register struct block *b, *surrounding_static_block = 0; - register int i, j; - struct partial_symbol **psym; + register int i; /* The name we are completing on. */ char *oload_name = NULL; /* Length of name. */ @@ -4505,6 +4502,8 @@ make_symbol_overload_list (fsym) ALL_PSYMTABS (objfile, ps) { + struct partial_symbol **psym; + /* If the psymtab's been read in we'll get it when we search through the blockvector. */ if (ps->readin) diff --git a/gdb/symtab.h b/gdb/symtab.h index 86a119a..0d9903b 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -854,7 +854,7 @@ struct symtab int block_line_section; /* If several symtabs share a blockvector, exactly one of them - should be designed the primary, so that the blockvector + should be designated the primary, so that the blockvector is relocated exactly once by objfile_relocate. */ int primary; diff --git a/gdb/target.c b/gdb/target.c index 07df980..fc1f64b 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -1272,6 +1272,7 @@ static struct { {"SIG62", "Real-time event 62"}, {"SIG63", "Real-time event 63"}, {"SIGCANCEL", "LWP internal signal"}, + {"SIG32", "Real-time event 32"}, #if defined(MACH) || defined(__MACH__) /* Mach exceptions */ @@ -1571,8 +1572,16 @@ target_signal_from_host (hostsig) #if defined (REALTIME_LO) if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI) - return (enum target_signal) - (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33); + { + /* This block of TARGET_SIGNAL_REALTIME value is in order. */ + if (33 <= hostsig && hostsig <= 63) + return (enum target_signal) + (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33); + else if (hostsig == 32) + return TARGET_SIGNAL_REALTIME_32; + else + error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal"); + } #endif return TARGET_SIGNAL_UNKNOWN; } @@ -1771,6 +1780,8 @@ target_signal_to_host (oursig) return SIGPRIO; #endif + case TARGET_SIGNAL_REALTIME_32: return 32; /* by definition */ + /* Mach exceptions. Assumes that the values for EXC_ are positive! */ #if defined (EXC_BAD_ACCESS) && defined (_NSIG) case TARGET_EXC_BAD_ACCESS: diff --git a/gdb/target.h b/gdb/target.h index fd4ffe5..e038802 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -50,7 +50,8 @@ enum strata file_stratum, /* Executable files, etc */ core_stratum, /* Core dump files */ download_stratum, /* Downloading of remote targets */ - process_stratum /* Executing processes */ + process_stratum, /* Executing processes */ + thread_stratum /* Executing threads */ }; enum thread_control_capabilities @@ -219,6 +220,12 @@ enum target_signal /* Used internally by Solaris threads. See signal(5) on Solaris. */ TARGET_SIGNAL_CANCEL = 76, + /* Yes, this pains me, too. But LynxOS didn't have SIG32, and now + Linux does, and we can't disturb the numbering, since it's part + of the protocol. Note that in some GDB's TARGET_SIGNAL_REALTIME_32 + is number 76. */ + TARGET_SIGNAL_REALTIME_32, + #if defined(MACH) || defined(__MACH__) /* Mach exceptions */ TARGET_EXC_BAD_ACCESS, diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index aa1d60b..15dd281 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,49 @@ +1999-09-08 Stan Shebs <shebs@andros.cygnus.com> + + * break.c (main): Compare a possibly-uninitialized argc with an + unlikely value that fits in 16 bits. + +1999-09-07 Stan Shebs <shebs@andros.cygnus.com> + + * gdb.base/restore.c, gdb.base/restore.exp: Use 0x7eeb instead of + 0xfeeb, don't want negative numbers if ints are 16 bits. + + * lib/gdb.exp (skip_cplus_tests): New proc. + * gdb.c++/ambiguous.exp, gdb.c++/annota2.exp, + gdb.c++/anon-union.exp, gdb.c++/classes.exp, + gdb.c++/cplusfuncs.exp, gdb.c++/ctti.exp, gdb.c++/demangle.exp, + gdb.c++/derivation.exp, gdb.c++/inherit.exp, gdb.c++/local.exp, + gdb.c++/member-ptr.exp, gdb.c++/method.exp, gdb.c++/misc.exp, + gdb.c++/overload.exp, gdb.c++/ovldbreak.exp, + gdb.c++/ref-types.exp, gdb.c++/templates.exp, gdb.c++/userdef.exp, + gdb.c++/virtfunc.exp: Use it to skip over C++ tests. + + * gdb.c++/cplusfuncs.exp: Use get_compiler_info consistently. + +Fri Sep 3 15:37:12 1999 Kevin Buettner <kevinb@cygnus.com> + + * gdb.base/corefile.exp (up): Allow a parameter to appear + in the frame that we're going up to. + + From Jim Blandy <jimb@cygnus.com>: + + * gdb.base/default.exp (info float): Expect some output now. + + * gdb.base/callfuncs.exp (do_function_calls): We no longer expect + returning floating-point values to fail on the x86. + * gdb.base/callfwmall.exp (do_function_calls): Same. + + * gdb.base/list.exp (test_listsize): Correct expectations for + listing line 1 with listsize 2. Also, listing a single line + works now, as does listing three lines. [Kevin's note: There + were a number of other cases fixed too where the expectations + differed...] + +1999-09-02 Stan Shebs <shebs@andros.cygnus.com> + + * gdb.base/selftest.exp: Add case for when version prints as + constant string instead of char pointer. + 1999-08-25 Stan Shebs <shebs@andros.cygnus.com> * gdb.base/ending-run.exp: Add Solaris case for what happens when diff --git a/gdb/testsuite/gdb.base/break.c b/gdb/testsuite/gdb.base/break.c index 6acbf9b..7e5fb8e 100644 --- a/gdb/testsuite/gdb.base/break.c +++ b/gdb/testsuite/gdb.base/break.c @@ -72,7 +72,7 @@ char *argv[], **envp; set_debug_traps(); breakpoint(); #endif - if (argc == 123456) { + if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ fprintf (stderr, "usage: factorial <number>\n"); return 1; } diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp index 1ce9683..397a255 100644 --- a/gdb/testsuite/gdb.base/callfuncs.exp +++ b/gdb/testsuite/gdb.base/callfuncs.exp @@ -229,10 +229,8 @@ proc do_function_calls {} { "call inferior func with struct - returns int" gdb_test "p t_structs_l(struct_val1)" "= 51" \ "call inferior func with struct - returns long" - setup_xfail "i*86-*-*" gdb_test "p t_structs_f(struct_val1)" "= 2.12.*" \ "call inferior func with struct - returns float" - setup_xfail "i*86-*-*" gdb_test "p t_structs_d(struct_val1)" "= 9.87.*" \ "call inferior func with struct - returns double" gdb_test "p t_structs_a(struct_val1)" "= (.unsigned char .. )?\"foo\"" \ diff --git a/gdb/testsuite/gdb.base/callfwmall.exp b/gdb/testsuite/gdb.base/callfwmall.exp index 7d7cf78..16851e6 100644 --- a/gdb/testsuite/gdb.base/callfwmall.exp +++ b/gdb/testsuite/gdb.base/callfwmall.exp @@ -236,10 +236,8 @@ proc do_function_calls {} { "call inferior func with struct - returns int" gdb_test "p t_structs_l(struct_val1)" "= 51" \ "call inferior func with struct - returns long" - setup_xfail "i*86-*-*" gdb_test "p t_structs_f(struct_val1)" "= 2.12.*" \ "call inferior func with struct - returns float" - setup_xfail "i*86-*-*" gdb_test "p t_structs_d(struct_val1)" "= 9.87.*" \ "call inferior func with struct - returns double" gdb_test "p t_structs_a(struct_val1)" "= (.unsigned char .. )?\"foo\"" \ diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp index 32f3f56..f998f88 100644 --- a/gdb/testsuite/gdb.base/corefile.exp +++ b/gdb/testsuite/gdb.base/corefile.exp @@ -189,7 +189,7 @@ gdb_test "print func2::coremaker_local" "\\\$$decimal = {0, 1, 2, 3, 4}" # file correctly. I don't think the other tests do this. gdb_test "bt" "abort.*func2.*func1.*main.*" "backtrace in corefile.exp" -gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(\\).*" "up in corefile.exp" +gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp" # Test ability to read mmap'd data diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp index 528d5a9..f73a6d7 100644 --- a/gdb/testsuite/gdb.base/default.exp +++ b/gdb/testsuite/gdb.base/default.exp @@ -304,6 +304,8 @@ if [istarget "arm-*-*"] then { gdb_test "info float" "Software FPU type.*mask:.*flags:.*" "info float" } elseif [istarget "strongarm-*-*"] then { gdb_test "info float" "Software FPU type.*mask:.*flags:.*" "info float" +} elseif [istarget "i\[3456\]86-*-linux-gnu"] then { + gdb_test "info float" "No registers." } else { gdb_test "info float" "No floating point info available for this processor." "info float" } diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp index f319ba0..b9dad0a 100644 --- a/gdb/testsuite/gdb.base/list.exp +++ b/gdb/testsuite/gdb.base/list.exp @@ -111,7 +111,7 @@ proc test_listsize {} { # Try just two lines if [ set_listsize 2 ] { - gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"" "list line 1 with listsize 2" + gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+" "list line 1 with listsize 2" gdb_test "list 2" "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+" "list line 2 with listsize 2" gdb_test "list 3" "2\[ \t\]+\r\n3\[ \t\]+int main \[)(\]+" "list line 3 with listsize 2" } @@ -119,18 +119,16 @@ proc test_listsize {} { # Try small listsize > 1 that is an odd number if [ set_listsize 3 ] { - setup_xfail "*-*-*" - gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"2\[ \t\]+" "list line 1 with listsize 3" + gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+int main \[)(\]+" "list line 1 with listsize 3" gdb_test "list 2" "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+int main \[)(\]+" "list line 2 with listsize 3" - gdb_test "list 3" "2\[ \t\]+\r\n3\[ \t\]+int main \[(\]+\[)\]+\r\n4\[ \t\]+\{" "list line 3 with listsize 3" } # Try small listsize > 2 that is an even number. if [ set_listsize 4 ] then { - gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+" "list line 1 with listsize 4" - gdb_test "list 2" "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+int main \[)(\]+" "list line 2 with listsize 4" + gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 1 with listsize 4" + gdb_test "list 2" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 2 with listsize 4" gdb_test "list 3" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 3 with listsize 4" gdb_test "list 4" "2\[ \t\]+\r\n.*5\[ \t\]+int x;.*" "list line 4 with listsize 4" @@ -166,7 +164,7 @@ proc test_list_include_file {} { setup_xfail "a29k-*-udi" setup_xfail_format "DWARF 1" setup_xfail_format "COFF" - gdb_test "list list0.h:1" "1\[ \t\]+/\[*\]+ An include file .*4\[ \t\]+.*foo \(.*x.*\).*" "list line 1 in include file" + gdb_test "list list0.h:1" "1\[ \t\]+/\[*\]+ An include file .*10\[ \t\]+bar \\(x\\+\\+\\);" "list line 1 in include file" setup_xfail "a29k-*-udi" setup_xfail_format "DWARF 1" @@ -185,7 +183,7 @@ proc test_list_filename_and_number {} { send_gdb "list list0.c:1\n" gdb_expect { - -re "1\[ \t\]+#include \"list0.h\".*5\[ \t\]+int x;\r\n$gdb_prompt $" { + -re "1\[ \t\]+#include \"list0.h\".*10\[ \t]+x = 0;\r\n$gdb_prompt $" { incr testcnt } -re ".*$gdb_prompt $" { fail "list list0.c:1" ; gdb_suppress_tests } @@ -231,7 +229,7 @@ proc test_list_function {} { # in include files, which breaks this test. # SunPRO cc is the second case below, it's also correct. setup_xfail "a29k-*-udi" - gdb_test "list main" "(5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;|1\[ \t\]+#include .*8\[ \t\]+breakpoint\[(\]\[)\]+;)" "list function in source file 1" + gdb_test "list main" "(5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;|1\[ \t\]+#include .*10\[ \t\]+x = 0;)" "list function in source file 1" # Ultrix gdb takes the second case below; it's also correct. # SunPRO cc is the third case. @@ -398,7 +396,7 @@ proc test_list_filename_and_function {} { setup_xfail "a29k-*-udi" send_gdb "list list0.c:main\n" gdb_expect { - -re "1\[ \t\]+#include .*8\[ \t\]+breakpoint\[(\]\[)\]+;\r\n$gdb_prompt $" { + -re "1\[ \t\]+#include .*10\[ \t\]+x = 0;\r\n$gdb_prompt $" { incr testcnt } -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { diff --git a/gdb/testsuite/gdb.base/restore.c b/gdb/testsuite/gdb.base/restore.c index 2469430..974e944 100644 --- a/gdb/testsuite/gdb.base/restore.c +++ b/gdb/testsuite/gdb.base/restore.c @@ -65,7 +65,7 @@ (insert "int\n") (insert (caller i) " (void)\n") (insert "{\n") - (let ((last (local-chain i "0xfeeb" (caller i)))) + (let ((last (local-chain i "0x7eeb" (caller i)))) (insert " register int n;\n") (let ((j 0)) (while (<= j limit) @@ -159,7 +159,7 @@ callee5 (int n) int caller1 (void) { - register int l1 = increment (0xfeeb); /* caller1 */ + register int l1 = increment (0x7eeb); /* caller1 */ register int n; n = callee0 (l1); n = callee1 (n + l1); @@ -173,7 +173,7 @@ caller1 (void) int caller2 (void) { - register int l1 = increment (0xfeeb); /* caller2 */ + register int l1 = increment (0x7eeb); /* caller2 */ register int l2 = increment (l1); register int n; n = callee0 (l2); @@ -188,7 +188,7 @@ caller2 (void) int caller3 (void) { - register int l1 = increment (0xfeeb); /* caller3 */ + register int l1 = increment (0x7eeb); /* caller3 */ register int l2 = increment (l1); register int l3 = increment (l2); register int n; @@ -204,7 +204,7 @@ caller3 (void) int caller4 (void) { - register int l1 = increment (0xfeeb); /* caller4 */ + register int l1 = increment (0x7eeb); /* caller4 */ register int l2 = increment (l1); register int l3 = increment (l2); register int l4 = increment (l3); @@ -221,7 +221,7 @@ caller4 (void) int caller5 (void) { - register int l1 = increment (0xfeeb); /* caller5 */ + register int l1 = increment (0x7eeb); /* caller5 */ register int l2 = increment (l1); register int l3 = increment (l2); register int l4 = increment (l3); diff --git a/gdb/testsuite/gdb.base/restore.exp b/gdb/testsuite/gdb.base/restore.exp index 64b714b..8cf5035 100644 --- a/gdb/testsuite/gdb.base/restore.exp +++ b/gdb/testsuite/gdb.base/restore.exp @@ -80,7 +80,7 @@ proc restore_tests { } { # Check that the values of the local variables are what # they should be. for {set var 1} {$var <= $c} {incr var} { - set expected [expr 0xfeeb + $var] + set expected [expr 0x7eeb + $var] gdb_test "print l$var" " = $expected" \ "caller$c called callee$e; variable l$var restored" } diff --git a/gdb/testsuite/gdb.base/selftest.exp b/gdb/testsuite/gdb.base/selftest.exp index c0d17c8..72a086e 100644 --- a/gdb/testsuite/gdb.base/selftest.exp +++ b/gdb/testsuite/gdb.base/selftest.exp @@ -254,8 +254,11 @@ proc test_with_self { executable } { # do we have a version number ? send_gdb "print version\n" gdb_expect { + -re ".\[0-9\]+ = .\[0-9.\]+.*$gdb_prompt $" { + pass "printed version as string" + } -re ".\[0-9\]+ = +0x.*\[0-9.\]+.*$gdb_prompt $" { - pass "printed version" + pass "printed version as pointer" } -re ".\[0-9\]+ = +.+ +0x.*\[0-9.\]+.*$gdb_prompt $" { pass "printed version with cast" diff --git a/gdb/testsuite/gdb.c++/ambiguous.exp b/gdb/testsuite/gdb.c++/ambiguous.exp index 998b478..6ee60e7 100644 --- a/gdb/testsuite/gdb.c++/ambiguous.exp +++ b/gdb/testsuite/gdb.c++/ambiguous.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1998 Free Software Foundation, Inc. +# Copyright (C) 1998, 1999 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -35,6 +35,8 @@ if $tracelevel then { set prms_id 0 set bug_id 0 +if { [skip_cplus_tests] } { continue } + set testfile "ambiguous" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} diff --git a/gdb/testsuite/gdb.c++/annota2.exp b/gdb/testsuite/gdb.c++/annota2.exp index 0a58cd4..1e25c5d 100644 --- a/gdb/testsuite/gdb.c++/annota2.exp +++ b/gdb/testsuite/gdb.c++/annota2.exp @@ -31,6 +31,8 @@ if $tracelevel then { set prms_id 0 set bug_id 0 +if { [skip_cplus_tests] } { continue } + set testfile "annota2" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} diff --git a/gdb/testsuite/gdb.c++/anon-union.exp b/gdb/testsuite/gdb.c++/anon-union.exp index 5ed924f..767ef02 100644 --- a/gdb/testsuite/gdb.c++/anon-union.exp +++ b/gdb/testsuite/gdb.c++/anon-union.exp @@ -1,4 +1,5 @@ -# Copyright (C) 1998 Free Software Foundation, Inc. +# Tests for anonymous union support. +# Copyright (C) 1998, 1999 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,8 +18,6 @@ # Please email any bugs, comments, and/or additions to this file to: # bug-gdb@prep.ai.mit.edu -# -# Tests for anonymous union support # Written by Satish Pai <pai@apollo.hp.com> 1997-08-19 # This file is part of the gdb testsuite @@ -34,9 +33,12 @@ if $tracelevel then { set prms_id 0 set bug_id 0 +if { [skip_cplus_tests] } { continue } + set testfile "anon-union" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.c++/classes.exp b/gdb/testsuite/gdb.c++/classes.exp index cf6a2cd..91a0400 100644 --- a/gdb/testsuite/gdb.c++/classes.exp +++ b/gdb/testsuite/gdb.c++/classes.exp @@ -26,10 +26,7 @@ if $tracelevel then { strace $tracelevel } - -# Check to see if we have an executable to test. If not, then either we -# haven't tried to compile one, or the compilation failed for some reason. -# In either case, just notify the user and skip the tests in this file. +if { [skip_cplus_tests] } { continue } set testfile "misc" set srcfile ${testfile}.cc @@ -42,7 +39,6 @@ if [get_compiler_info ${binfile} "c++"] { return -1 } - if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.c++/cplusfuncs.exp b/gdb/testsuite/gdb.c++/cplusfuncs.exp index 16283f3..d3783a3 100644 --- a/gdb/testsuite/gdb.c++/cplusfuncs.exp +++ b/gdb/testsuite/gdb.c++/cplusfuncs.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1992, 1997 Free Software Foundation, Inc. +# Copyright (C) 1992, 1997, 1999 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,21 +23,20 @@ if $tracelevel then { strace $tracelevel } -# Check to see if we have an executable to test. If not, then either we -# haven't tried to compile one, or the compilation failed for some reason. -# In either case, just notify the user and skip the tests in this file. +if { [skip_cplus_tests] } { continue } set testfile "cplusfuncs" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { - gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." -} -if {[get_compiler_info $binfile "c++"] == -1} { +if { [get_compiler_info $binfile "c++"] } { return -1 } +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + # # Cause gdb to lookup a specific C++ function and print the demangled # form. diff --git a/gdb/testsuite/gdb.c++/ctti.exp b/gdb/testsuite/gdb.c++/ctti.exp index b8c7cc9..135dcf4 100644 --- a/gdb/testsuite/gdb.c++/ctti.exp +++ b/gdb/testsuite/gdb.c++/ctti.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1998 Free Software Foundation, Inc. +# Copyright (C) 1998, 1999 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,10 +29,7 @@ if $tracelevel then { strace $tracelevel } - -# Check to see if we have an executable to test. If not, then either we -# haven't tried to compile one, or the compilation failed for some reason. -# In either case, just notify the user and skip the tests in this file. +if { [skip_cplus_tests] } { continue } set testfile "cttiadd" set srcfile ${testfile}.cc diff --git a/gdb/testsuite/gdb.c++/demangle.exp b/gdb/testsuite/gdb.c++/demangle.exp index d63ab04..0c96431 100644 --- a/gdb/testsuite/gdb.c++/demangle.exp +++ b/gdb/testsuite/gdb.c++/demangle.exp @@ -23,6 +23,8 @@ if $tracelevel then { strace $tracelevel } +if { [skip_cplus_tests] } { continue } + ### The demangling style we last sent to GDB. set current_demangling_style none diff --git a/gdb/testsuite/gdb.c++/derivation.exp b/gdb/testsuite/gdb.c++/derivation.exp index 31cdd6f..031985a 100644 --- a/gdb/testsuite/gdb.c++/derivation.exp +++ b/gdb/testsuite/gdb.c++/derivation.exp @@ -39,10 +39,19 @@ if $tracelevel then { set prms_id 0 set bug_id 0 +if { [skip_cplus_tests] } { continue } + set testfile "derivation" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} +# Create and source the file that provides information about the compiler +# used to compile the test case. + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.c++/inherit.exp b/gdb/testsuite/gdb.c++/inherit.exp index b1c28ed..e39b12a 100644 --- a/gdb/testsuite/gdb.c++/inherit.exp +++ b/gdb/testsuite/gdb.c++/inherit.exp @@ -26,9 +26,8 @@ if $tracelevel then { strace $tracelevel } -# Check to see if we have an executable to test. If not, then either we -# haven't tried to compile one, or the compilation failed for some reason. -# In either case, just notify the user and skip the tests in this file. +if { [skip_cplus_tests] } { continue } + # Note - create separate "inherit" executable from misc.cc set testfile "inherit" diff --git a/gdb/testsuite/gdb.c++/local.exp b/gdb/testsuite/gdb.c++/local.exp index 66b6d63..6ec777b 100644 --- a/gdb/testsuite/gdb.c++/local.exp +++ b/gdb/testsuite/gdb.c++/local.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1998 Free Software Foundation, Inc. +# Copyright (C) 1998, 1999 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -33,6 +33,8 @@ if $tracelevel then { set prms_id 0 set bug_id 0 +if { [skip_cplus_tests] } { continue } + set testfile "local" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} diff --git a/gdb/testsuite/gdb.c++/member-ptr.exp b/gdb/testsuite/gdb.c++/member-ptr.exp index d1de663..b7c6206 100644 --- a/gdb/testsuite/gdb.c++/member-ptr.exp +++ b/gdb/testsuite/gdb.c++/member-ptr.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1998 Free Software Foundation, Inc. +# Copyright (C) 1998, 1999 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,6 +26,8 @@ if $tracelevel then { strace $tracelevel } +if { [skip_cplus_tests] } { continue } + # # test running programs # diff --git a/gdb/testsuite/gdb.c++/method.exp b/gdb/testsuite/gdb.c++/method.exp index a0d005b..b3c725c 100644 --- a/gdb/testsuite/gdb.c++/method.exp +++ b/gdb/testsuite/gdb.c++/method.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1998 Free Software Foundation, Inc. +# Copyright (C) 1998, 1999 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -42,6 +42,8 @@ if $tracelevel then { set prms_id 0 set bug_id 0 +if { [skip_cplus_tests] } { continue } + set testfile "method" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} diff --git a/gdb/testsuite/gdb.c++/misc.exp b/gdb/testsuite/gdb.c++/misc.exp index 7d64e4a..07465ac 100644 --- a/gdb/testsuite/gdb.c++/misc.exp +++ b/gdb/testsuite/gdb.c++/misc.exp @@ -23,9 +23,7 @@ if $tracelevel then { strace $tracelevel } -# Check to see if we have an executable to test. If not, then either we -# haven't tried to compile one, or the compilation failed for some reason. -# In either case, just notify the user and skip the tests in this file. +if { [skip_cplus_tests] } { continue } set testfile "misc" set srcfile ${testfile}.cc diff --git a/gdb/testsuite/gdb.c++/overload.exp b/gdb/testsuite/gdb.c++/overload.exp index c49d76a..fa12bff 100644 --- a/gdb/testsuite/gdb.c++/overload.exp +++ b/gdb/testsuite/gdb.c++/overload.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1998 Free Software Foundation, Inc. +# Copyright (C) 1998, 1999 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -35,6 +35,8 @@ if $tracelevel then { set prms_id 0 set bug_id 0 +if { [skip_cplus_tests] } { continue } + set testfile "overload" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} diff --git a/gdb/testsuite/gdb.c++/ovldbreak.exp b/gdb/testsuite/gdb.c++/ovldbreak.exp index 34f2404..d7482bd 100644 --- a/gdb/testsuite/gdb.c++/ovldbreak.exp +++ b/gdb/testsuite/gdb.c++/ovldbreak.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1998 Free Software Foundation, Inc. +# Copyright (C) 1998, 1999 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -36,6 +36,8 @@ if $tracelevel then { set prms_id 0 set bug_id 0 +if { [skip_cplus_tests] } { continue } + set testfile "ovldbreak" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} diff --git a/gdb/testsuite/gdb.c++/ref-types.exp b/gdb/testsuite/gdb.c++/ref-types.exp index 611dc6f..a528fd64 100644 --- a/gdb/testsuite/gdb.c++/ref-types.exp +++ b/gdb/testsuite/gdb.c++/ref-types.exp @@ -30,6 +30,8 @@ if $tracelevel then { set prms_id 0 set bug_id 0 +if { [skip_cplus_tests] } { continue } + set testfile "ref-types" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} diff --git a/gdb/testsuite/gdb.c++/templates.exp b/gdb/testsuite/gdb.c++/templates.exp index 6c643b1..99c2551 100644 --- a/gdb/testsuite/gdb.c++/templates.exp +++ b/gdb/testsuite/gdb.c++/templates.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1992, 1996, 1997 Free Software Foundation, Inc. +# Copyright (C) 1992, 1996, 1997, 1999 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,6 +25,8 @@ if $tracelevel then { strace $tracelevel } +if { [skip_cplus_tests] } { continue } + set testfile "templates" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} diff --git a/gdb/testsuite/gdb.c++/userdef.exp b/gdb/testsuite/gdb.c++/userdef.exp index 055ff0d..8221d99 100644 --- a/gdb/testsuite/gdb.c++/userdef.exp +++ b/gdb/testsuite/gdb.c++/userdef.exp @@ -1,4 +1,5 @@ -# Copyright (C) 1998 Free Software Foundation, Inc. +# Tests of overloaded operators resolution. +# Copyright (C) 1998, 1999 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,19 +20,14 @@ # written by Elena Zannoni (ezannoni@cygnus.com) # -# testing overloaded operators resolution. -# # source file "userdef.cc" # - if $tracelevel then { strace $tracelevel } -# Check to see if we have an executable to test. If not, then either we -# haven't tried to compile one, or the compilation failed for some reason. -# In either case, just notify the user and skip the tests in this file. +if { [skip_cplus_tests] } { continue } set testfile "userdef" set srcfile ${testfile}.cc diff --git a/gdb/testsuite/gdb.c++/virtfunc.exp b/gdb/testsuite/gdb.c++/virtfunc.exp index dd73cab..b023944 100644 --- a/gdb/testsuite/gdb.c++/virtfunc.exp +++ b/gdb/testsuite/gdb.c++/virtfunc.exp @@ -26,6 +26,8 @@ if $tracelevel then { strace $tracelevel } +if { [skip_cplus_tests] } { continue } + set testfile "virtfunc" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} @@ -36,10 +38,6 @@ if [get_compiler_info ${binfile} "c++"] { source ${binfile}.ci -# Check to see if we have an executable to test. If not, then either we -# haven't tried to compile one, or the compilation failed for some reason. -# In either case, just notify the user and skip the tests in this file. - set src "${srcdir}/${subdir}/${srcfile}" if { [gdb_compile "${src}" "${binfile}" executable {c++ debug}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index ad1e5ad..ab640a3 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -830,6 +830,19 @@ proc default_gdb_start { } { return 0; } +# Return a 1 for configurations for which we don't even want to try to +# test C++. + +proc skip_cplus_tests {} { + if { [istarget "d10v-*-*"] } { + return 1 + } + if { [istarget "h8300-*-*"] } { + return 1 + } + return 0 +} + # * For crosses, the CHILL runtime doesn't build because it can't find # setjmp.h, stdio.h, etc. # * For AIX (as of 16 Mar 95), (a) there is no language code for @@ -872,7 +885,7 @@ proc get_compiler_info {binfile args} { if {![istarget "hppa*-*-hpux*"]} { if { [llength $args] > 0 } { if {$args == "c++"} { - if { [gdb_compile "${srcdir}/${subdir}/compiler.cc" "${binfile}.ci" preprocess {}] != "" } { + if { [gdb_compile "${srcdir}/${subdir}/compiler.cc" "${binfile}.ci" preprocess {}] != "" } { perror "Couldn't make ${binfile}.ci file" return 1; } diff --git a/gdb/thread.c b/gdb/thread.c index 4a2070b..b618afe 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -353,7 +353,7 @@ thread_alive (tp) static void prune_threads () { - struct thread_info *tp, *tpprev, *next; + struct thread_info *tp, *next; for (tp = thread_list; tp; tp = next) { @@ -34,6 +34,7 @@ #include "terminal.h" /* For job_control. */ #include "annotate.h" #include "top.h" +#include "version.h" /* readline include files */ #include <readline/readline.h> @@ -169,18 +170,6 @@ int inhibit_gdbinit = 0; int use_windows = 1; -/* Version number of GDB, as a string. */ - -extern char *version; - -/* Canonical host name as a string. */ - -extern char *host_name; - -/* Canonical target name as a string. */ - -extern char *target_name; - extern char lang_frame_mismatch_warn[]; /* language.c */ /* Flag for whether we want all the "from_tty" gubbish printed. */ @@ -3178,7 +3167,7 @@ get_prompt_1 (formatted_prompt) else { if (available >= 16 /*? */ ) /* overflow protect */ - sprintf (outp, "%d", (long) longval); + sprintf (outp, "%ld", (long) longval); } break; } diff --git a/gdb/utils.c b/gdb/utils.c index ccb4489..bd42ee2 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -996,9 +996,7 @@ print_spaces (n, file) /* Print a host address. */ void -gdb_print_address (addr, stream) - PTR addr; - GDB_FILE *stream; +gdb_print_host_address (void *addr, struct gdb_file *stream) { /* We could use the %p conversion specifier to fprintf if we had any @@ -3200,6 +3198,13 @@ get_cell () */ +int +strlen_paddr (void) +{ + return (TARGET_PTR_BIT / 8 * 2); +} + + /* eliminate warning from compiler on 32-bit systems */ static int thirty_two = 32; diff --git a/gdb/valprint.c b/gdb/valprint.c index 2f07114..60a34be 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -623,10 +623,16 @@ print_floating (valaddr, type, stream) high &= 0xfffff; } else - /* Extended. We can't detect NaNs for extendeds yet. Also note - that currently extendeds get nuked to double in - REGISTER_CONVERTIBLE. */ - is_nan = 0; + { +#ifdef TARGET_ANALYZE_FLOATING + TARGET_ANALYZE_FLOATING; +#else + /* Extended. We can't detect extended NaNs for this target. + Also note that currently extendeds get nuked to double in + REGISTER_CONVERTIBLE. */ + is_nan = 0; +#endif + } if (is_nan) { @@ -635,7 +641,7 @@ print_floating (valaddr, type, stream) (in an implementation-defined manner) distinguish between signaling and quiet NaN's. */ if (high) - fprintf_filtered (stream, "-NaN(0x%lx%.8lx)" + nonnegative, + fprintf_filtered (stream, "-NaN(0x%lx%.8lx)" + !!nonnegative, high, low); else fprintf_filtered (stream, "-NaN(0x%lx)" + nonnegative, low); diff --git a/gdb/values.c b/gdb/values.c index b4381cd..6f2642e 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -922,7 +922,6 @@ value_virtual_fn_field (arg1p, f, j, type, offset) /* Deal with HP/Taligent runtime model for virtual functions */ value_ptr vp; value_ptr argp; /* arg1 cast to base */ - CORE_ADDR vfunc_addr; /* address of virtual method */ CORE_ADDR coreptr; /* pointer to target address */ int class_index; /* which class segment pointer to use */ struct type *ftype = TYPE_FN_FIELD_TYPE (f, j); /* method type */ diff --git a/gdb/version.h b/gdb/version.h new file mode 100644 index 0000000..015caa8 --- /dev/null +++ b/gdb/version.h @@ -0,0 +1,33 @@ +/* Version information for GDB. + Copyright (C) 1999, 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef VERSION_H +#define VERSION_H + +/* Version number of GDB, as a string. */ +extern const char version[]; + +/* Canonical host name as a string. */ +extern const char host_name[]; + +/* Canonical target name as a string. */ +extern const char target_name[]; + +#endif /* #ifndef VERSION_H */ diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 059bc1d..fa03d2f 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -199,7 +199,7 @@ static void xcoff_initial_scan PARAMS ((struct objfile *, int)); static void -scan_xcoff_symtab PARAMS ((struct section_offsets *, struct objfile *)); +scan_xcoff_symtab PARAMS ((struct objfile *)); static char * xcoff_next_symbol_text PARAMS ((struct objfile *)); @@ -223,7 +223,7 @@ xcoff_new_init PARAMS ((struct objfile *)); static void xcoff_symfile_finish PARAMS ((struct objfile *)); -static struct section_offsets * +static void xcoff_symfile_offsets PARAMS ((struct objfile *, CORE_ADDR)); static void @@ -1997,7 +1997,7 @@ init_stringtab (abfd, offset, objfile) static unsigned int first_fun_line_offset; static struct partial_symtab *xcoff_start_psymtab - PARAMS ((struct objfile *, struct section_offsets *, char *, int, + PARAMS ((struct objfile *, char *, int, struct partial_symbol **, struct partial_symbol **)); /* Allocate and partially fill a partial symtab. It will be @@ -2008,19 +2008,18 @@ static struct partial_symtab *xcoff_start_psymtab (normal). */ static struct partial_symtab * -xcoff_start_psymtab (objfile, section_offsets, - filename, first_symnum, global_syms, static_syms) +xcoff_start_psymtab (objfile, filename, first_symnum, global_syms, + static_syms) struct objfile *objfile; - struct section_offsets *section_offsets; char *filename; int first_symnum; struct partial_symbol **global_syms; struct partial_symbol **static_syms; { struct partial_symtab *result = - start_psymtab_common (objfile, section_offsets, + start_psymtab_common (objfile, objfile->section_offsets, filename, - /* We fill in textlow later. */ + /* We fill in textlow later. */ 0, global_syms, static_syms); @@ -2203,8 +2202,7 @@ swap_sym (symbol, aux, name, raw, symnump, objfile) } static void -scan_xcoff_symtab (section_offsets, objfile) - struct section_offsets *section_offsets; +scan_xcoff_symtab (objfile) struct objfile *objfile; { CORE_ADDR toc_offset = 0; /* toc offset value in data section. */ @@ -2335,7 +2333,7 @@ scan_xcoff_symtab (section_offsets, objfile) /* Give all psymtabs for this source file the same name. */ pst = xcoff_start_psymtab - (objfile, section_offsets, + (objfile, filestring, symnum_before, objfile->global_psymbols.next, @@ -2515,7 +2513,7 @@ scan_xcoff_symtab (section_offsets, objfile) else filestring = namestring; - pst = xcoff_start_psymtab (objfile, section_offsets, + pst = xcoff_start_psymtab (objfile, filestring, symnum_before, objfile->global_psymbols.next, @@ -2608,7 +2606,7 @@ scan_xcoff_symtab (section_offsets, objfile) /* START_PSYMTAB and END_PSYMTAB are never used, because they are only called from DBXREAD_ONLY or N_SO code. Likewise for the symnum variable. */ -#define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms) 0 +#define START_PSYMTAB(ofile,fname,low,symoff,global_syms,static_syms) 0 #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set)\ do {} while (0) /* We have already set the namestring. */ @@ -2750,7 +2748,7 @@ xcoff_initial_scan (objfile, mainline) /* Now that the symbol table data of the executable file are all in core, process them and define symbols accordingly. */ - scan_xcoff_symtab (objfile->section_offsets, objfile); + scan_xcoff_symtab (objfile); /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. */ @@ -2760,16 +2758,15 @@ xcoff_initial_scan (objfile, mainline) do_cleanups (back_to); } -static struct section_offsets * +static void xcoff_symfile_offsets (objfile, addr) struct objfile *objfile; CORE_ADDR addr; { - struct section_offsets *section_offsets; int i; objfile->num_sections = SECT_OFF_MAX; - section_offsets = (struct section_offsets *) + objfile->section_offsets = (struct section_offsets *) obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS); /* syms_from_objfile kindly subtracts from addr the bfd_section_vma @@ -2781,9 +2778,7 @@ xcoff_symfile_offsets (objfile, addr) parameter and use 0. rs6000-nat.c will set the correct section offsets via objfile_relocate. */ for (i = 0; i < objfile->num_sections; ++i) - ANOFFSET (section_offsets, i) = 0; - - return section_offsets; + ANOFFSET (objfile->section_offsets, i) = 0; } /* Register our ability to parse symbols for xcoff BFD files. */ diff --git a/gdb/xcoffsolib.c b/gdb/xcoffsolib.c index bb286eb..e956511 100644 --- a/gdb/xcoffsolib.c +++ b/gdb/xcoffsolib.c @@ -192,9 +192,9 @@ Text Range Data Range Syms Shared Object Library\n"); for (; vp != NULL; vp = vp->nxt) { - printf_unfiltered ("0x%08x-0x%08x 0x%08x-0x%08x %s %s%s%s%s\n", - vp->tstart, vp->tend, - vp->dstart, vp->dend, + printf_unfiltered ("0x%s-0x%s 0x%s-0x%s %s %s%s%s%s\n", + paddr (vp->tstart),paddr (vp->tend), + paddr (vp->dstart), paddr (vp->dend), vp->loaded ? "Yes" : "No ", *vp->member ? "(" : "", vp->member, diff --git a/gdb/z8k-tdep.c b/gdb/z8k-tdep.c index b3f85bd..e32bf8f 100644 --- a/gdb/z8k-tdep.c +++ b/gdb/z8k-tdep.c @@ -32,6 +32,10 @@ #include "dis-asm.h" #include "gdbcore.h" +#include "value.h" /* For read_register() */ + + +static int read_memory_pointer (CORE_ADDR x); /* Return the saved PC from this frame. @@ -39,7 +43,7 @@ just use the register SRP_REGNUM itself. */ CORE_ADDR -frame_saved_pc (frame) +z8k_frame_saved_pc (frame) struct frame_info *frame; { return read_memory_pointer (frame->frame + (BIG ? 4 : 2)); @@ -152,15 +156,14 @@ z8k_addr_bits_remove (addr) return (addr & PTR_MASK); } -int -read_memory_pointer (x) - CORE_ADDR x; +static int +read_memory_pointer (CORE_ADDR x) { return read_memory_integer (ADDR_BITS_REMOVE (x), BIG ? 4 : 2); } CORE_ADDR -frame_chain (thisframe) +z8k_frame_chain (thisframe) struct frame_info *thisframe; { if (thisframe->prev == 0) @@ -295,7 +298,7 @@ frame_find_saved_regs (fip, fsrp) #endif int -saved_pc_after_call () +z8k_saved_pc_after_call (struct frame_info *frame) { return ADDR_BITS_REMOVE (read_memory_integer (read_register (SP_REGNUM), PTR_SIZE)); @@ -343,7 +346,7 @@ store_struct_return (addr, sp) void -print_register_hook (regno) +z8k_print_register_hook (regno) int regno; { if ((regno & 1) == 0 && regno < 16) @@ -378,7 +381,8 @@ print_register_hook (regno) printf_unfiltered ("\n"); for (i = 0; i < 10; i += 2) { - printf_unfiltered ("(sp+%d=%04x)", i, read_memory_short (rval + i)); + printf_unfiltered ("(sp+%d=%04x)", i, + (unsigned int)read_memory_short (rval + i)); } } @@ -409,6 +413,11 @@ z8k_set_pointer_size (newsize) { BIG = 0; } + /* FIXME: This code should be using the GDBARCH framework to + handle changed type sizes. If this problem is ever fixed + (the direct reference to _initialize_gdbtypes() below + eliminated) then Makefile.in should be updated so that + z8k-tdep.c is again compiled with -Werror. */ _initialize_gdbtypes (); } } |