[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gdb not landing inside function

From: Joe Butler
Subject: Re: gdb not landing inside function
Date: Sat, 2 Apr 2005 23:26:44 +0100

The arguments passed to the main() function are stored in an array of chars
with a zero terminating char (char *).  Your Get() function is expecting a
reference to a std::string (and that's how it will interpret what you pass
to it).

The problem is that a std::string is not an array of chars (char *).  You
need to deal with it by copying the char * string into a std::string before
calling Get(), or changing Get() so that it expects a zero-terminated
string - it's your choice.

"Kelly Mandrake" <address@hidden> wrote in message
> I have a situation where I cannot enter into a function.  The code I am
> trying to debug comes from example code of a C++ socket library.  When
> I debug with gdb tutorials on the net they work fine, i can step into
> methods and functions, but with this code for some reason it will not
> work.
> Instead when I get to the if condition (!Get(argv[i])) and issue step,
> it jumps to basicstring.h:491 from this point it does not mater weather
> i issue next, step or continue, I cannot get into the Get function so
> that I can debug it
> #include <HttpGetSocket.h>
> #include <HttpsGetSocket.h>
> #include <SocketHandler.h>
> #include <Parse.h>
> bool Get(const std::string& url_in)
> {
>     // This is where i want to go
> }
> int main(int argc,char *argv[])
> {
> for (int i = 1; i < argc; i++)
> {
> if (!Get(argv[i]))
> {
> printf("Failed: %s\n",argv[i]);
> }
> }
> }
> The breakpoint is set on the for loop, I issued next untill I reach the
> if statment, at wich point I issue step and land inside basickstring.h
> instead of Get
> Can somebody give me some guidence, would be apreciated.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]