Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb can step into some opencv function,but can not step into some other opencv functions

I want to debug Opencv with gdb under opensuse 13.1:

I can step into some function like imshow, waitKey, but I can not step into others like imread, namedWindow, it shows:

29          image = cv::imread(name);
(gdb) s
std::allocator<char>::allocator (this=0x7fffffffdc7f)
    at /usr/src/debug/gcc-4.8.1-20130909/obj-x86_64-suse-linux/x86_64-suse-linux/libstdc++-v3/include/bits/allocator.h:113
113           allocator() throw() { }

here are my steps:

test4.cpp:

#include <stdio.h>
#include <opencv2/opencv.hpp>

using namespace cv;

int main(int argc, char** argv )
{

Mat image;
image = imread( "LinuxLogo.jpg", 1 );

if ( !image.data )
{
    printf("No image data \n");
    return -1;
}
namedWindow("Display Image", CV_WINDOW_AUTOSIZE );
imshow("Display Image", image);

waitKey(0);

return 0;
}

my makefile:

OpencvDebugLibDir=/home/ry/lib
CFLAGS=-g -I$(OpencvDebugLibDir)/include/opencv -I$(OpencvDebugLibDir)
LIBS=$(OpencvDebugLibDir)/lib

test4:test4.cpp
    g++ $(CFLAGS) -o $@ $<  -L$(LIBS) -lopencv_highgui -lopencv_core -Wl,-rpath=/home/ry/lib/lib

run gdb:

gdb test4 -d /home/ry/learn/opencv/install/OpenCV/opencv-2.4.9/modules/core/src -d /home/ry/learn/opencv/install/OpenCV/opencv-2.4.9/modules/highgui/src
like image 803
madcc Avatar asked Jan 20 '26 04:01

madcc


1 Answers

You should finish and step again in gdb prompt.

This is because when you are first stepping into, you step into std::string constructor code (it is the first parameter of imread). This is not what you want, so just finish executing this current frame an step into again. Note that this process may occur multiple times on the same line of code depending on arguments of the function and how you pass them.

like image 119
ks1322 Avatar answered Jan 23 '26 21:01

ks1322