LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-19-2010, 07:51 AM   #1
915086731
Member
 
Registered: Apr 2010
Posts: 120
Blog Entries: 5

Rep: Reputation: 2
Wink Gdb did not step into function when "step" typed!!!


I typed "step", but gdb did not step into the specified function.

the code is:
Code:
#include "file.h"
#include "WordAnalyze.h"
#include "OperatorPriorAnalyze.h"
#include <cstring>
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    unsigned int size;
    char *mem;
    char* line;
    char tc[100];
    file f1;
    OperatorPriorAnalyze operator_analyze;
    WordAnalyze w1;
    size = f1.readfile("./test.txt", &mem );
    w1.setSource(mem);
    w1.setSize(size);
    while( !w1.atEnd() ){
	unsigned int i = w1.getLineSize();
	line = w1.getLine();                 //after "step" typed, gdb can step into getLine() function 
	operator_analyze.setSize(i);         //but gdb can not step into setSize(i) function 
	operator_analyze.setSource(line);    //gdb can't step into
	unsigned int k = 0;
	while(k<i){
	    tc[k] = line[k];
	    k++;
	}
	tc[k] = '\0';
	cout<< tc;
        operator_analyze.restart();
	if(operator_analyze.Judge() == 0 )
	    cout<< "Right!"  << endl;
	else
	    cout<< "Wrong!  " << operator_analyze.getError() << endl;
	delete line;
    }
    return 0;
}
It seems that gdb can't step into the function of "operator_analyze"class.
Can anyone explain to me?
Thanks !

Last edited by 915086731; 06-19-2010 at 08:26 AM.
 
Old 06-19-2010, 09:14 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Have you compiled the OperatorPriorAnalyze source with debugging information?
What do you mean by it "doesn't step into"?
What does the function do?

Remember an inlined function might not appear as you expect.
 
1 members found this post helpful.
Old 06-20-2010, 01:49 AM   #3
915086731
Member
 
Registered: Apr 2010
Posts: 120
Blog Entries: 5

Original Poster
Rep: Reputation: 2
Thanks for your help. I am Chinese and my English is terrible!

All my source file were compiled with "-g" options.
When gdb stop at
Code:
operator_analyze.setSize(i);
, then I input "step", but gdb didn't come into the inner code of function
Code:
operator_analyze.setSize(i);
, gdb just executed the function like "next" .
If I run "stepi" many times, gdb can come into the body of
Code:
operator_analyze.setSize(i);
.

Does me explain clearly?
 
Old 06-20-2010, 02:13 AM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
You English is fine.

Are any of these functions inline functions? In such a case the compiler will make a code substitution and so all of the inlined code will <b>be</b> on that one line, hence a step will just take you over.

Have you tried putting a breakpoint within the function you wanted to step into?

Do you have any compiler optimisation turned on?
 
1 members found this post helpful.
Old 06-23-2010, 09:44 AM   #5
915086731
Member
 
Registered: Apr 2010
Posts: 120
Blog Entries: 5

Original Poster
Rep: Reputation: 2
Thanks .
There is something wrong in my makefile. And the OperatorPriorAnalyz.cpp was not compiled with '-g' option. Sorry.
 
  


Reply

Tags
c++, debug, gdb, step


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What are the easy to follow step-by-step instructions for loading "WICD" in Slackware Twilight_Bandit Linux - Software 2 06-22-2009 05:16 AM
unable to step through function in shared object library using gdb markhod Programming 2 01-03-2009 02:00 AM
LXer: O'reilly Releases "Learning PHP & MySQL": A Step-by-Step Guide to ... LXer Syndicated Linux News 0 06-21-2006 06:33 AM
Tell my how to set up "mysql" step by step, please kornerr Linux - General 7 05-16-2005 12:00 PM
gdb won't single step thru the function frankie_DJ Programming 2 10-06-2004 05:50 AM


All times are GMT -5. The time now is 01:34 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration