debugging problem

Discussion in 'C++' started by Ron Eggler, Feb 25, 2008.

  1. Ron Eggler

    Ron Eggler Guest

    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::eek:fstream out("/usr/share/NovaxTSP/INITreport.txt", std::ios_base::in |
    std::ios_base::eek: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
     
    Ron Eggler, Feb 25, 2008
    #1
    1. Advertising

  2. Ron Eggler

    red floyd Guest

    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::eek:fstream out("/usr/share/NovaxTSP/INITreport.txt", std::ios_base::in |
    > std::ios_base::eek: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
    >
     
    red floyd, Feb 25, 2008
    #2
    1. Advertising

  3. Ron Eggler

    red floyd Guest

    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::eek:fstream out("/usr/share/NovaxTSP/INITreport.txt", std::ios_base::in |
    > std::ios_base::eek: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.
     
    red floyd, Feb 25, 2008
    #3
  4. Ron Eggler

    Guest

    On Feb 25, 7:12 pm, 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::eek:fstream out("/usr/share/NovaxTSP/INITreport.txt", std::ios_base::in |
    > std::ios_base::eek: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.
     
    , Feb 25, 2008
    #4
  5. Ron Eggler

    Ron Eggler Guest

    wrote:

    > On Feb 25, 7:12 pm, 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::eek:fstream out("/usr/share/NovaxTSP/INITreport.txt",
    >> std::ios_base::in |
    >> std::ios_base::eek: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
     
    Ron Eggler, Feb 25, 2008
    #5
  6. Ron Eggler

    Ron Eggler Guest

    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]
     
    Ron Eggler, Feb 25, 2008
    #6
  7. Ron Eggler

    Ron Eggler Guest

    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]
     
    Ron Eggler, Feb 25, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2FuZHVyZWE=?=

    Problem Debugging COM componenets from ASP.NET

    =?Utf-8?B?U2FuZHVyZWE=?=, Jul 29, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    453
    =?Utf-8?B?U2FuZHVyZWE=?=
    Jul 29, 2005
  2. Stephen Noronha

    Debugging Problem

    Stephen Noronha, Sep 2, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    469
    Stephen Noronha
    Sep 2, 2005
  3. Johann Blake
    Replies:
    1
    Views:
    1,241
    Hermit Dave
    Jan 5, 2004
  4. jacob navia

    Debugging C vs debugging C++

    jacob navia, Oct 26, 2006, in forum: C Programming
    Replies:
    11
    Views:
    623
    Ian Collins
    Oct 27, 2006
  5. AAaron123
    Replies:
    3
    Views:
    690
    AAaron123
    Jul 28, 2009
Loading...

Share This Page