help on debugging

This is a discussion on help on debugging within the C++ Programming forums, part of the General Programming Boards category; hello, i dont know if its righ to say sth like this here , so im sorry if i shouldnt ...

  1. #1
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493

    help on debugging

    hello, i dont know if its righ to say sth like this here , so im sorry if i shouldnt have posted this !
    anyway ,i need to debug my program , (current project) , but the catch here is i dont know what those debugging stuffs are ! i start debuging some windows poping up and say sth , but i dont understand it , if there is anyone who can help me understand where the problem is and what it is , i will be very thankful ,

    here are some screen shots and also some text file that i dont know how to work with them ! i dont understand them !
    ( if the source code can help you , i can give you that, (its not complete, and is some how very messed up! it needs more work, but some member functions are complete and should work , i just dont understand why i get a "send error, dont send " windows!!)
    when i entered some instruction , after that the program did its work, it crashes!
    Code:
    http://master.huricane.googlepages.com/fulllength.GIF
    while debugging! stuff i dont understand!
    Code:
    http://master.huricane.googlepages.com/screenshot.GIF
    callstack.txt

    debugassembely.txt
    and this is the projects exe file so far . if you want to see it error! here it is:
    claexe.rar
    you should start with ORG a number (e.g 10 or 88)
    then enter your instructions .. you can find some instruction here .: #4

    again , i would be very thankful if any one tell me what those texts mean !
    --------------------------------
    by the way , gotta tell you sth , i fyou disable the loop in main.cpp, the program runs once, so far so good, and it wont generate any error!!(i mean dont send error! ) . but you know i=its not good either m cause i need to process all of the strings ,
    (fetch is giving one string at each loop, and the other members work with this string , the loops continue until the fetch reaches "exit". exit must not be processed !this is a brief summery of what i was doing there! i know its realllly messed up , meany redeclarations !but believe me , i had no ther choices, i didnt know debugging , so that my way of finding error! sorry for being that messed up.!!)
    Last edited by Masterx; 01-27-2009 at 12:37 PM.
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,687
    Actual code would help.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    Quote Originally Posted by Salem View Post
    Actual code would help.
    tanx for your attention
    REVISEDCLAnewsearch.rar
    REVISEDCLAnewsearch.zip

    by the way , gotta tell you sth , i fyou disable the loop in main.cpp, the program runs once, so far so good, and it wont generate any error!!(i mean dont send error! ) . but you know i=its not good either m cause i need to process all of the strings ,
    (fetch is giving one string at each loop, and the other members work with this string , the loops continue until the fetch reaches "exit". exit must not be processed !this is a brief summery of what i was doing there! i know its realllly messed up , meany redeclarations !but believe me , i had no ther choices, i didnt know debugging , so that my way of finding error! sorry for being that messed up.!!)
    ------------------------
    new problem i found , when you enter the value of a variable in declaration e.g num, 65 or 12 or 15 it crashes!!buf if you enter 99 or any thing else and plus if you enter one digit numbers such as 5 or 7 or 8 , it wont generate error !! im reallly confused. i checked the number conversion function works! it convers 86 or stuff . but i dont know why it generates error and crashes on 65! or 10 or 12(these are decimal so they must be converted to octal! )!!
    sample input !:
    (ORG 10
    CLA
    RED num
    num: 5
    exit

    Runs fine. to the end , and processes all of the strings, but crashes at the end.
    ------------------

    ORG 10
    CLA
    RED num
    num: 65
    exit
    Generates Error! before reaching the end and process all of the strings it crashes
    --------------------------
    ORG 10
    CLA
    RED num
    num: 99
    exit
    conversion occured! and rest of the info. at the end program crashes.
    Runs fine again!
    )
    Last edited by Masterx; 01-28-2009 at 05:38 AM.
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Code:
           while (CLAEX.Fetch()!=0)
            {
                    //اکه فچ بره آخر و حلقه رو هم غیر فعال کنیم .ارروی نمیده و خط او
    ل چک میشه .اما اگه بره اخر حتی اونخطر اخر هم چک نمیشه.
                    CLAEX.Fetch();
                    CLAEX.AnalizeString();
                    CLAEX.Tokenizer();
                    CLAEX.machinLanguageConvertor();
                    CLAEX.MemoryDumper();
                   //CLAEX.Fetch();
            }
            CLAEX.ExecutionEngine();
    If you look at the code for CLAEX.Fetch(), you'll see that it modifies the state of the class. I didn't investigate in too much detail, but I think that perhaps you should only call Fetch once, i.e.
    Code:
           while (CLAEX.Fetch()!=0)
            {
                    //اکه فچ بره آخر و حلقه رو هم غیر فعال کنیم .ارروی نمیده و خط او
    ل چک میشه .اما اگه بره اخر حتی اونخطر اخر هم چک نمیشه.
                    //CLAEX.Fetch(); do not call Fetch() again
                    CLAEX.AnalizeString();
                    CLAEX.Tokenizer();
                    CLAEX.machinLanguageConvertor();
                    CLAEX.MemoryDumper();
                   //CLAEX.Fetch();
            }
            CLAEX.ExecutionEngine();
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    Quote Originally Posted by dwks View Post
    Code:
           while (CLAEX.Fetch()!=0)
            {
                    
                   //CLAEX.Fetch();
                    CLAEX.AnalizeString();
                    CLAEX.Tokenizer();
                    CLAEX.machinLanguageConvertor();
                    CLAEX.MemoryDumper();
                   //CLAEX.Fetch();
            }
            CLAEX.ExecutionEngine();
    If you look at the code for CLAEX.Fetch(), you'll see that it modifies the state of the class. I didn't investigate in too much detail, but I think that perhaps you should only call Fetch once, i.e.
    Code:
           while (CLAEX.Fetch()!=0)
            {
                   
                    //CLAEX.Fetch(); do not call Fetch() again
                    CLAEX.AnalizeString();
                    CLAEX.Tokenizer();
                    CLAEX.machinLanguageConvertor();
                    CLAEX.MemoryDumper();
                   //CLAEX.Fetch();
            }
            CLAEX.ExecutionEngine();
    tanx dear dwk, i commented that part too, but again at the end it crashes!(dont send error window appears,)
    ( by the way , why is it that after 3 or 4 times of compiling and running the program, at the fifth try, it doesnt even scan these commands (upon reaching REM num e.g, it crashes) and generates errors! is it because of the fault the program is suffering?, cause when i log off and on again , for 3 times again , its works fine, but if you do try more , it crashes more and more even before program reaches the end of the map!)

    anyway thanks so far dears.im waiting for your comments.
    Last edited by Masterx; 01-27-2009 at 07:40 PM.
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,687
    Well if it's a zip, I might download it. But I'm not interested enough to download and install whatever I need to unpack a rar file just to help you.
    Don't make it hard for people to help you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,820
    Who does not have rar/7z these days?
    On a school, or a workplace, I might believe you, but on a home computer?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    again im really thank you for your attention , while in a deep desperation and confusion ,i extremely thankyou for sharing your precious time with me for solving this problem .

    ive uploaded the zip file too, hope you help me find the problem.

    ive faced another error . ( i mean an error that kept happening before and after a while after some changes, it disappeared i thought . now it just poped up. and i found what was the cause.
    when i enter number 65 or 10 or 12 as the variables value in a declaration, the program crashes immediately by typing exit,(and thus executing the rest of the functions!)

    EDITED : using stringstream , the error is gone , now they are all right ! i used itoa() improperly and the samples below showed up! , but upon using string stream , they are gone .! thanks all

    for example :
    //declaring 1 digit number is harmless!! to the program, it process all of the strings, and at the end it crashes.

    ORG 10
    CLA
    RED num
    num: 5
    exit

    Runs fine. to the end , and processes all of the strings, but crashes at the end.
    ------------------

    ORG 10
    CLA
    RED num
    num: 65
    exit
    Generates Error! before reaching the end and process all of the strings it crashes
    --------------------------
    ORG 10
    CLA
    RED num
    num: 99
    exit
    conversion occured! and rest of the info. at the end program crashes.
    Runs fine again!
    )

    its really really confusing me, because i dont see any difference between 65 and 99 or 86 .
    99 and 86 are fine but 65 not!!
    you know what. i checked it . the program converts the number 65 to octal but after that there is an error ( it doesnt even show the conversion occured! message! as it does in 99 and 86s !) some time loging off an on will make it right!! and some time no!! just by chance i think!!
    Last edited by Masterx; 01-28-2009 at 12:31 PM.
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  9. #9
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    edited! double post
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  10. #10
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,652
    I can't even get this to compile under Linux due to itoa; around 310 lines of warnings though.

    Here's something, in SearchEngine.h:
    Code:
     else if( message != "no" )
    {
        //if it was octal . well do the routin .copy it to offset,convert it to binary
        char * oo;
        char * o;
        o = itoa(temp,oo,8);    //itoa(number,a buffer to hold the string,the base you want the number to be saved in buffer)
        offsetptr = o;//itoa(temp,ptr,8);    //itoa(number,a buffer to hold the string,the base you want the number to be saved in buffer)
        //cout<<"\nThis is in Search,"<<offsetptr;
    }
    ...
    return offsetptr;
    You need to allocate storage for the buffer passed to itoa.
    You're returning a pointer to a local variable.

  11. #11
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    Quote Originally Posted by rags_to_riches View Post
    I can't even get this to compile under Linux due to itoa; around 310 lines of warnings though.

    Here's something, in SearchEngine.h:
    Code:
     else if( message != "no" )
    {
        //if it was octal . well do the routin .copy it to offset,convert it to binary
        char * oo;
        char * o;
        o = itoa(temp,oo,8);    //itoa(number,a buffer to hold the string,the base you want the number to be saved in buffer)
        offsetptr = o;//itoa(temp,ptr,8);    //itoa(number,a buffer to hold the string,the base you want the number to be saved in buffer)
        //cout<<"\nThis is in Search,"<<offsetptr;
    }
    ...
    return offsetptr;
    You need to allocate storage for the buffer passed to itoa.
    You're returning a pointer to a local variable.
    im using gcc under windows, it should compile nder linux too!! and by the way for me it doesnt generate any warning concerning itoa() !! and most of the warnings are because of comaprison betwean size_t found and -1!

    after all , how to allocate that! i dont understand! what should i do ?
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You need to make sure that the variable oo that you pass to itoa represents some real memory - oo currently points at some random location, which is highly likely not a good place to store the string produced by itoa.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #13
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    how to do that!? im not familiare with char * string initialization! will
    int i;
    char * oo =& i ; ! work? !!
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  14. #14
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Masterx View Post
    how to do that!? im not familiare with char * string initialization! will
    int i;
    char * oo =& i ; ! work? !!
    In theory, that would work. I'd probably use char oo[13] instead [13 is long enough for a 32-bit integer].

    However, you return 'o', which is a pointer to the oo variable (yes, itoa() returns the string it got as buffer, which is oo), so you will still return a pointer to a local variable, which is bad. You either should pass a character array to the function, or call malloc() to get a permanent piece of memory (just make sure you free it later).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #15
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,652
    Quote Originally Posted by Masterx View Post
    how to do that!? im not familiare with char * string initialization! will
    int i;
    char * oo =& i ; ! work? !!
    You know, this code is full of char * (C-style strings) usage. Sorry, but if you don't know how to use them, you're destined to fail. This looks like a complicated project to undertake if you don't understand such a rudimentary part of C & C++ programming. If you're used to using the C++ string class and its relatives, then I would use those instead.

Page 1 of 4 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dev-C++: Problems with Breakpoint Debugging
    By Thileepan_Bala in forum C Programming
    Replies: 1
    Last Post: 01-17-2008, 09:48 AM
  2. Problem in debugging in Eclipse
    By Bargi in forum Linux Programming
    Replies: 1
    Last Post: 08-21-2007, 09:53 AM
  3. Debugging Dev C++
    By tuurb046 in forum Tech Board
    Replies: 10
    Last Post: 08-16-2007, 12:51 PM
  4. Debugging book recommendation
    By dagans in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 09-13-2005, 07:35 PM
  5. debugging directx apps
    By confuted in forum C++ Programming
    Replies: 1
    Last Post: 08-16-2003, 08:56 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21