binutils-gdb/gdb/python
Andrew Burgess 4076f962e8 gdb: split apart two different types of filename completion
Unfortunately we have two different types of filename completion in
GDB.

The majority of commands have what I call unquoted filename
completion, this is for commands like 'set logging file ...', 'target
core ...', and 'add-auto-load-safe-path ...'.  For these commands
everything after the command name (that is not a command option) is
treated as a single filename.  If the filename contains white space
then this does not need to be escaped, nor does the filename need to
be quoted.  In fact, the filename argument is not de-quoted, and does
not have any escaping removed, so if a user does try to add such
things, they will be treated as part of the filename.  As an example:

  (gdb) target core "/path/that contains/some white space"

Will look for a directory calls '"' (double quotes) in the local
directory.

A small number of commands do de-quote and remove escapes from
filename arguments.  These command accept what I call quoted and
escaped filenames.  Right now these are the commands that specify the
file for GDB to debug, so:

  file
  exec-file
  symbol-file
  add-symbol-file
  remove-symbol-file

As an example of this in action:

  (gdb) file "/path/that contains/some white space"

In this case GDB would load the file:

  /path/that contains/some white space

Current filename completion always assumes that filenames can be
quoted, though escaping doesn't work in completion right now.  But the
assumption that quoting is allowed is clearly wrong.

This commit splits filename completion into two.  The existing
filename_completer is retained, and is used for unquoted filenames.  A
second filename_maybe_quoted_completer is added which can be used for
completing quoted filenames.

The filename completion test has been extended to cover more cases.
As part of the extended testing I need to know the character that
should be used to separate filenames within a path.  For this TCL 8.6+
has $::tcl_platform(pathSeparator).  To support older versions of TCL
I've added some code to testsuite/lib/gdb.exp.

You might notice that after this commit the completion for unquoted
files is all done in the brkchars phase, that is the function
filename_completer_handle_brkchars calculates the completions and
marks the completion_tracker as using a custom word point.  The reason
for this is that we don't want to break on white space for this
completion, but if we rely on readline to find the completion word,
readline will consider the entire command line, and with no white
space in the word break character set, readline will end up using the
entire command line as the word to complete.

For now at least, the completer for quoted filenames does generate its
completions during the completion phase, though this is going to
change in a later commit.
2024-09-07 20:28:57 +01:00
..
lib/gdb Fix DAP failure when fetching global variables 2024-08-16 08:47:00 -06:00
py-all-events.def
py-arch.c [gdb/python] Use GDB_PY_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
py-auto-load.c
py-block.c Memoize gdb.Block and make them hashable 2024-06-04 10:54:18 -06:00
py-bpevent.c
py-breakpoint.c [gdb/python] Use GDB_PY_SET_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
py-cmd.c gdb: split apart two different types of filename completion 2024-09-07 20:28:57 +01:00
py-connection.c [gdb/python] Use GDB_PY_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
py-continueevent.c
py-dap.c Don't allow new-ui to start the TUI 2024-05-17 09:39:41 -06:00
py-disasm.c [gdb/python] Fix handling of ^C during disassembly 2024-08-08 23:52:00 +02:00
py-event-types.def
py-event.c
py-event.h
py-events.h
py-evtregistry.c
py-evts.c
py-exitedevent.c
py-finishbreakpoint.c [gdb/python] Use GDB_PY_SET_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
py-frame.c [gdb/python] Use GDB_PY_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
py-framefilter.c gdb: drop struct keyword when using bound_minimal_symbol 2024-08-12 10:31:09 -04:00
py-function.c
py-gdb-readline.c [gdb/python] Use GDB_PY_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
py-inferior.c [gdb] Add const to catch gdb_exception 2024-08-22 09:49:53 +02:00
py-infevents.c
py-infthread.c
py-instruction.c
py-instruction.h
py-lazy-string.c fix division by zero in target_read_string() 2024-06-11 09:50:08 -06:00
py-linetable.c
py-membuf.c
py-mi.c [gdb/python] Use GDB_PY_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
py-micmd.c
py-newobjfileevent.c
py-objfile.c gdb: make objfile::pspace private 2024-07-15 13:55:00 +00:00
py-param.c [gdb/python] Use GDB_PY_SET_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
py-prettyprint.c
py-progspace.c gdb: make progspace::exec_filename private, add getter / setter 2024-06-07 23:09:03 -04:00
py-record-btrace.c [gdb/python] Use GDB_PY_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
py-record-btrace.h python: Add clear() to gdb.Record. 2024-08-14 11:20:56 +02:00
py-record-full.c
py-record-full.h
py-record.c [gdb/python] Use GDB_PY_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
py-record.h python: Introduce gdb.RecordAuxiliary class. 2024-08-14 11:20:56 +02:00
py-ref.h
py-registers.c
py-signalevent.c
py-stopevent.c [gdb/python] Use GDB_PY_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
py-stopevent.h
py-symbol.c
py-symtab.c
py-threadevent.c
py-tui.c [gdb/python] Use GDB_PY_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
py-type.c [gdb/python] Eliminate catch(...) in type_to_type_object 2024-08-22 09:49:53 +02:00
py-uiout.h
py-unwind.c [gdb/python] Make gdb.UnwindInfo.add_saved_register more robust (fixup) 2024-05-10 08:46:21 +02:00
py-utils.c
py-value.c [gdb/python] Use GDB_PY_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
py-varobj.c
py-xmethods.c
python-config.py
python-internal.h btrace, python: Enable ptwrite filter registration. 2024-08-14 11:20:57 +02:00
python.c [gdb/python] Use GDB_PY_HANDLE_EXCEPTION more often 2024-08-27 09:20:18 +02:00
python.h