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.

Loadti current working directory wrong

Have a number of applications which read in data files,  paths are relative to current working directory either ".\file.dat" or ".\subdirectory\file2.dat"

The "loadti" and/or Debug Server Scripting stuff is using location of the outfile as current working directory, which is incorrect.

Same behavior either on Win32 or Linux hosts, uses location of outfile as working directory.

Data file to be read in by the outfile, is in current working directory, outfile is one level up ..\rs_c64.out :

C:\work\RS>dir .\rs.gold
 Directory of C:\work\RS

10/25/2001  02:07 PM             3,760 rs.gold

 

C:\work\RS>"C:\Program Files\Texas Instruments\CCSv4\scripting\examples\loadti\loadti.bat"  --timeout=300000 --cfg-file=C:\ace_outfiles\DSK_6416.ccxml -o=..\rs_c64.out

***** DSS Generic Loader *****

START: 15:52:41 GMT-0600 (CST)

Configuring Debug Server for specified target...
Done
Loading repository "C:\Program Files\Texas Instruments\ccsv4\common\targetdb\"
Loading file "C:\ace_outfiles\.DSK_6416.ccxml.cache2"
C:\Documents and Settings\a0322488\user\CCSTargetConfigurations\.NewTargetConfiguration.ccxml.cache2  [99 elements,  0.047s]
Parsed 99 XML element(s), from 1 file(s), in 0.062 seconds
TARGET: Texas Instruments XDS560 PCI Emulator_0
Connecting to target...
C64xx_0: GEL Output: GEL StartUp Complete.

testEnv.outFiles: ..\rs_c64.out
Loading ..\rs_c64.out
Done
Target running...
Interrupt to abort . . .
frame: 1, cycles: 1887399
Error in opening golden data input file: rs.gold
NORMAL COMPLETION: 2814519 cycles

END: 15:52:50 GMT-0600 (CST)

Copy input file up one level to same directory as the outfile, and run same command again.  Then it works. 

C:\work\RS>copy rs.gold ..\
        1 file(s) copied.

C:\work\RS>"C:\Program Files\Texas Instruments\CCSv4\scripting\examples\loadti\loadti.bat"  --timeout=300000 --cfg-file=C:\ace_outfiles\DSK_6416.ccxml -o=..\rs_c64.out

***** DSS Generic Loader *****

START: 16:07:06 GMT-0600 (CST)

Configuring Debug Server for specified target...
Done
Loading repository "C:\Program Files\Texas Instruments\ccsv4\common\targetdb\"
Loading file "C:\ace_outfiles\.DSK_6416.ccxml.cache2"
C:\Documents and Settings\a0322488\user\CCSTargetConfigurations\.NewTargetConfiguration.ccxml.cache2  [99 elements,  0.063s]
Parsed 99 XML element(s), from 1 file(s), in 0.063 seconds
TARGET: Texas Instruments XDS560 PCI Emulator_0
Connecting to target...
C64xx_0: GEL Output: GEL StartUp Complete.

testEnv.outFiles: ..\rs_c64.out
Loading ..\rs_c64.out
Done
Target running...
Interrupt to abort . . .
frame: 1, cycles: 1887344
frame: 2, cycles: 1891854
frame: 3, cycles: 1897371
frame: 4, cycles: 1900267
frame: 5, cycles: 2008985
frame: 6, cycles: 2007198
frame: 7, cycles: 1993545
frame: 8, cycles: 1999906
frame: 9, cycles: 1998509
frame: 10, cycles: 1998932
SDS_PASS: Reed-Solomon Error Detection PASSED.
SDS_PERF: 1st = 1887344 Avg = 1958391 Tot = 19583911 Min = 1/1887344 Max = 5/2008985
NORMAL COMPLETION: 25221543 cycles

END: 16:07:15 GMT-0600 (CST)

  • The default behaviour for the Debugger is to set the current directory to the last loaded program.  As such, all File I/O operations that utilize relative paths will be relative to the location of the loaded program. 

    CCS 3.3 provided a way for the user to indicate a specific directory from which all File I/O operations should occur but this isn't directly exposed to users in CCSv4.  However, the the option is still available internally:  you'll need to make use of some non-documented GEL expressions to access them.

    The segment of JavaScript included below will tell DS to open any files with relative paths relative to a directory that you specify.  In this case I've set that directory to be the same directory as the loadti script so that the relative path behaviour should be relative to where the script is running:

        // Set a default directory that File I/O operations with relative paths will loaded from.
        // Tells DS what the default directory should be.
        debugSession.expression.evaluate( "DEBUG_SetStringProperty(\"FileIODefaultDirectory\", \"C:/Program Files/Texas Instruments/CCSv4/scripting/examples/loadti\")" );

        // Then tell DS that the default location should be utilized.
        debugSession.expression.evaluate( "DEBUG_SetBoolProperty(\"FileIOUseDefaultDirectory\", 1 )" );

    If you open main.js in your install's scripting/examples/loadti directory and add the above code snippet after the call to debugSession = debugServer.openSession("*", "*"); (~ line 164) the script should work as you desire.

    Chris

  • Your solution fixed the problem, ended up with a rather backslash riddled string, but it works:

    var mybigstring = "\"DEBUG_SetStringProperty(\\\"FileIODefaultDirectory\\\",\\\"" + dssScriptEnv.getCurrentDirectory() +"\\\"\)\"" ;

    java.lang.System.out.println("Setting CWD : " + mybigstring);

    debugSession.expression.evaluate(mybigstring);

    debugSession.expression.evaluate("DEBUG_SetBoolProperty(\"FileIOUseDefaultDirectory\", 1 )" );

    ------------ Output seems to verify working directory "C:\work\RS", outfile directory "C:\tmp", finds files in working directory -----------

     

    Configuring Debug Server for specified target...
    Done
    TARGET: Texas Instruments XDS560 PCI Emulator_0
    Connecting to target...
    C64xx_0: GEL Output: GEL StartUp Complete.

    Setting CWD : "DEBUG_SetStringProperty(\"FileIODefaultDirectory\",\"C:\work\RS\")"
    testEnv.outFiles: c:\tmp\rs_c64.out
    Loading c:\tmp\rs_c64.out

    Thanks !