I have never been able to get the Variable Formatter to work in the
windows version of CW 9.3. Until now, I have just worked around its
lack. Since I am trying to debug some code that makes use of strings, I
decided to try to figure out what was wrong.
This is the contents of the "MSL Variable Formats.xml" file that was
in my Plugins/Sup****t/VariableFormats directory:
<variableformats>
<variableformat>
<osname>osMac</osname>
<typename>std::vector</typename>
<typenamematch>BeginsWith</typename>
<expression>"size:" + ^var.size_ </expression>
</variableformat>
<variableformat>
<condition>^var.r_.first_.r.t1.f_ == 0</condition>
<osname>osMac</osname>
<typename>std::basic_string</typename>
<typenamematch>BeginsWith</typename>
<expression>^var.r_.first_.r.t2.data_</expression>
</variableformat>
<variableformat>
<condition>^var.r_.first_.r.t1.f_ == 1</condition>
<osname>osMac</osname>
<typename>std::basic_string</typename>
<typenamematch>BeginsWith</typename>
<expression>^var.r_.first_.r.t1.data_</expression>
</variableformat>
<variableformat>
<osname>osWin32</osname>
<runtimename>runtimeWin32</runtimename>
<typename>vector</typename>
<expression>"size:" +
^var.__vector_imp.__vector_pod.size_</expression>
</variableformat>
<variableformat>
<osname>osWin32</osname>
<runtimename>runtimeWin32</runtimename>
<typename>basic_string</typename>
<expression>^var.data_</expression>
</variableformat>
</variableformats>
When I compared the osWin32 fields with what was displayed in the
debugger, it was obvious that neither the vector nor the string
definitions matched. What was displayed in the debugger matched fairly
closely with the osMac version.
I then tried a modified version of osWin32 vector and string that
corresponded to the fields shown in the debugger. At the same time, I
also implemented the Rect example that was given in the release note.
The new file is:
<variableformats>
<variableformat>
<osname>osWin32</osname>
<runtimename>runtimeWin32</runtimename>
<condition>^var.r_.compressed_pair_imp.first_.r.t1.f_ ==
0</condition>
<typename>std::basic_string</typename>
<typenamematch>BeginsWith</typename>
<expression>^var.r_.first_.r.t2.data_</expression>
</variableformat>
<variableformat>
<osname>osWin32</osname>
<runtimename>runtimeWin32</runtimename>
<condition>^var.r_.compressed_pair_imp.first_.r.t1.f_ ==
1</condition>
<typename>std::basic_string</typename>
<typenamematch>BeginsWith</typename>
<expression>^var.r_.compressed_pair_imp.first_.r.t1.data_</expression>
</variableformat>
<variableformat>
<osname>osWin32</osname>
<runtimename>runtimeWin32</runtimename>
<typename>vector</typename>
<expression>
"size:" + ^var.__vec_constructor.__vec_deleter.size_
</expression>
</variableformat>
<variableformat>
<osname>osWin32</osname>
<runtimename>runtimeWin32</runtimename>
<typename>Rect</typename>
<expression>
"{T: " + ^var.top +
" L: " + ^var.left +
" B: " + ^var.bottom +
" R: " + ^var.right +
"}{H: " + (^var.bottom - ^var.top) +
" W: " + (^var.right - ^var.left) + "}"
</expression>
</variableformat>
</variableformats>
I used the following test program to try the revised script:
#include <string>
#include <vector>
struct Rect {
Rect(int T, int L, int B, int R): top(T), left(L),
bottom(B), right(R) {}
int top;
int left;
int bottom;
int right;
};
int main() {
Rect box(11, 22, 33, 44);
std::string str("This is a string");
std::vector<int> arr(10, 1234);
return 0;
}
The debugger did not not display any values for either the vector or the
string variables. The variable, box, did show the error message, "Can't
read the memory from the address", so at least I was able to verify that
my changes did have some effect.
Can someone provide me with some WinOS Variable Formatter examples
that actually work? Right now, I am at a loss as to how to proceed
without some correct scripts that function as they should.


|