Hello,
(Vista, CL. rev. 3899)
I tried to set up a predefined type for printing selections in hex values. I choose the debugger command to "print /x" and the Expression to "$(Variable)". However, the output is not in hex like the gdb command line output, e.g "print /x my_struct", but in standard integer. Is there any way to change this, so I can print in hex? ( I tried "print /x" and "print \/x" as well)
Debugger - predefined types
-
- CodeLite Veteran
- Posts: 63
- Joined: Mon Apr 06, 2009 10:43 am
- Contact:
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Debugger - predefined types
Turn on debugger logging and see what does codelite passes to the debugger and what is the debugger reply
Eran
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Veteran
- Posts: 63
- Joined: Mon Apr 06, 2009 10:43 am
- Contact:
Re: Debugger - predefined types
Hello Eran,
here is the full story:
I define a struct like this:
typedef struct
{
unsigned int a;
unsigned short array[20];
unsigned int b;
} MyStruct2;
MyStruct2 my_struct_2;
What I want is to see is the struct exactly the same like in debugger tooltips (if enabled) or in the watch window, but with all values printed as hex.
The tooltip prints everything in signed (is there a way to change the format of the debugger tooltip?).
When adding my_struct_2 to the watches, setting format to "hex" and double click the item, I get the same as the tooltip (no hex values).
If I add a predefined type to the debugger diaolg and add my_struct_2 to the watches as hex(using the predefined typ where the command is set to "print /x"), the debugger log is like this:
DEBUG>>00000992-file-list-exec-source-file
DEBUG>>00000992^done,line="50",file="[snip]main.c",fullname="[snip]main.c",macro-info="0"
DEBUG>>00000993-var-create watch_num_47 * my_struct_2
DEBUG>>00000994-var-set-format watch_num_47 hexadecimal
DEBUG>>00000995-var-evaluate-expression watch_num_47
DEBUG>>00000996-var-delete "watch_num_47"
DEBUG>>00000993^done,name="watch_num_47",numchild="3",value="{...}",type="MyStruct2"
DEBUG>>00000994^done,format="hexadecimal",value="{...}"
DEBUG>>00000995^done,value="{...}"
DEBUG>>00000996^done,ndeleted="1"
If I then double click the item in the watch window I get the same as the tooltip with the debugger log:
DEBUG>>00000997^done,name="var3",numchild="3",value="{...}",type="MyStruct2"
DEBUG>>00000998-var-list-children "var3"
DEBUG>>00000998^done,numchild="3",children=[child={name="var3.a",exp="a",numchild="0",type="unsigned int"},child={name="var3.array",exp="array",numchild="20",type="short unsigned int [20]"},child={name="var3.b",exp="b",numchild="0",type="unsigned int"}]
DEBUG>>00000999-var-evaluate-expression "var3.a"
DEBUG>>00001000-var-evaluate-expression "var3.array"
DEBUG>>00001001-var-evaluate-expression "var3.b"
DEBUG>>00000999^done,value="1"
DEBUG>>00001000^done,value="[20]"
DEBUG>>00001001^done,value="2"
DEBUG>>00001002-var-list-children "var3.array"
DEBUG>>00001002^done,numchild="20",children=[child={name="var3.array.0",exp="0",numchild="0",type="short unsigned int"},child={name="var3.array.1",exp="1",numchild="0",type="short unsigned int"},child={name="var3.array.2",exp="2",numchild="0",type="short unsigned int"},child={name="var3.array.3",exp="3",numchild="0",type="short unsigned int"},child={name="var3.array.4",exp="4",numchild="0",type="short unsigned int"},child={name="var3.array.5",exp="5",numchild="0",type="short unsigned int"},child={name="var3.array.6",exp="6",numchild="0",type="short unsigned int"},child={name="var3.array.7",exp="7",numchild="0",type="short unsigned int"},child={name="var3.array.8",exp="8",numchild="0",type="short unsigned int"},child={name="var3.array.9",exp="9",numchild="0",type="short unsigned int"},child={name="var3.array.10",exp="10",numchild="0",type="short unsigned int"},child={name="var3.array.11",exp="11",numchild="0",type="short unsigned int"},child={name="var3.array.12",exp="12",numchild="0",type="short unsigned int"},child={name="var3.array.13",exp="13",numchild="0",type="short unsigned int"},child={name="var3.array.14",exp="14",numchild="0",type="short unsigned int"},child={name="var3.array.15",exp="15",numchild="0",type="short unsigned int"},child={name="var3.array.16",exp="16",numchild="0",type="short unsigned int"},child={name="var3.array.17",exp="17",numchild="0",type="short unsigned int"},child={name="var3.array.18",exp="18",numchild="0",type="short unsigned int"},child={name="var3.array.19",exp="19",numchild="0",type="short unsigned int"}]
DEBUG>>00001003-var-evaluate-expression "var3.array.0"
DEBUG>>00001004-var-evaluate-expression "var3.array.1"
DEBUG>>00001005-var-evaluate-expression "var3.array.2"
DEBUG>>00001006-var-evaluate-expression "var3.array.3"
DEBUG>>00001007-var-evaluate-expression "var3.array.4"
DEBUG>>00001008-var-evaluate-expression "var3.array.5"
DEBUG>>00001009-var-evaluate-expression "var3.array.6"
DEBUG>>00001010-var-evaluate-expression "var3.array.7"
DEBUG>>00001011-var-evaluate-expression "var3.array.8"
DEBUG>>00001012-var-evaluate-expression "var3.array.9"
DEBUG>>00001013-var-evaluate-expression "var3.array.10"
DEBUG>>00001014-var-evaluate-expression "var3.array.11"
DEBUG>>00001015-var-evaluate-expression "var3.array.12"
DEBUG>>00001016-var-evaluate-expression "var3.array.13"
DEBUG>>00001017-var-evaluate-expression "var3.array.14"
DEBUG>>00001018-var-evaluate-expression "var3.array.15"
DEBUG>>00001019-var-evaluate-expression "var3.array.16"
DEBUG>>00001020-var-evaluate-expression "var3.array.17"
DEBUG>>00001021-var-evaluate-expression "var3.array.18"
DEBUG>>00001022-var-evaluate-expression "var3.array.19"
DEBUG>>00001003^done,value="0"
DEBUG>>00001004^done,value="1"
DEBUG>>00001005^done,value="2"
DEBUG>>00001006^done,value="3"
DEBUG>>00001007^done,value="4"
DEBUG>>00001008^done,value="5"
DEBUG>>00001009^done,value="6"
DEBUG>>00001010^done,value="7"
DEBUG>>00001011^done,value="8"
DEBUG>>00001012^done,value="9"
DEBUG>>00001013^done,value="10"
DEBUG>>00001014^done,value="11"
DEBUG>>00001015^done,value="12"
DEBUG>>00001016^done,value="13"
DEBUG>>00001017^done,value="14"
DEBUG>>00001018^done,value="15"
DEBUG>>00001019^done,value="16"
DEBUG>>00001020^done,value="17"
DEBUG>>00001021^done,value="18"
DEBUG>>00001022^done,value="19"
DEBUG>>00001023-var-delete "var3"
DEBUG>>00001023^done,ndeleted="24"
What I want the output to be is the same as typing the gdb command "print /x my_struct_2" on the command line:
$1 = {
a = 0x1
,
array = {0x0
, 0x1
, 0x2
, 0x3
, 0x4
, 0x5
, 0x6
, 0x7
, 0x8
, 0x9
, 0xa
, 0xb
, 0xc
, 0xd
, 0xe
, 0xf
, 0x10
, 0x11
, 0x12
, 0x13
}
,
b = 0x2
}
here is the full story:
I define a struct like this:
typedef struct
{
unsigned int a;
unsigned short array[20];
unsigned int b;
} MyStruct2;
MyStruct2 my_struct_2;
What I want is to see is the struct exactly the same like in debugger tooltips (if enabled) or in the watch window, but with all values printed as hex.
The tooltip prints everything in signed (is there a way to change the format of the debugger tooltip?).
When adding my_struct_2 to the watches, setting format to "hex" and double click the item, I get the same as the tooltip (no hex values).
If I add a predefined type to the debugger diaolg and add my_struct_2 to the watches as hex(using the predefined typ where the command is set to "print /x"), the debugger log is like this:
DEBUG>>00000992-file-list-exec-source-file
DEBUG>>00000992^done,line="50",file="[snip]main.c",fullname="[snip]main.c",macro-info="0"
DEBUG>>00000993-var-create watch_num_47 * my_struct_2
DEBUG>>00000994-var-set-format watch_num_47 hexadecimal
DEBUG>>00000995-var-evaluate-expression watch_num_47
DEBUG>>00000996-var-delete "watch_num_47"
DEBUG>>00000993^done,name="watch_num_47",numchild="3",value="{...}",type="MyStruct2"
DEBUG>>00000994^done,format="hexadecimal",value="{...}"
DEBUG>>00000995^done,value="{...}"
DEBUG>>00000996^done,ndeleted="1"
If I then double click the item in the watch window I get the same as the tooltip with the debugger log:
DEBUG>>00000997^done,name="var3",numchild="3",value="{...}",type="MyStruct2"
DEBUG>>00000998-var-list-children "var3"
DEBUG>>00000998^done,numchild="3",children=[child={name="var3.a",exp="a",numchild="0",type="unsigned int"},child={name="var3.array",exp="array",numchild="20",type="short unsigned int [20]"},child={name="var3.b",exp="b",numchild="0",type="unsigned int"}]
DEBUG>>00000999-var-evaluate-expression "var3.a"
DEBUG>>00001000-var-evaluate-expression "var3.array"
DEBUG>>00001001-var-evaluate-expression "var3.b"
DEBUG>>00000999^done,value="1"
DEBUG>>00001000^done,value="[20]"
DEBUG>>00001001^done,value="2"
DEBUG>>00001002-var-list-children "var3.array"
DEBUG>>00001002^done,numchild="20",children=[child={name="var3.array.0",exp="0",numchild="0",type="short unsigned int"},child={name="var3.array.1",exp="1",numchild="0",type="short unsigned int"},child={name="var3.array.2",exp="2",numchild="0",type="short unsigned int"},child={name="var3.array.3",exp="3",numchild="0",type="short unsigned int"},child={name="var3.array.4",exp="4",numchild="0",type="short unsigned int"},child={name="var3.array.5",exp="5",numchild="0",type="short unsigned int"},child={name="var3.array.6",exp="6",numchild="0",type="short unsigned int"},child={name="var3.array.7",exp="7",numchild="0",type="short unsigned int"},child={name="var3.array.8",exp="8",numchild="0",type="short unsigned int"},child={name="var3.array.9",exp="9",numchild="0",type="short unsigned int"},child={name="var3.array.10",exp="10",numchild="0",type="short unsigned int"},child={name="var3.array.11",exp="11",numchild="0",type="short unsigned int"},child={name="var3.array.12",exp="12",numchild="0",type="short unsigned int"},child={name="var3.array.13",exp="13",numchild="0",type="short unsigned int"},child={name="var3.array.14",exp="14",numchild="0",type="short unsigned int"},child={name="var3.array.15",exp="15",numchild="0",type="short unsigned int"},child={name="var3.array.16",exp="16",numchild="0",type="short unsigned int"},child={name="var3.array.17",exp="17",numchild="0",type="short unsigned int"},child={name="var3.array.18",exp="18",numchild="0",type="short unsigned int"},child={name="var3.array.19",exp="19",numchild="0",type="short unsigned int"}]
DEBUG>>00001003-var-evaluate-expression "var3.array.0"
DEBUG>>00001004-var-evaluate-expression "var3.array.1"
DEBUG>>00001005-var-evaluate-expression "var3.array.2"
DEBUG>>00001006-var-evaluate-expression "var3.array.3"
DEBUG>>00001007-var-evaluate-expression "var3.array.4"
DEBUG>>00001008-var-evaluate-expression "var3.array.5"
DEBUG>>00001009-var-evaluate-expression "var3.array.6"
DEBUG>>00001010-var-evaluate-expression "var3.array.7"
DEBUG>>00001011-var-evaluate-expression "var3.array.8"
DEBUG>>00001012-var-evaluate-expression "var3.array.9"
DEBUG>>00001013-var-evaluate-expression "var3.array.10"
DEBUG>>00001014-var-evaluate-expression "var3.array.11"
DEBUG>>00001015-var-evaluate-expression "var3.array.12"
DEBUG>>00001016-var-evaluate-expression "var3.array.13"
DEBUG>>00001017-var-evaluate-expression "var3.array.14"
DEBUG>>00001018-var-evaluate-expression "var3.array.15"
DEBUG>>00001019-var-evaluate-expression "var3.array.16"
DEBUG>>00001020-var-evaluate-expression "var3.array.17"
DEBUG>>00001021-var-evaluate-expression "var3.array.18"
DEBUG>>00001022-var-evaluate-expression "var3.array.19"
DEBUG>>00001003^done,value="0"
DEBUG>>00001004^done,value="1"
DEBUG>>00001005^done,value="2"
DEBUG>>00001006^done,value="3"
DEBUG>>00001007^done,value="4"
DEBUG>>00001008^done,value="5"
DEBUG>>00001009^done,value="6"
DEBUG>>00001010^done,value="7"
DEBUG>>00001011^done,value="8"
DEBUG>>00001012^done,value="9"
DEBUG>>00001013^done,value="10"
DEBUG>>00001014^done,value="11"
DEBUG>>00001015^done,value="12"
DEBUG>>00001016^done,value="13"
DEBUG>>00001017^done,value="14"
DEBUG>>00001018^done,value="15"
DEBUG>>00001019^done,value="16"
DEBUG>>00001020^done,value="17"
DEBUG>>00001021^done,value="18"
DEBUG>>00001022^done,value="19"
DEBUG>>00001023-var-delete "var3"
DEBUG>>00001023^done,ndeleted="24"
What I want the output to be is the same as typing the gdb command "print /x my_struct_2" on the command line:
$1 = {
a = 0x1
,
array = {0x0
, 0x1
, 0x2
, 0x3
, 0x4
, 0x5
, 0x6
, 0x7
, 0x8
, 0x9
, 0xa
, 0xb
, 0xc
, 0xd
, 0xe
, 0xf
, 0x10
, 0x11
, 0x12
, 0x13
}
,
b = 0x2
}
-
- CodeLite Veteran
- Posts: 63
- Joined: Mon Apr 06, 2009 10:43 am
- Contact:
Re: Debugger - predefined types
Hello Eran,
would it be possible to change the sources so the watch window and the ascii viewer window contain 3 columns where the variable is shown in decimal | hex | ascii in parallel? This would help me a lot while debugging.
Thanks.
would it be possible to change the sources so the watch window and the ascii viewer window contain 3 columns where the variable is shown in decimal | hex | ascii in parallel? This would help me a lot while debugging.
Thanks.
-
- CodeLite Veteran
- Posts: 63
- Joined: Mon Apr 06, 2009 10:43 am
- Contact:
Re: Debugger - predefined types
Hello Eran,
is the "Debugger Command" column evaluated at all for predefined types? Because if I put something like "abc" in it, the watch is ok (like "print variable"). The log output is:
DEBUG>>00001101-var-create watch_num_34 * myVar
DEBUG>>00001102-var-set-format watch_num_34 natural
DEBUG>>00001103-var-evaluate-expression watch_num_34
DEBUG>>00001104-var-delete "watch_num_34"
DEBUG>>00001101^done,name="watch_num_34",numchild="0",value="10",type="int"
DEBUG>>00001102^done,format="natural",value="10"
DEBUG>>00001103^done,value="10"
DEBUG>>00001104^done,ndeleted="1"
is the "Debugger Command" column evaluated at all for predefined types? Because if I put something like "abc" in it, the watch is ok (like "print variable"). The log output is:
DEBUG>>00001101-var-create watch_num_34 * myVar
DEBUG>>00001102-var-set-format watch_num_34 natural
DEBUG>>00001103-var-evaluate-expression watch_num_34
DEBUG>>00001104-var-delete "watch_num_34"
DEBUG>>00001101^done,name="watch_num_34",numchild="0",value="10",type="int"
DEBUG>>00001102^done,format="natural",value="10"
DEBUG>>00001103^done,value="10"
DEBUG>>00001104^done,ndeleted="1"
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: Debugger - predefined types
Sorry, I don't understand the question
Eran
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Veteran
- Posts: 63
- Joined: Mon Apr 06, 2009 10:43 am
- Contact:
Re: Debugger - predefined types
1.) All I want to do is add a predefined type within the debugger options that will print (more correct: show in watch window) the hex value of a selected variable. Like "print /x myVar".
2.) I would not need this if the "ascii viewer" output would contain the binary AND the hex format of a variable in parallel.
-
- CodeLite Veteran
- Posts: 63
- Joined: Mon Apr 06, 2009 10:43 am
- Contact:
Re: Debugger - predefined types
Hello Eran,
I patched my local sources to get this working. Maybe there is a smarter way, but at least the output is what I expect for single variables.
void DebuggerAsciiViewer::UpdateView(const wxString &expr, const wxString &value)
{
m_textCtrlExpression->SetValue(expr);
wxString evaluated (value);
evaluated.Replace(wxT("\r\n"), wxT("\n"));
evaluated.Replace(wxT("\n,"), wxT(",\n"));
evaluated.Replace(wxT("\n\n"), wxT("\n"));
m_textView->SetReadOnly(false);
m_textView->ClearAll();
// start changes
// m_textView->SetText(evaluated);
{
unsigned long TempLong;
wxString myString = evaluated.AfterLast(wxT(' '));
if(myString.ToULong(&TempLong))
{
evaluated << wxT(" = ") << wxString::Format(_T("0x%X"), TempLong);
m_textView->SetText(evaluated);
}
else
{
m_textView->SetText(evaluated);
}
}
// end changes
m_textView->SetReadOnly(true);
}
I patched my local sources to get this working. Maybe there is a smarter way, but at least the output is what I expect for single variables.
void DebuggerAsciiViewer::UpdateView(const wxString &expr, const wxString &value)
{
m_textCtrlExpression->SetValue(expr);
wxString evaluated (value);
evaluated.Replace(wxT("\r\n"), wxT("\n"));
evaluated.Replace(wxT("\n,"), wxT(",\n"));
evaluated.Replace(wxT("\n\n"), wxT("\n"));
m_textView->SetReadOnly(false);
m_textView->ClearAll();
// start changes
// m_textView->SetText(evaluated);
{
unsigned long TempLong;
wxString myString = evaluated.AfterLast(wxT(' '));
if(myString.ToULong(&TempLong))
{
evaluated << wxT(" = ") << wxString::Format(_T("0x%X"), TempLong);
m_textView->SetText(evaluated);
}
else
{
m_textView->SetText(evaluated);
}
}
// end changes
m_textView->SetReadOnly(true);
}