Knowledgebase
CODESCAPE
Why do the parameters in my callstack contain abstract values?
This is normally a limitation of the debug information supplied by your compiler and a function of the compilers optimiser. The arguments tend to be passed within a set of registers, and reused for each sub-call. When a subcall is made the compiler pushes the current registers onto the stack to reuse those registers for the next call. Sadly, there is not normally any debugging information about when this happens and where the old values go, so CODESCAPE has no way of finding the old values to show in the call stack. CODESCAPE does try to figure out if these pushes are happening in the prolog of the function, and will code read to try and get this correct, however if you have turned on the optimiser then it is quite likely that the pushes will not happen until later on in the function. At this point CODESCAPE has no way to figure out where the parameter is now being stored. The only solutions we can offer are to either turn optimisations off for your debugging build, or nag your compiler supplier to see if they can work with us to provide a better solution.
Why does my source code jump about when I'm single stepping my program?
This normally happens in an optimised program. The compiler has rearranged and reused your code to make your program smaller and faster. The problem now is that the code generated is not linear in the way the source code is. The following example shows a section of code with the annotated disassembly that was generated when compiled. The arrows on the diageam show that some lines of source generate multiple sections on assembly code. When tracing the cursor will bounce up and down to indicate the interleaving of the op-code blocks.
Example

The only solution is turn off the optimiser. This can be done for just the object/function you are debugging if your development environment allows for that
This still won't solve it for some instances, e.g. the for loop. There are probably some other cases where it is virtually impossible for the compiler to generate code following the same sequence as the source.
Can I debug a function that is defined in a header file?
Yes
Why is CODESCAPE not reloading my elf, but loading the previous version?
If you are running on a Samba based SMB server (a Linux box serving up Windows files) then it may be a wrinkle of the Linux filing system you are seeing. CODESCAPE normally keeps a file handle open to the elf file loaded so it can load infomation on demand. In Windows this would prevent you writing over the elf file whilst CODESCAPE has it open, but in Linux it causes the old elf file to be 'hidden', and a new elf file created with the same name. The consequence is that anything opening the file will now get the new elf file, but anything (such as CODESCAPE) that already had the file open will still have a handle to the old version. When you do a reload, CODESCAPE will believe the file to have not changed, and load the old version again. The solution is to tick the 'unload and copy' tick box in CODESCAPEs elf load dialog. Then CODESCAPE will release its copy and check the new file upon a reset/reload.
Why can't CODESCAPE find my Dash under linux?
This is most frequently caused because you haven't set up a default route and gateway, this can be checked and corrected using route.
Scripting and DA-Script
How do I get a JScript to invoke another JScript?
This can be a very useful thing to do. For example, you can call generated scripts from your own scripts; the magic trick is to load the sub script into a string and then evaluate that string. You can perform that with the following code:
var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = fso.OpenTextFile(filename );
var script = file.ReadAll();
file.close();
eval ( script );
How do I print out a hex number in my JScript?
There is native support in JScript for this, but it has problems with sign'edness. The native way is to use a format extension of .toString(16)
s = x.toString(16);
As the toString(16) function has problems, we wrote a small helper function...
// converts to hex - Displays leading zeros and copes with minus number
function toHex( value )
{
hexTab = "0123456789ABCDEF";
var result = "";
for (ToHexi = 0; ToHexi < 8; ++ToHexi )
{
var temp=value & 0x0f;
result = hexTab.substr( temp, 1 ) + result;
value = value >>>4;
}
return result;
}It's also possible to make all numbers unsigned using the >>> operator, so:
s = (x >>> 0).toString(16);
How do I turn a number into a character (ASCII) to print?
You can use the JScript string function fromCharCode() for this. For example:
s += String.fromCharCode(ch);
How do I use DA-Script with Python, Perl and Ruby?
Python
You need to use the win32com extensions, e.g.:
import win32com.client
try :
dash = wind32com.client.Dispatch("DA-Script.Dash")
print "Initialized DA-Script"
dash.UseTargetOn(322, "192.168.152.44")
# Do some work
except :
# Failed to initialize DA-Script
PERL
You need to use the Win21::OLE extensions e.g.:
use Win32::OLE;
my $dash = Win32::OLE->new("DA-Script.Dash");
$dash->UseTargetOn(322, "192.168.152.44");
# Do some work
The lack of exceptions in Perl makes it somewhat harder to use than languages with them.
Ruby
Yes you can use Ruby, you need to use the win32ole extensions, e.g:
require 'win32ole'
begin
dash = WIN32OLE.new('DA-Script.Dash')
dash.UseTarget ( 541)
# Do some work
rescue WIN32OLERuntimeError
$stderr.print $!
endAre there any documents covering the DA-Script extensions?
Yes. Please refer to the DA-Script documentation that came with your installation.
I'm fed up with having to prefix all the debugging commands with the name of the 'dash' object. Is there a way that I can overwrite that, similar to the 'using' directive in C++ ?
Yes, there is. You can 'export' the dash object into the global namespace using the 'with' command. Then you can use the DA-Script commands without having to prefix them. For instance:
with (dash)
{
var pc = ReadRegister("pc");
}Can I write a script that runs in both CODESCAPE and DA-Script ?
Yes. There are a couple of things to be aware of though:
- Not all commands in CODESCAPE are available in DashScript, such as the GUI and graphics commands.
- All commands in DA-Script normally have to be prefixed with the name of the dash object, such as 'dash.xxx'.
I ran one script, but now no more scripts run, why is this?
This is a common problem experienced if you terminate a script using Ctrl-C, or if the target terminates unxexpectedly, then DA-Script will fail to work at all, and CODESCAPE will also perform poorly. Have a look in your task list (Ctrl-Shift-Escape). There may be a rogue DA-Script.exe or DASHSC~1.EXE still running when no script is running. You need to terminate this process before DA-Script will work again.
I got a message telling me that 'the target has gone away', what is causing this?
This could be caused by a number of things :
- Make sure you have the LATEST version of DA-Script.
- Make sure you have the LATEST IMGDIAL.DLL
- You may need a PRConfig.xml in the same directory as DA-Script.exe that is configured appropiately for your target. This is so that DA-Script.exe understands the memory lay out of your target.
I don't think DA-Script is installed correctly - either I didn't use the installer or it broke at some point. How do I fix this?
From a command prompt run DA-Script.exe with the -RegServer? switch :
with (dash) DA-Script -RegServer
