char *argv0;
{
struct cleanup *old_chain;
- char *lib, *gdbtk_lib, gdbtk_lib_tmp[1024],gdbtk_file[128];
+ char *lib, *gdbtk_lib, *gdbtk_lib_tmp, *gdbtk_file;
int i, found_main;
struct sigaction action;
static sigset_t nullsigmask = {0};
#ifdef IDE
/* Initialize the Paths variable. */
- if (ide_initialize_paths (interp, "gdb") != TCL_OK)
+ if (ide_initialize_paths (interp, "gdbtcl") != TCL_OK)
error ("ide_initialize_paths failed: %s", interp->result);
/* Find the directory where we expect to find idemanager. We ignore
else
gdbtk_lib = GDBTK_LIBRARY;
- strcpy (gdbtk_lib_tmp, gdbtk_lib);
+ gdbtk_lib_tmp = xstrdup (gdbtk_lib);
+
found_main = 0;
/* see if GDBTK_LIBRARY is a path list */
lib = strtok (gdbtk_lib_tmp, GDBTK_PATH_SEP);
}
if (!found_main)
{
- strcpy (gdbtk_file, lib);
- strcat (gdbtk_file, "/main.tcl");
+ gdbtk_file = concat (lib, "/main.tcl", (char *) NULL);
if (access (gdbtk_file, R_OK) == 0)
{
found_main++;
}
}
while ((lib = strtok (NULL, ":")) != NULL);
-
+
+ free (gdbtk_lib_tmp);
+
+#ifdef IDE
+ if (!found_main)
+ {
+ /* Try finding it with the auto path. */
+
+ static const char script[] ="\
+proc gdbtk_find_main {} {\n\
+ global auto_path GDBTK_LIBRARY\n\
+ foreach dir $auto_path {\n\
+ set f [file join $dir main.tcl]\n\
+ if {[file exists $f]} then {\n\
+ set GDBTK_LIBRARY $dir\n\
+ return $f\n\
+ }\n\
+ }\n\
+ return ""\n\
+}\n\
+gdbtk_find_main";
+
+ if (Tcl_GlobalEval (interp, (char *) script) != TCL_OK)
+ {
+ fputs_unfiltered (Tcl_GetVar (interp, "errorInfo", 0), gdb_stderr);
+ error ("");
+ }
+
+ if (interp->result[0] != '\0')
+ {
+ gdbtk_file = xstrdup (interp->result);
+ found_main++;
+ }
+ }
+#endif
+
if (!found_main)
{
fputs_unfiltered_hook = NULL; /* Force errors to stdout/stderr */
error ("");
}
+ free (gdbtk_file);
+
discard_cleanups (old_chain);
}