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: [PATCH] Also install data-directory into the build directory as computed by relocate_gdb_directory


Hi,

On Oct 3, 2012, at 9:33 PM, Joel Brobecker wrote:

>> Another wild idea is to rename the gdb in the build directory as xgdb
>> (akin to xgcc).  One could key off that to know gdb is being run from
>> the build directory.
> 
> I think that this is opening the door for allowing GDB to execute
> code without the user being aware of it. I'd rather avoid that.

I've thought of one more option: we can compile two near copies of gdb: the standard gdb to be installed, and xgdb for debugging (never installed). The only difference for xgdb is that it has a different main() function that inserts --data-directory into the command line before calling the real main. The implementation can be something like:

// xgdb.c
int main (int argc, char *argv[]) {
	... add --data-directory $BUILDDIR to argv if it doesn't exists ...
	return the_actual_main(argc, argv);
}

#define main the_actual_main
#include "gdb.c"
// end xgdb.c

This doesn't have the issue of my previous idea of using exec, and does not rely on any quirks of relocate_gdb_directory. It does hard code the build directory into the binary, but that binary should never be installed and so does not affect users. The cost would be compiling one more source file and linking it.

Yit
October 3, 2012


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