Commit Graph

7 Commits

Author SHA1 Message Date
Tom Tromey
fdc82b33c4 Move some code from dwarf2/read.c to die.c
This patch introduces a new file, dwarf2/die.c, and moves some
DIE-related code out of dwarf2/read.c and into this new file.  This is
just a small part of the long-term project to split up read.c.
(According to 'wc', dwarf2/read.c is the largest file in gdb by around
8000 LOC.)

Regression tested on x86-64 Fedora 36.
2023-02-12 13:03:58 -07:00
Andrew Burgess
b9c05fc03d gdb: remove unnecessary 'dir' commands from gdb-gdb.gdb script
While debugging GDB I used 'show directories' and spotted lots of
entries that didn't make much sense. Here are all the entries that are
in my directories list:

  /tmp/binutils-gdb/build
  /tmp/binutils-gdb/build/../../src/gdb
  /tmp/binutils-gdb/build/../../src/gdb/../bfd
  /tmp/binutils-gdb/build/../../src/gdb/../libiberty
  $cdir
  $cwd

Notice the second, third, and fourth entries in this list, these
should really be:

  /tmp/binutils-gdb/build/../src/gdb
  /tmp/binutils-gdb/build/../src/gdb/../bfd
  /tmp/binutils-gdb/build/../src/gdb/../libiberty

The problem is because I generally run everything from the top level
build directory, not the gdb/ sub-directory, thus, I start GDB like:

  ./gdb/gdb --data-directory ./gdb/data-directory

If run GDB under GDB, then I end up loading the gdb/gdb-gdb.gdb
script, which contains these lines:

  dir ../../src/gdb/../libiberty
  dir ../../src/gdb/../bfd
  dir ../../src/gdb
  dir .

These commands only make sense when running within the gdb/
sub-directory.

However, my debugging experience doesn't seem to be degraded at all, I
can still see the GDB source code just fine; which is because the
directory list still contains $cdir.

The build/gdb/gdb-gdb.gdb script is created from the
src/gdb/gdb-gdb.gdb.in template, which includes the automake @srcdir@
markers.

The 'dir' commands have mostly been around since the sourceware
repository was first created, though this commit 67f0714670 did
reorder some of the 'dir' commands, which would seem to indicate these
commands were important to some people, at some time.

One possible fix would be to replace @srcdir@ with @abs_srcdir@, this
would ensure that the entries added were all valid, no matter the
user's current directory when debugging GDB.

However... I'd like to propose that we instead remove all the extra
directories completely.  My hope is that, with more recent tools, the
debug information should allow us to correctly find all of the source
files without having to add any extra 'dir' entries.  Obviously,
commit 67f0714670 does make me a little nervous, but the
gdb-gdb.gdb script isn't something a non-maintainer will be using, so
I think we can afford to be a little more aggressive here.  If it
turns out the 'dir' entries are needed then we can add them back, but
actually document why they are needed.  Plus, when we add them back we
will use @abs_srcdir@ instead of @srcdir@.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-02-11 17:14:33 +00:00
Simon Marchi
a5a0a4fd0f gdb: internal_error -> internal_error_loc in gdb-gdb.gdb.in
Commit f34652de0b ("internal_error: remove need to pass
__FILE__/__LINE__") renamed the internal_error function to
internal_error_loc.  Change gdb-gdb.gdb.in accordingly.

Change-Id: I876e1623607b6becf74ade53d102ead53a74ed86
2022-10-25 00:12:38 -04:00
Tom Tromey
4fd6c7e872 Restore info_command and breakpoint
As discussed on gdb-patches, this restores info_command and the
breakpoint on info_command in gdb-gdb.gdb.  This reverts a tiny part
of 0743fc83c0 ("Replace most calls to help_list and cmd_show_list"),
as well as 652fc23a30 ("Remove gdb-gdb.gdb breakpoint on disappeared
function info_command.").

gdb/ChangeLog
2020-05-11  Tom Tromey  <tromey@adacore.com>

	* cli/cli-cmds.c (info_command): Restore.
	(_initialize_cli_cmds): Use add_prefix_command for "info".
	* gdb-gdb.gdb.in: Restore breakpoint on info_command.
2020-05-11 15:30:40 -06:00
Philippe Waroquiers
652fc23a30 Remove gdb-gdb.gdb breakpoint on disappeared function info_command.
The function info_command has disappeared, so this breakpoint does not
work anymore.
"info_command" was a function for the prefix command "info",
giving the list of "info" subcommands.
It is not very clear what the removed breakpoint and its associated
command list was supposed to do.

Removed and pushed as obvious, after discussion with Tom.
2020-05-01 16:47:05 +02:00
Jan Kratochvil
edceb2a99a gdb/
* gdb-gdb.gdb.in: Wrap set complaints, b internal_error, b info_command
	and dir commands into an if block.
2013-02-15 20:28:24 +00:00
Jan Kratochvil
e2207b9a28 gdb/
auto-load: Move files.
	* Makefile.in (SFILES): Add auto-load.c.
	(HFILES_NO_SRCDIR): Add auto-load.h.
	(COMMON_OBS): Add auto-load.o.
	(distclean): Change .gdbinit for gdb-gdb.gdb.
	* auto-load.c: New file, with parts from python/py-auto-load.c.
	* auto-load.h: New file, with parts from python/python.h.
	* configure: Regenerate.
	* configure.ac (AC_OUTPUT): Change .gdbinit for gdb-gdb.gdb.
	* gdb-gdb.gdb.in: New file, renamed from gdbinit.in.
	* gdbinit.in: Remove file, rename it to gdb-gdb.gdb.in.
	* main.c: Include auto-load.h.
	* python/py-auto-load.c: Move include filenames.h, gdb_regex.h,
	command.h, observer.h and progspace.h to auto-load.c.  Add include
	auto-load.h.
	(gdbpy_global_auto_load, struct auto_load_pspace_info)
	(struct loaded_script, auto_load_pspace_data)
	(auto_load_pspace_data_cleanup, get_auto_load_pspace_data)
	(hash_loaded_script_entry, eq_loaded_script_entry)
	(init_loaded_scripts_info, get_auto_load_pspace_data_for_loading)
	(maybe_add_script): Move to auto-load.c.
	(source_section_scripts): Change maybe_add_script parameters passing,
	use script_not_found_warning_print.
	(clear_section_scripts, auto_load_objfile_script)
	(auto_load_new_objfile, loaded_script_ptr)
	(DEF_VEC_P (loaded_script_ptr), collect_matching_scripts, print_script)
	(sort_scripts_by_name, info_auto_load_scripts): Move to auto-load.c.
	(gdbpy_initialize_auto_load): Move auto_load_pspace_data,
	auto_load_new_objfile and info_auto_load_scripts initizations to
	auto-load.c.
	* python/python.h (gdbpy_global_auto_load): Move to auto-load.h.
2012-04-17 15:49:16 +00:00