This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS: JDB kill DSS thread?



Hi,

 

When using DSS, we sometimes run into some trouble-making polling conditions. Say if we poll for some variable or waiting for a breakpoint to be hit and they do not happen, the js in DSS runs in an infinite while loop. When this happens we frequently need to restart CCS and everything.

 

Since eclipse is java application, we tried connecting to it with jdb. Then with “threads”, we see that some worker threads appear to be associated with DSS, and they have name like “Worker-12”, “Worker-13”, etc.

 

We are aware that killing threads in general can be risky and may cause program state corruption, but most of the looping conditions we set are on some simple variables, such as value of specific target processor register, so there is a high chance that the thread can be terminated without bad consequences.

 

Please instruct that if we can kill(jdb) such thread as a way to abort the endless loop. We tried the kill command, 1) out of thread scope 2) within thread scope, but all got error message.

  

 

 

 

Noah

  • Noah,

    I agree with you that killing child processes can lead to very unpredictable results, but I am still a bit unclear if you are using the Scripting Console from inside CCS or the DSS from the command line.

    If you are using DSS from the command line, did you try to use the setScriptTimeout method of a ScriptingEnvironment.instance object? This limits the runtime length of the script.

    If you haven't done so, you can set a timeout for the script (in milliseconds) as shown below:

    var DEFAULTTIMEOUT = 7200000;
    var script = ScriptingEnvironment.instance();
    script.setScriptTimeout(DEFAULTTIMEOUT);

    If you are using the scripting console, I would need to investigate further but I suspect the suggestion above would work as well.

    I hope to have understood the issue at hand.

    Regards,
    Rafael
  • I am using from CCS. Although I set a short timeout, it can still hangs indefinitely.

    I cannot afford the time investigate Rhino internals and its integration with CCS. Please advise us any working solution to this problem however imperfect.

    Noah

  • Noah,

    How are you running your code? In conversations here I confirmed the timeout method works, but only for DebugServer calls. In other words, you can get the timeout to work by running the target using a Debug Server call just as in the example below:

    js:> script = ScriptingEnvironment.instance();
    
    js:> script.setScriptTimeout(6000);
    
    js:> debugServer = script.getServer("DebugServer.1");
    
    js:> debugSession = debugServer.openSession(".*/ARM9_0");
    
    js:> debugSession.target.run();
    com.ti.debug.engine.scripting.Target.run(): Timed out after 6000ms
    js:> 

    Reference:

    http://processors.wiki.ti.com/index.php/Scripting_Console#Services 

    Hope this helps,

    Rafael

  • That does work but only as in this example: It times out from target.run(). It only quits a function with no input and output variable, no exception (destruct variable, stack unrolling, etc.), so if setScriptTimeout is only for DebugSession than it is very easily implemented. However, it does not to give anything really more than the "Suspend" button in CCS.

    1. But is still hangs at "while(1)", or other deep nested loop, in which case if timeout were to work, there are much more work such as allowing throw exception by a timer interrupt and do all the unrolling upwards. So is there no way whatsoever for timing out general loop structure, in the current DSS/rhino implementation?

    2. Could you try to kill the script's particular thread in JDB and see if it possible to fix the com.sun.tools.examples.debug.expr.ParseException error? Is there a way to identify a worker thread whose forced kills has little or none effect to the DSS environment?

    3. For "while(1);" which hangs DSS, it there a way like "Ctrl C/Z" in bash to promptly kill that?


    Noah

  • Hi,

    Please see latest reply, particularly if it is possible to do bash-like termination.