This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] New option -B: simplify running gdb from build directory


On Fri, Dec 27, 2013 at 11:42 AM, Doug Evans <dje@google.com> wrote:
> Hi.
>
> The "make run" Makefile rule simplifies running gdb from the shell,
> but it doesn't simplify running gdb from gdb: I'm always typing
> "--data-directory=$(pwd)/data-directory".
> And since we can't agree on a way to let gdb auto-detect being run
> from the build directory, how about this?
>
> This patch provides a new option, -B, which if provided tells gdb
> it *may* have been run from the build directory.  If -B was provided
> and --data-directory was not provided, use a heuristic to determine
> if gdb was run from the build directory and if so set gdb_datadir
> appropriately.
>
> We can certainly discuss what's the best heuristic to use here.
> We don't, IMO, have to employ too complicated a heuristic because
> the user has explicitly passed -B.
> OTOH, I'm sure one can improve a bit on the heuristic that's here.
> One thought I have is to have the Makefile create a file with a name that
> is reasonably obscure (maybe even pseudo-cryptographically secure and encode
> the name in gdb?), and then simplify the test by just checking for that file.
>
> If we can agree on this approach, I'll add NEWS and docs.
>
> 2013-12-27  Doug Evans  <dje@google.com>
>
>         * main.c (maybe_run_from_builddir): New global.
>         (get_builddir): New function.
>         (captured_main): New option enum OPT_BATCH_SILENT, use it for
>         --batch-silent instead of 'B'.  Add option -B: If -B is provided
>         and --data-directory is not, see if being run from build directory
>         and use that for gdb_datadir if so.

Blech, I shouldn't assume gdb_program_name is an absolute path.  I'll
fix that in the next revision.

[OTOH, the caller could be the one to ensure gdb_datadir is an
absolute path since we don't do that yet if a relative path is passed
to --data-directory.]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]