and TMPDIR which was introduced when fixing bugzilla #267020.
Factor out VG_(tmpdir). New function VG_(vgdb_path_prefix).
Partially fixes bugzilla #280757.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12063
offsetof(ThreadState, status),
offsetof(ThreadState, os_state) + offsetof(ThreadOSstate, lwpid)};
const int pid = VG_(getpid)();
- const int name_default = strcmp(name, VG_CLO_VGDB_PREFIX_DEFAULT) == 0;
+ const int name_default = strcmp(name, VG_(vgdb_prefix_default)()) == 0;
Addr addr_shared;
SysRes o;
int shared_mem_fd = INVALID_DESCRIPTOR;
return 0;
}
+
+/* Return the path prefix for the named pipes (FIFOs) used by vgdb/gdb
+ to communicate with valgrind */
+HChar *
+VG_(vgdb_prefix_default)(void)
+{
+ const HChar *tmpdir;
+ HChar *prefix;
+
+ tmpdir = VG_(tmpdir)();
+ prefix = malloc(strlen(tmpdir) + strlen("/vgdb-pipe") + 1);
+ strcpy(prefix, tmpdir);
+ strcat(prefix, "/vgdb-pipe");
+
+ return prefix;
+}
# endif
}
+/* Return the name of a directory for temporary files. */
+const HChar *VG_(tmpdir)(void)
+{
+ const HChar *tmpdir;
+
+ tmpdir = VG_(getenv)("TMPDIR");
+ if (tmpdir == NULL || *tmpdir == '\0') tmpdir = VG_TMPDIR;
+ if (tmpdir == NULL || *tmpdir == '\0') tmpdir = "/tmp"; /* fallback */
+
+ return tmpdir;
+}
+
/* Create and open (-rw------) a tmp file name incorporating said arg.
Returns -1 on failure, else the fd of the file. If fullname is
non-NULL, the file's name is written into it. The number of bytes
seed = (VG_(getpid)() << 9) ^ VG_(getppid)();
/* Determine sensible location for temporary files */
- tmpdir = VG_(getenv)("TMPDIR");
- if (tmpdir == NULL || *tmpdir == '\0') tmpdir = VG_TMPDIR;
- if (tmpdir == NULL || *tmpdir == '\0') tmpdir = "/tmp"; /* fallback */
+ tmpdir = VG_(tmpdir)();
tries = 0;
while (True) {
/* END command-line processing loop */
+ /* Determine the path prefix for vgdb */
+ if (VG_(clo_vgdb_prefix) == NULL)
+ VG_(clo_vgdb_prefix) = VG_(vgdb_prefix_default)();
+
/* Make VEX control parameters sane */
if (VG_(clo_vex_control).guest_chase_thresh
#endif
Int VG_(clo_vgdb_poll) = 5000;
Int VG_(clo_vgdb_error) = 999999999;
-Char* VG_(clo_vgdb_prefix) = VG_CLO_VGDB_PREFIX_DEFAULT;
+HChar* VG_(clo_vgdb_prefix) = NULL;
Bool VG_(clo_vgdb_shadow_registers) = False;
Bool VG_(clo_db_attach) = False;
#include "pub_tool_gdbserver.h"
+/* Return the path prefix for the named pipes (FIFOs) used by vgdb/gdb
+ to communicate with valgrind */
+HChar* VG_(vgdb_prefix_default)(void);
// After a fork or after an exec, call the below to (possibly) terminate
// the previous gdbserver and then activate a new gdbserver
written is guaranteed not to exceed 64+strlen(part_of_name). */
extern Int VG_(mkstemp) ( HChar* part_of_name, /*OUT*/HChar* fullname );
+/* Return the name of a directory for temporary files. */
+extern const HChar* VG_(tmpdir)(void);
+
/* Record the process' working directory at startup. Is intended to
be called exactly once, at startup, before the working directory
changes. Return True for success, False for failure, so that the
/* if > 0, checks every VG_(clo_vgdb_poll) BBS if vgdb wants to be served. */
extern Int VG_(clo_vgdb_poll);
/* prefix for the named pipes (FIFOs) used by vgdb/gdb to communicate with valgrind */
-extern Char* VG_(clo_vgdb_prefix);
+extern HChar* VG_(clo_vgdb_prefix);
/* if True, gdbserver in valgrind will expose a target description containing
shadow registers */
extern Bool VG_(clo_vgdb_shadow_registers);
-#define VG_CLO_VGDB_PREFIX_DEFAULT "/tmp/vgdb-pipe"
/* Enquire about whether to attach to a debugger at errors? default: NO */
extern Bool VG_(clo_db_attach);
#include "pub_core_libcsetjmp.h"
#include "pub_core_threadstate.h"
#include "pub_core_gdbserver.h"
+#include "config.h"
#include <limits.h>
#include <unistd.h>
fflush(stderr), \
exit(1))
-static char *vgdb_prefix = "/tmp/vgdb-pipe";
+static char *vgdb_prefix = NULL;
/* Will be set to True when any condition indicating we have to shutdown
is encountered. */
return mem;
}
+/* Return the name of a directory for temporary files. */
+static
+const char *vgdb_tmpdir(void)
+{
+ const char *tmpdir;
+
+ tmpdir = getenv("TMPDIR");
+ if (tmpdir == NULL || *tmpdir == '\0') tmpdir = VG_TMPDIR;
+ if (tmpdir == NULL || *tmpdir == '\0') tmpdir = "/tmp"; /* fallback */
+
+ return tmpdir;
+}
+
+/* Return the path prefix for the named pipes (FIFOs) used by vgdb/gdb
+ to communicate with valgrind */
+static
+char *vgdb_prefix_default(void)
+{
+ const char *tmpdir;
+ HChar *prefix;
+
+ tmpdir = vgdb_tmpdir();
+ prefix = vmalloc(strlen(tmpdir) + strlen("/vgdb-pipe") + 1);
+ strcpy(prefix, tmpdir);
+ strcat(prefix, "/vgdb-pipe");
+
+ return prefix;
+}
+
/* add nrw to the written_by_vgdb field of shared32 or shared64 */
static
void add_written(int nrw)
}
}
+ if (vgdb_prefix == NULL)
+ vgdb_prefix = vgdb_prefix_default();
+
if (isatty(0)
&& !show_shared_mem
&& !show_list