Board index » cppbuilder » Debug

Debug


2004-09-19 10:33:08 PM
cppbuilder59
I am used to using development environments like eclipse. When I debug, I
set the debug-marks and can examine the whole class or function by
stepping-in. While I do this, I'm able to see the values of the variables,
objects, etc. Does this work also with c++builder. I have set the
debug-marks and then start. When I do each statement, I cannot examine the
values of the variables or objects as from the marked-point. Is it right
this way or am I missing something. The whole routine (F8) does also not
work as wished.
Thanks in anticipation
Harpharp
 
 

Re:Debug

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote

"Harp" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>I am used to using development environments like eclipse. When
>I debug, I set the debug-marks and can examine the whole class
>or function by stepping-in. While I do this, I'm able to see the
>values of the variables, objects, etc. Does this work also with
>c++builder.

Yes.

>I have set the debug-marks and then start. When I do each
>statement, I cannot examine the values of the variables or objects
>as from the marked-point.

Why not? Please be more specific. What EXACTLY are you doing? What
EXACTLY happens when you try to do anything?


Gambit

Thanks a lot!
I just have the following code and would like to open/read some files. When
I place my halt-point at checkfile, hoping that with step-in I would be able
to find out what is going withing the code (which values the variables like
sRoot is having, ...etc.), can I also display with fprint here?
Thanks
bool CheckFile(){
bool bRegOK;
char sComputerName[255];
TRegistry * Reg = new TRegistry;
AnsiString sRoot;
FILE *fInFile;
GetEnvironmentVariable("COMPUTERNAME", sComputerName, 50);
g_sRoot = sRoot;
sRoot = "C:\Program\Borland\CBuilder6\Projects\Test.xml";
/*if (g_sTestSet != "")
sRoot = g_sTestSet;
else
g_sTestSet = sRoot;
*/
fInFile = fopen(sRoot.c_str(), "r");
if (fInFile == NULL)
if (!Form1->ExistsError()){
MyDialog("Test is not found!\r\n\r\nPath: " + sRoot, "of
test is missing", mtError, TMsgDlgButtons() << mbOK);
fclose(fInFile);
delete Reg;
delete fInFile;
return false;
}
else
printf("Test.xml is now openend");
fclose(fInFile);
sRoot = "C:\Program\Borland\CBuilder6\Projects\master.txt";
/* if (g_sLogFile != "")
sRoot = g_sLogFile;
else
g_sLogFile = sRoot;
*/
fInFile = fopen(sRoot.c_str(), "rb");
if (fInFile == NULL)
if (!Form1->ExistsError()){
if (MyDialog("LogFile is not found!\r\n\r\nPfad: " + sRoot +
"\nShould I create the file?", "Master file error", mtError,
TMsgDlgButtons() << mbYes << mbNo) == 6){
fInFile = fopen(sRoot.c_str(), "w");
fclose(fInFile);
}
else{
delete Reg;
delete fInFile;
return false;
}
}
else
printf("master.txt is now openend");
fclose(fInFile);
delete Reg;
delete fInFile;
return true;
}
 

Re:Debug

"Harp" < XXXX@XXXXX.COM >wrote in message
Quote
I am used to using development environments like eclipse. When
I debug, I set the debug-marks and can examine the whole class
or function by stepping-in. While I do this, I'm able to see the
values of the variables, objects, etc. Does this work also with
c++builder.
Yes.
Quote
I have set the debug-marks and then start. When I do each
statement, I cannot examine the values of the variables or objects
as from the marked-point.
Why not? Please be more specific. What EXACTLY are you doing? What
EXACTLY happens when you try to do anything?
Gambit
 

{smallsort}

Re:Debug

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote

"Harp" < XXXX@XXXXX.COM >wrote in message
news:414fe9e1$ XXXX@XXXXX.COM ...

>When I place my halt-point at checkfile, hoping that with step-in
>I would be able to find out what is going withing the code (which
>values the variables like sRoot is having, ...etc.)

You can do all of that just fine.

>can I also display with fprint here?

I do not understand what you are asking. Please clearify.

>sRoot = "C:\Program\Borland\CBuilder6\Projects\Test.xml";

You need to double up on the backslashes:

sRoot = "C:\\Program\\Borland\\CBuilder6\\Projects\\Test.xml";

>fInFile = fopen(sRoot.c_str(), "r");
>if (fInFile == NULL)
>if (!Form1->ExistsError()){
>MyDialog("Test is not found!\r\n\r\nPath: " + sRoot, "of
>test is missing", mtError, TMsgDlgButtons() << mbOK);
>fclose(fInFile);

There is no need to call fclose() when fopen() returned NULL. There is
nothing available to close in the first place.

>delete fInFile;

Never call 'delete' on a FILE* pointer. That is plain wrong. The only
reason it does not crash on you altogether is because fInFile has been set
to NULL beforehand and the 'delete' operator recognizes and ignores NULL
pointers.

>else
>printf("Test.xml is now openend");

You are missing curly braces on your "if(fInFile == NULL)" statement.
Thus,
the 'else' statement will get associated with the
"if(!Form1->ExistsError())" statement instead, and you will then be
executing that printf() statement at the wrong time. When the file fails
to
open, you are displaying to the user that the file opened successfully.
That is misleading. You should be calling that printf() statement when
fopen() returns a non-NULL pointer instead.

>sRoot = "C:\Program\Borland\CBuilder6\Projects\master.txt";

Again, you are missing the double backslashes:

sRoot = "C:\\Program\\Borland\\CBuilder6\\Projects\\master.txt";


Gambit


Thanks Gambit for your nice comments. I still have another point, with hope
to get a help.
I quite agree with you due to what you said about deleting a file. I was
thinking that an object could be deleted, with File being also one of
them.Hmmmmmm! Why can't a file be deleted?
What can be deleted and when?
If I have something like this:
HANDLE hFile1;
TRegistry * Reg = new TRegistry;
can I say:
delete hFile1;
delete Reg;
When do I say that and when do I say close(file) or closeHandle(hFile1)?
Thanks in anticipation!
Harp
 

Re:Debug

"Harp" < XXXX@XXXXX.COM >wrote in message
Quote
When I place my halt-point at checkfile, hoping that with step-in
I would be able to find out what is going withing the code (which
values the variables like sRoot is having, ...etc.)
You can do all of that just fine.
Quote
can I also display with fprint here?
I do not understand what you are asking. Please clearify.
Quote
sRoot = "C:\Program\Borland\CBuilder6\Projects\Test.xml";
You need to double up on the backslashes:
sRoot = "C:\\Program\\Borland\\CBuilder6\\Projects\\Test.xml";
Quote
fInFile = fopen(sRoot.c_str(), "r");
if (fInFile == NULL)
if (!Form1->ExistsError()){
MyDialog("Test is not found!\r\n\r\nPath: " + sRoot, "of
test is missing", mtError, TMsgDlgButtons() << mbOK);
fclose(fInFile);
There is no need to call fclose() when fopen() returned NULL. There is
nothing available to close in the first place.
Quote
delete fInFile;
Never call 'delete' on a FILE* pointer. That is plain wrong. The only
reason it does not crash on you altogether is because fInFile has been set
to NULL beforehand and the 'delete' operator recognizes and ignores NULL
pointers.
Quote
else
printf("Test.xml is now openend");
You are missing curly braces on your "if(fInFile == NULL)" statement. Thus,
the 'else' statement will get associated with the
"if(!Form1->ExistsError())" statement instead, and you will then be
executing that printf() statement at the wrong time. When the file fails to
open, you are displaying to the user that the file opened successfully.
That is misleading. You should be calling that printf() statement when
fopen() returns a non-NULL pointer instead.
Quote
sRoot = "C:\Program\Borland\CBuilder6\Projects\master.txt";
Again, you are missing the double backslashes:
sRoot = "C:\\Program\\Borland\\CBuilder6\\Projects\\master.txt";
Gambit
 

Re:Debug

"Harp" < XXXX@XXXXX.COM >wrote in message
Quote
I was thinking that an object could be deleted, with File being
also one of them.Hmmmmmm! Why can't a file be deleted?
A FILE is not an object. A FILE pointer is not allocated using the 'new'
operator, so you cannot free it using the 'delete' operator. You can only
use fclose() to free a FILE pointer that was returned by fopen().
Quote
If I have something like this:
<snip>
can I say:
delete hFile1;
No.
Quote
delete Reg;
Yes.
Quote
When do I say that and when do I say close(file) or closeHandle(hFile1)?
Gambit
 

Re:Debug

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote

"Harp" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>I was thinking that an object could be deleted, with File being
>also one of them.Hmmmmmm! Why can't a file be deleted?

A FILE is not an object. A FILE pointer is not allocated using the 'new'
operator, so you cannot free it using the 'delete' operator. You can only
use fclose() to free a FILE pointer that was returned by fopen().

>If I have something like this:
<snip>
>can I say:
>delete hFile1;

No.

>delete Reg;

Yes.

>When do I say that and when do I say close(file) or closeHandle(hFile1)?


Gambit


Thanks a lot!
Harp
 

Re:Debug

Hi
I have to reverse engineering a complex application, with more than 1000
units (a class or a form in each unit), handled in a single Delphi 7
project.
I would like to know if there is some Jedi tool to help in the debugging
process. Specifically, that I would like is to follow he source execution,
like in the Delphi de{*word*81}, but with writing the result in a file instead
of reading it at the screen.
Thanks for any help.
Cordially
Richard
 

Re:Debug

Richard H wrote:
Quote
Hi

I have to reverse engineering a complex application, with more than 1000
units (a class or a form in each unit), handled in a single Delphi 7
project.
I would like to know if there is some Jedi tool to help in the debugging
process. Specifically, that I would like is to follow he source execution,
like in the Delphi de{*word*81}, but with writing the result in a file instead
of reading it at the screen.
Thanks for any help.

Cordially

Richard


Hi,
You can use TraceTool (written in Delphi).
www.codeproject.com/csharp/TraceTool.asp
It is a visual tracing tool. I think this can help you (I hope!). I
haven't used it myself but it looks good.
--
Cheers,
Phillip Flores
"Keep track of those project times...use VeriTime"
www.pcfworks.com
 

Re:Debug

Thanks for your answer, Phillip.
It seems it is not the tool I am looking for, as to use it I have to insert
lines of code in the sources. I am looking for something more like the
de{*word*81} does, and to get the path of the execution in the source code...
Er, I think I am not clear :)
Richard
 

Re:Debug

You might try asking the AutomatedQA people if AQTime will do what you
want, as I know it does similar things like coverage profiling and call
graphs
Cheers,
Jim Cooper
__________________________________________
Jim Cooper XXXX@XXXXX.COM
Tabdee Ltd www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
__________________________________________
 

Re:Debug

Richard H wrote:
Quote
I would like to know if there is some Jedi tool to help in the
debugging process. Specifically, that I would like is to follow he
source execution, like in the Delphi de{*word*81}, but with writing the
result in a file instead of reading it at the screen.
Have a look at inTrace www.cyamon.com/intrace1.htm
Regards,
Anthony Egerton
 

Re:Debug

Quote
You might try asking the AutomatedQA people if AQTime will do what you
want, as I know it does similar things like coverage profiling and call
graphs
Ok, thanks for the tip :) !
 

Re:Debug

Quote
Have a look at inTrace www.cyamon.com/intrace1.htm
Ok, thanks, I'll have a look at it.
Cordially
Richard
 

Re:Debug

I have the configuration lancher, I disable error insight and all the
together are disable. The program run well but when I have an error the
debug don't show me where the error is on the .pas file. Why?