the watches window adds, automatic, local variables but not what i need to test. for that i nee do it manually(select the variable and then click on right button for add it to watches window).
until here fine, but see these: i have a class button with a getTop() function member.
vector<button> btnarray;
int WinMain()
{
//int arraysize=ArraySize(btnarray, button);//geting the array size
btnarray.resize(8);
for (int i=0; i<btnarray.size(); i++)
{
int b=100 + ((i+1)*50);
btnarray[i].setTop(b);
//OutputDebugStr(to_string(btnarray[i].getTop()).c_str());
btnarray[i].setLeft(0);
btnarray[i].setText(to_string(i));
btnarray[i].MouseClick=[i]()
{
MessageBox(btnarray[i].getText());
};
}
now heres the questions points:
- how can i add the btnarray [ i ].getTop() to watches window and see it's value?
- how can i see the string of OutputDebugStr() on debug mode?
1. Select it and wait for the popup to show up or right click -> add watch
2. This is more of a gdb question, but have you tried to enable the debug output in the settings -> debugger?
for that i must, 1st, enter\execute on debug mode. on watches window, on value section, i get 'Not available'. what means? why i can't get it's value? or is because i'm not using on code?
GDB can execute function, but I'm not sure what are the requirements. Sometimes it just fails.
BTW. I have really hard time understanding what you're talking about, please try harder to explain what you're doing.
i'm trying using the watches windows for see the btnarray.getTop() value. and send some messages, for test other values, for watches window
You have add a watch for btnarray.getTop() or btnarray and then inspect the raw values.
i did. but where is the values i get these string 'not avaiblable' or something like these
Have you read this: http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks ?
Does it work with simple local variables?
finally i get the point.
i must go to getTop() class member and test the intTop value.
thanks for all
another question: i can use OutputDebugString() function, but how can i see it's value\string?
(i'm trying, in hard way, learn more about debuging)
It should be in the log of the debugger (probably in the full log, which you have to enable in the debugger settings).
I've told you about this already.
Another option is to define it to something that prints on stdout/stderr:)
i use windows api applications. so it's there another way?
Have you checked the log?
The debugger tab in you 'logs and others' window.
i'm sorry, the string isn't printed on that tab :(
button btnarray[8];
int WinMain()
{
int arraysize=ArraySize(btnarray, button);//geting the array size
//btnarray.resize(8);
int i=0;
for (i; i<arraysize; i++)
{
int inttop=150 + (i*50);
btnarray[i].setTop(inttop);
OutputDebugStr(to_string(btnarray[i].getTop()).c_str());//i belive these string must be printed on debugger tab, right?
btnarray[i].setLeft(0);
btnarray[i].setText(to_string(i));
btnarray[i].MouseClick=[i]()
{
MessageBox(btnarray[i].getText());
};
Generally this is the place where you should see it.
Have you enabled full log from the debugger?
i think i did. but i don't have sure... can you tell me more about?
If you see the debug: at the beginning of the line, then you have done it.
heres what i see on debug tab:
"Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\
Adding source dir: C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\
Adding file: C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\bin\Debug\classcontrols.exe
Changing directory to: C:/Users/Cambalinho/Documents/CodeBlocks/classcontrols/bin/Debug
Set variable: PATH=.;C:\Program Files (x86)\CodeBlocks\mingw32\i686-w64-mingw32\lib;C:\Program Files (x86)\CodeBlocks\mingw32\bin;C:\Program Files (x86)\CodeBlocks\mingw32;C:\Program Files (x86)\PC Connectivity Solution;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Broadcom\Broadcom 802.11\Driver;C:\Program Files (x86)\Skype\Phone
Starting debugger: C:\Program Files (x86)\CodeBlocks\mingw32\bin\gdb.exe -nx -fullname -quiet -args C:/Users/Cambalinho/Documents/CodeBlocks/classcontrols/bin/Debug/classcontrols.exe
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.6
Child process PID: 4636"
i'm sorry, i know that i'm miss something, but i don't know what :(
i don't see the result of 'OutputDebugString("hello world");' :(
Obviously you've not enabled full logging...
Settings -> Debugger -> Common -> Full (Debug) Log...
And when pasting please use code tags (the # button above the editor).
now it's the full, but the:
OutputDebugString("hello world");isn't showed on it :(
QuoteBuilding to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\
Adding source dir: C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\
Adding file: C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\bin\Debug\classcontrols.exe
Changing directory to: C:/Users/Cambalinho/Documents/CodeBlocks/classcontrols/bin/Debug
Set variable: PATH=.;C:\Program Files (x86)\CodeBlocks\mingw32\i686-w64-mingw32\lib;C:\Program Files (x86)\CodeBlocks\mingw32\bin;C:\Program Files (x86)\CodeBlocks\mingw32;C:\Program Files (x86)\PC Connectivity Solution;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Broadcom\Broadcom 802.11\Driver;C:\Program Files (x86)\Skype\Phone
[debug]Command-line: C:\Program Files (x86)\CodeBlocks\mingw32\bin\gdb.exe -nx -fullname -quiet -args C:/Users/Cambalinho/Documents/CodeBlocks/classcontrols/bin/Debug/classcontrols.exe
[debug]Working dir : C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\bin\Debug
Starting debugger: C:\Program Files (x86)\CodeBlocks\mingw32\bin\gdb.exe -nx -fullname -quiet -args C:/Users/Cambalinho/Documents/CodeBlocks/classcontrols/bin/Debug/classcontrols.exe
done
[debug]> set prompt >>>>>>cb_gdb:
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
[debug]Reading symbols from C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\bin\Debug\classcontrols.exe...
[debug]done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.6
[debug]Copyright (C) 2013 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law. Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "i686-w64-mingw32".
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off
Debugger name and version: GNU gdb (GDB) 7.6
[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Function "__cxa_throw" not defined.
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source C:\Program Files (x86)\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory C:/Users/Cambalinho/Documents/CodeBlocks/classcontrols/
[debug]Source directories searched: C:/Users/Cambalinho/Documents/CodeBlocks/classcontrols;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "C:/Users/Cambalinho/Documents/CodeBlocks/classcontrols/main.cpp:79"
[debug]Breakpoint 2 at 0x405869: file C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\main.cpp, line 79.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\bin\Debug\classcontrols.exe
Child process PID: 1704
[debug][New Thread 1704.0xdd4]
[debug][New Thread 1704.0x850]
[debug][New Thread 1704.0x10fc]
[debug][New Thread 1704.0xe18]
[debug][New Thread 1704.0x1200]
[debug][New Thread 1704.0xcf8]
[debug]Breakpoint 2, WinMain@16 (hThisInstance=0x400000, hPreviousInstance=0x0, lpCmLine=0x8b3ad5 "", nCmdShow=10) at C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\main.cpp:79
[debug]C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\main.cpp:79:1830:beg:0x405869
[debug]>>>>>>cb_gdb:
At C:\Users\Cambalinho\Documents\CodeBlocks\classcontrols\main.cpp:79
[debug]> info locals
[debug]arraysize = -1
[debug]i = 1
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]hThisInstance = 0x400000
[debug]hPreviousInstance = 0x0
[debug]lpCmLine = 0x8b3ad5 ""
[debug]nCmdShow = 10
[debug]>>>>>>cb_gdb:
Continuing...
[debug]> cont
[debug]Continuing.
Trying to pause the running process...
[debug][New Thread 1704.0xd14]
[debug]Program received signal SIGTRAP, Trace/breakpoint trap.
[debug][Switching to Thread 1704.0xd14]
[debug]0x7734000d in ntdll!DbgBreakPoint () from C:\Windows\system32\ntdll.dll
[debug]>>>>>>cb_gdb:
Program received signal SIGTRAP, Trace/breakpoint trap.
In ntdll!DbgBreakPoint () (C:\Windows\system32\ntdll.dll)
[debug]> quit
Debugger finished with status 0
Then it is a GDB or MinGW progblem (don't know if outputdebugstring is a OS or runtime thing).
that's why i did my own:
void debugtext(string text)
{
//create a permanent controls
static form debugwindow("Debug Window");
static label lblDebugText("",debugwindow);
//control the static depending on it's parent size
debugwindow.Resize=[]()
{
lblDebugText.setWidth(debugwindow.width-10);
lblDebugText.setHeight(debugwindow.height-10);
};
//resize the parent window
debugwindow.width=1000;
debugwindow.height=400;
//print the text depnding if have some text or not
if(lblDebugText.getText()=="")
lblDebugText.setText(text);
else
lblDebugText.setText(lblDebugText.getText() + "\n" + text);
}
using it:
bool blnRightMouseButtonDown=false;
button btnarray[8];
int WinMain()
{
OutputDebugString("hello world");
int arraysize=ArraySize(btnarray, button);//geting the array size
int i=0;
for (i; i<arraysize; i++)
{
int inttop=150 + (i*50);
btnarray[i].setTop(inttop);
btnarray[i].setLeft(0);
btnarray[i].setText(to_string(i));
btnarray[i].MouseClick=[i]()
{
MessageBox(btnarray[i].getText());
};
debugtext((string)to_string(inttop) + "\t" + to_string(i));
}
https://onedrive.live.com/?id=C3EF456E15C8DEB6!1295&cid=C3EF456E15C8DEB6&group=0&parId=C3EF456E15C8DEB6!197&o=OneUp
it's from my public hotmail folder