Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > debugging problem

Reply
Thread Tools

debugging problem

 
 
Ron Eggler
Guest
Posts: n/a
 
      02-25-2008
Hi,

I'm developing software for Linux on my desktop. The software gets compiled
and the binary is downloaded to the target system where i can't install a
debugging system or something.
I've written following code:
#ifdef INIT_REPORT
std:fstream out("/usr/share/NovaxTSP/INITreport.txt", std::ios_base::in |
std::ios_base:ut | std::ios_base::app);
if(!out) { // if out couldn't be opened, print error and exit
std::cout << "Cannot open reportfile:
\"/usr/share/NovaxTSP/INITreport.txt\"." << std::endl;
exit(0);
}
std::string str = newLine + "\n";
out << newLine.c_str() << std::endl;
out.close();
#endif

The problem is, it works just fine on my desktop but it returns
with "/usr/share/NovaxTSP/INITreport.txt" on the target system. I'm root
and i do have write access to /usr/share/NovaxTSP/. I have
tried "touch /usr/share/NovaxTSP/INITreport.txt" but this didn't help
either.
df -h shows that I'm not running out of space either
Does any one have any other idea what could go wrong?

Thanks,
Ron

 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      02-25-2008
Ron Eggler wrote:
> Hi,
>
> I'm developing software for Linux on my desktop. The software gets compiled
> and the binary is downloaded to the target system where i can't install a
> debugging system or something.
> I've written following code:
> #ifdef INIT_REPORT
> std:fstream out("/usr/share/NovaxTSP/INITreport.txt", std::ios_base::in |
> std::ios_base:ut | std::ios_base::app);


Is this combination of flags legit?

> if(!out) { // if out couldn't be opened, print error and exit
> std::cout << "Cannot open reportfile:
> \"/usr/share/NovaxTSP/INITreport.txt\"." << std::endl;


Odds are good that errno is probably valid here, assuming you're using
gcc. Try adding:

#include <cerrno>
#include <cstdio>

at the top, and adding

std::cout << std::strerror(errno)

in your error message.

> exit(0);
> }
> std::string str = newLine + "\n";
> out << newLine.c_str() << std::endl;
> out.close();
> #endif
>
> The problem is, it works just fine on my desktop but it returns
> with "/usr/share/NovaxTSP/INITreport.txt" on the target system. I'm root
> and i do have write access to /usr/share/NovaxTSP/. I have
> tried "touch /usr/share/NovaxTSP/INITreport.txt" but this didn't help
> either.
> df -h shows that I'm not running out of space either
> Does any one have any other idea what could go wrong?
>
> Thanks,
> Ron
>

 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      02-25-2008
Ron Eggler wrote:
> Hi,
>
> I'm developing software for Linux on my desktop. The software gets compiled
> and the binary is downloaded to the target system where i can't install a
> debugging system or something.
> I've written following code:
> #ifdef INIT_REPORT
> std:fstream out("/usr/share/NovaxTSP/INITreport.txt", std::ios_base::in |
> std::ios_base:ut | std::ios_base::app);
> if(!out) { // if out couldn't be opened, print error and exit
> std::cout << "Cannot open reportfile:
> \"/usr/share/NovaxTSP/INITreport.txt\"." << std::endl;
> exit(0);
> }
> std::string str = newLine + "\n";
> out << newLine.c_str() << std::endl;
> out.close();
> #endif
>
> The problem is, it works just fine on my desktop but it returns
> with "/usr/share/NovaxTSP/INITreport.txt" on the target system. I'm root
> and i do have write access to /usr/share/NovaxTSP/. I have
> tried "touch /usr/share/NovaxTSP/INITreport.txt" but this didn't help
> either.
> df -h shows that I'm not running out of space either
> Does any one have any other idea what could go wrong?
>


You may also get better answers in gnu.g++.help, or one of the many
linux programming newsgroups.
 
Reply With Quote
 
diligent.snail@gmail.com
Guest
Posts: n/a
 
      02-25-2008
On Feb 25, 7:12 pm, Ron Eggler <(E-Mail Removed)> wrote:
> Hi,
>
> I'm developing software for Linux on my desktop. The software gets compiled
> and the binary is downloaded to the target system where i can't install a
> debugging system or something.
> I've written following code:
> #ifdef INIT_REPORT
> std:fstream out("/usr/share/NovaxTSP/INITreport.txt", std::ios_base::in |
> std::ios_base:ut | std::ios_base::app);
> if(!out) { // if out couldn't be opened, print error and exit
> std::cout << "Cannot open reportfile:
> \"/usr/share/NovaxTSP/INITreport.txt\"." << std::endl;
> exit(0);
> }
> std::string str = newLine + "\n";
> out << newLine.c_str() << std::endl;
> out.close();
> #endif
>
> The problem is, it works just fine on my desktop but it returns
> with "/usr/share/NovaxTSP/INITreport.txt" on the target system. I'm root
> and i do have write access to /usr/share/NovaxTSP/. I have
> tried "touch /usr/share/NovaxTSP/INITreport.txt" but this didn't help
> either.
> df -h shows that I'm not running out of space either
> Does any one have any other idea what could go wrong?
>
> Thanks,
> Ron


On your previous posting of the same exact problem, people adviced to
use tools such as 'touch' and 'strace' in order to diagonise your
problem. It would have helped much if you had followed up on that and
not started a new thread. At least people who try to help would know
where they stand.

Regards.
 
Reply With Quote
 
Ron Eggler
Guest
Posts: n/a
 
      02-25-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> On Feb 25, 7:12 pm, Ron Eggler <(E-Mail Removed)> wrote:
>> Hi,
>>
>> I'm developing software for Linux on my desktop. The software gets
>> compiled and the binary is downloaded to the target system where i can't
>> install a debugging system or something.
>> I've written following code:
>> #ifdef INIT_REPORT
>> std:fstream out("/usr/share/NovaxTSP/INITreport.txt",
>> std::ios_base::in |
>> std::ios_base:ut | std::ios_base::app);
>> if(!out) { // if out couldn't be opened, print error and exit
>> std::cout << "Cannot open reportfile:
>> \"/usr/share/NovaxTSP/INITreport.txt\"." << std::endl;
>> exit(0);
>> }
>> std::string str = newLine + "\n";
>> out << newLine.c_str() << std::endl;
>> out.close();
>> #endif
>>
>> The problem is, it works just fine on my desktop but it returns
>> with "/usr/share/NovaxTSP/INITreport.txt" on the target system. I'm root
>> and i do have write access to /usr/share/NovaxTSP/. I have
>> tried "touch /usr/share/NovaxTSP/INITreport.txt" but this didn't help
>> either.
>> df -h shows that I'm not running out of space either
>> Does any one have any other idea what could go wrong?
>>
>> Thanks,
>> Ron

>
> On your previous posting of the same exact problem, people adviced to
> use tools such as 'touch' and 'strace' in order to diagonise your
> problem. It would have helped much if you had followed up on that and
> not started a new thread. At least people who try to help would know
> where they stand.


Right, I thought I'd start over again by better explaining my situation with
the target system. I didn't mention this in the other thread. I realized
that I had done it wrongly and started over again.
I'll now follow-up with red floyd's suggestion and will see how far I get
with that. I appreciate every kind of help!

Ron

 
Reply With Quote
 
Ron Eggler
Guest
Posts: n/a
 
      02-25-2008
red floyd wrote:

[snip]

>
> Odds are good that errno is probably valid here, assuming you're using
> gcc. Try adding:
>
> #include <cerrno>
> #include <cstdio>
>
> at the top, and adding
>
> std::cout << std::strerror(errno)


Hi Floyed,

This helped me alot, i changed my cout line to:
std::cout << "Cannot open reportfile:
\"/usr/share/NovaxTSP/INITreport.txt\". Error #:" << std::strerror(errno)
<< " Out: " << static_cast<bool>(out) << std::endl;
and this is what I got:
"Cannot open reportfile: "/usr/share/NovaxTSP/INITreport.txt". Error
#:Success Out: 0"
So I guess the if should be if (out< 0) to do the expected thing, right?
PS I tried to static cast out to int but it wouldn't compile and since it's
an if i thought I'd cast it to bool instead.

Thanks,
Ron

>
> in your error message.
>

[snip]

 
Reply With Quote
 
Ron Eggler
Guest
Posts: n/a
 
      02-25-2008
Ron Eggler wrote:

> red floyd wrote:
>
> [snip]
>
>>
>> Odds are good that errno is probably valid here, assuming you're using
>> gcc. Try adding:
>>
>> #include <cerrno>
>> #include <cstdio>
>>
>> at the top, and adding
>>
>> std::cout << std::strerror(errno)

>
> Hi Floyed,
>
> This helped me alot, i changed my cout line to:
> std::cout << "Cannot open reportfile:
> \"/usr/share/NovaxTSP/INITreport.txt\". Error #:" << std::strerror(errno)
> << " Out: " << static_cast<bool>(out) << std::endl;
> and this is what I got:
> "Cannot open reportfile: "/usr/share/NovaxTSP/INITreport.txt". Error
> #:Success Out: 0"
> So I guess the if should be if (out< 0) to do the expected thing, right?
> PS I tried to static cast out to int but it wouldn't compile and since
> it's an if i thought I'd cast it to bool instead.

No,
not that simnple, I changed the if clause, ran it on the target and what I
get nothing doing a
/var/run/sbin # cat /usr/share/NovaxTSP/INITreport.txt
/var/run/sbin #
even tho it for sure would have written data in the file. Any other help?
I'm pretty onfused here....
Thanks,
Ron
>
>>
>> in your error message.
>>

> [snip]


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I skip debugging Ajax when debugging my code? AAaron123 ASP .Net 3 07-28-2009 04:07 PM
Debugging C vs debugging C++ jacob navia C Programming 11 10-27-2006 07:19 PM
Debugging Problem Stephen Noronha ASP .Net 0 09-02-2005 09:49 PM
Problem Debugging COM componenets from ASP.NET =?Utf-8?B?U2FuZHVyZWE=?= ASP .Net 0 07-29-2005 09:04 AM
No Debugging of C# Server-Side Script, but Code-Behind Debugging Works Johann Blake ASP .Net 1 01-05-2004 03:01 PM



Advertisments