- added search paths before running tcl/commands.tcl.
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 10 Jul 2008 18:24:30 +0000 (18:24 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 10 Jul 2008 18:24:30 +0000 (18:24 +0000)
- improved error handling for missing tcl/commands.tcl

git-svn-id: svn://svn.berlios.de/openocd/trunk@785 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/helper/configuration.h
src/helper/options.c
src/openocd.c

index 1d315cc2dac49bf850ea4b0ccd3b0ed90ce34241..d1f537d77f4aaa43d22c400a13623d31aadc2640 100644 (file)
@@ -30,5 +30,6 @@ extern void add_script_search_dir (const char *dir);
 extern int configuration_output_handler(struct command_context_s *context, const char* line);
 extern FILE *open_file_from_path (char *file, char *mode);
 extern char *find_file(char *name);
+int add_default_dirs(void);
 
 #endif /* CONFIGURATION_H */
index afff55ba4964a75e03c5fd943160e6a24b12a13c..f62ab16b2b6f9922538048b6d90876515ab8fbfb 100644 (file)
@@ -52,6 +52,36 @@ int configuration_output_handler(struct command_context_s *context, const char*
        return ERROR_OK;
 }
 
+int add_default_dirs(void)
+{
+#ifdef _WIN32
+       /* Add the parent of the directory where openocd.exe resides to the
+        * config script search path.
+        * Directory layout: 
+        * bin\openocd.exe
+        * lib\openocd
+        * event\at91eb40a_reset.cfg
+        * target\at91eb40a.cfg
+        */
+       {
+               char strExePath [MAX_PATH];
+               GetModuleFileName (NULL, strExePath, MAX_PATH);
+               /* Either this code will *always* work or it will SEGFAULT giving
+                * excellent information on the culprit. 
+                */
+               *strrchr(strExePath, '\\')=0;
+               strcat(strExePath, "\\..");
+               add_script_search_dir(strExePath);
+       }
+#else
+       /* Add dir for openocd supplied scripts last so that user can over
+          ride those scripts if desired. */
+       add_script_search_dir(PKGDATADIR);
+       add_script_search_dir(PKGLIBDIR);
+#endif
+       return ERROR_OK;
+}
+
 int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[])
 {
        int c;
@@ -138,31 +168,6 @@ int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[]
                exit(-1);
        }       
 
-#ifdef _WIN32
-       /* Add the parent of the directory where openocd.exe resides to the
-        * config script search path.
-        * Directory layout: 
-        * bin\openocd.exe
-        * lib\openocd
-        * event\at91eb40a_reset.cfg
-        * target\at91eb40a.cfg
-        */
-       {
-               char strExePath [MAX_PATH];
-               GetModuleFileName (NULL, strExePath, MAX_PATH);
-               /* Either this code will *always* work or it will SEGFAULT giving
-                * excellent information on the culprit. 
-                */
-               *strrchr(strExePath, '\\')=0;
-               strcat(strExePath, "\\..");
-               add_script_search_dir(strExePath);
-       }
-#else
-       /* Add dir for openocd supplied scripts last so that user can over
-          ride those scripts if desired. */
-       add_script_search_dir(PKGDATADIR);
-       add_script_search_dir(PKGLIBDIR);
-#endif
 
        return ERROR_OK;
 }
index f4aa451728a050cea16230440f2a919c00149676..c7b18eb24cf7b26b67b1e7c51bfd644f8206bc5c 100644 (file)
@@ -572,7 +572,11 @@ void initJim(void)
 /* after command line parsing */
 void initJim2(void)
 {
-       Jim_Eval(interp, "source [find tcl/commands.tcl]");
+       if (Jim_Eval(interp, "source [find tcl/commands.tcl]")==JIM_ERR)
+       {
+               LOG_ERROR("Can not find tcl/commands.tcl - check installation");
+               exit(-1);
+       }
 }
 
 command_context_t *setup_command_handler(void)
@@ -653,11 +657,13 @@ int openocd_main(int argc, char *argv[])
        
        active_cmd_ctx=cfg_cmd_ctx;
        
-       if (parse_cmdline_args(cfg_cmd_ctx, argc, argv) != ERROR_OK)
-               return EXIT_FAILURE;
+       add_default_dirs();
 
        initJim2();
-
+       
+       if (parse_cmdline_args(cfg_cmd_ctx, argc, argv) != ERROR_OK)
+               return EXIT_FAILURE;
+       
        if (parse_config_file(cfg_cmd_ctx) != ERROR_OK)
                return EXIT_FAILURE;
        

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)