]> git.sur5r.net Git - openocd/commitdiff
improve error messages a little bit.
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Wed, 9 Jul 2008 22:19:05 +0000 (22:19 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Wed, 9 Jul 2008 22:19:05 +0000 (22:19 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@781 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/jim.c
src/openocd.c

index 712ce74f570144ae4072aa2db87c34a5f93f8b2b..be53233c16524a10ec9af069e4fc3027d8fbcbcb 100644 (file)
--- a/src/jim.c
+++ b/src/jim.c
@@ -8245,10 +8245,10 @@ int Jim_EvalObjVector(Jim_Interp *interp, int objc, Jim_Obj *const *objv)
             retcode = cmdPtr->cmdProc(interp, objc, objv);
         } else {
             retcode = JimCallProcedure(interp, cmdPtr, objc, objv);
-            if (retcode == JIM_ERR) {
-                JimAppendStackTrace(interp,
-                    Jim_GetString(objv[0], NULL), "?", 1);
-            }
+    if (retcode == JIM_ERR) {
+        JimAppendStackTrace(interp,
+            Jim_GetString(objv[0], NULL), "?", 1);
+    }
         }
     }
     /* Decr refcount of arguments and return the retcode */
@@ -8540,6 +8540,11 @@ int Jim_EvalObj(Jim_Interp *interp, Jim_Obj *scriptObjPtr)
         } else {
             /* Call [unknown] */
             retcode = JimUnknown(interp, argc, argv);
+            if (retcode == JIM_ERR) {
+                JimAppendStackTrace(interp,
+                    Jim_GetString(argv[0], NULL), script->fileName,
+                    token[i-argc*2].linenr);
+            }
         }
         if (retcode != JIM_OK) {
             i -= argc*2; /* point to the command name. */
index b2a8ade561065d5c97b1e5c79dcb83dd5b1b5fc5..50eb99e0b1a3c518437dc0a8206e9be98c219d90 100644 (file)
@@ -357,35 +357,20 @@ int jim_command(command_context_t *context, char *line)
        int retval=ERROR_OK;
        int retcode=Jim_Eval(interp, line);
        
-       const char *result;
-       int reslen;
-       result = Jim_GetString(Jim_GetResult(interp), &reslen);
        if (retcode == JIM_ERR) {
-               int len, i;
-               
-               LOG_USER_N("Runtime error, file \"%s\", line %d:" JIM_NL, interp->errorFileName, interp->errorLine);
-               LOG_USER_N("    %s" JIM_NL,
-               Jim_GetString(interp->result, NULL));
-               Jim_ListLength(interp, interp->stackTrace, &len);
-               for (i = 0; i < len; i += 3) {
-                       Jim_Obj *objPtr;
-                       const char *proc, *file, *line;
-                       
-                       Jim_ListIndex(interp, interp->stackTrace, i, &objPtr, JIM_NONE);
-                       proc = Jim_GetString(objPtr, NULL);
-                       Jim_ListIndex(interp, interp->stackTrace, i+1, &objPtr, JIM_NONE);
-                       file = Jim_GetString(objPtr, NULL);
-                       Jim_ListIndex(interp, interp->stackTrace, i+2, &objPtr, JIM_NONE);
-                       line = Jim_GetString(objPtr, NULL);
-                       LOG_USER_N("In procedure '%s' called at file \"%s\", line %s" JIM_NL, proc, file, line);
-           }
+               Jim_PrintErrorMessage(interp);
            long t;
            if (Jim_GetLong(interp, Jim_GetVariableStr(interp, "openocd_result", JIM_ERRMSG), &t)==JIM_OK)
            {
                return t;
            }
            return ERROR_FAIL;
-       } else if (retcode == JIM_EXIT) {
+       } 
+       const char *result;
+       int reslen;
+       result = Jim_GetString(Jim_GetResult(interp), &reslen);
+               
+       if (retcode == JIM_EXIT) {
                /* ignore. */
        /* exit(Jim_GetExitCode(interp)); */
        } else {