PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > debugging problem
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
debugging problem

Réponse
 
LinkBack Outils de la discussion
Vieux 25/02/2008, 18h12   #1
Ron Eggler
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut debugging problem

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
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

  Réponse avec citation
Vieux 25/02/2008, 18h39   #2
red floyd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: debugging problem

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
> 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
>

  Réponse avec citation
Vieux 25/02/2008, 19h09   #3
red floyd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: debugging problem

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
> 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++., or one of the many
linux programming newsgroups.
  Réponse avec citation
Vieux 25/02/2008, 19h25   #4
diligent.snail@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: debugging problem

On Feb 25, 7:12 pm, Ron Eggler <noth...@example.com> 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
> 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 ed much if you had followed up on that and
not started a new thread. At least people who try to would know
where they stand.

Regards.
  Réponse avec citation
Vieux 25/02/2008, 20h02   #5
Ron Eggler
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: debugging problem

diligent.snail@gmail.com wrote:

> On Feb 25, 7:12 pm, Ron Eggler <noth...@example.com> 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
>> 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 ed much if you had followed up on that and
> not started a new thread. At least people who try to 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 !

Ron

  Réponse avec citation
Vieux 25/02/2008, 20h20   #6
Ron Eggler
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: debugging problem

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 ed 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]

  Réponse avec citation
Vieux 25/02/2008, 20h24   #7
Ron Eggler
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: debugging problem

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 ed 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 ?
I'm pretty onfused here....
Thanks,
Ron
>
>>
>> in your error message.
>>

> [snip]


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h23.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,17121 seconds with 15 queries