gdb: reorder checks in validate_exec_file

While reviewing another patch I was briefly confused by a call to
target_pid_to_exec_file coming from validate_exec_file while attaching
to a process when I had not previously set an executable.

The current order of actions in validate_exec_file is:

  1. Get name of current executable.
  2. Get name of executable from the current inferior.
  3. If either of (1) or (2) return NULL, then there's nothing to
     check, early return.

I think it would be cleaner if we instead did this:

  1. Get name of current executable.
  3. If (1) returned NULL then there's nothing to check, early return.
  3. Get name of executable from the current inferior.
  4. If (3) returned NULL then there's nothing to check, early return.

This does mean there's an extra step, but I don't think the code is
any more complex really, and we now avoid trying to extract the name
of the executable from the current inferior unless we really need it.
This avoids the target_pid_to_exec_file call that I was seeing, which
for remote targets does avoid a packet round trip (not that I'm
selling this as an "optimisation", just noting the change).

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
1 file changed