Re: GDB Hopelessly broken (CentOS 5.2, debugging Apache QPid)

Paul Pluzhnikov
2009-04-18T05:19:12Z

On Fri, Apr 17, 2009 at 8:33 PM, Joshua Kramer <josh@globalherald.net> wrote:
> Hello Everyone,
>
> I'm having some really bizarre problems debugging Apache Qpid under CentOS
> 5.2, and I'm wondering if anyone can shed some light on this.  The
> application is compiled with -ggdb and no optimization (the -O2 specified in
> the makefile was removed).
>
> GDB (as supplied by the OS) is exhibiting odd behavior.  First, I keep
> getting the error about the source files being newer than the executable,
> even though:
>
> 1. I have manually deleted all object files and executables, then ran make,
> and
> 2. I verified that the executable is 30 minutes newer than any source file.
>
> Next, it appears that some code does not get compiled.  If I set a
> breakpoint on line 335 of a certain file, it does not stop until line 339.
>  Also, some variables do not get declared.  In the code example shown below,
> the seContext variable is never declared - that is, if I set the breakpoint
> on lines directly after I assign something to that variable, when gdb stops
> and I enter the command 'print seContext', gdb replies that there is no
> seContext in this scope.
>
> Are these things a result of unseen compiler optimizations?  Any help is
> greatly appreciated.

The most likely cause is a "pilot error".

Are you debugging the binary you just rebuilt?
How do you invoke GDB?

All the symptoms you've listed are consistent with you debugging
some *other* optimized binary.

> Thanks!
> -Joshua Kramer
>
> (gdb) list
> /home/josh/dev/qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp:325
> 320
> 321     void SessionAdapter::QueueHandlerImpl::declare(const string& name,
> const string& alternateExchange,
> 322                                                    bool passive, bool
> durable, bool exclusive,
> 323                                                    bool autoDelete,
> const qpid::framing::FieldTable& arguments)
> 324     {
> 325         AclModule* acl = getBroker().getAcl();
> 326        327         std::string seContext;
> 328         //if (arguments.isSet("secontext"))
> 329         {
>
> (gdb) list
> /home/josh/dev/qpid/trunk/qpid/cpp/src/qpid/broker/SessionAdapter.cpp:343
> 338             params.insert(make_pair(acl::PROP_EXCLUSIVE,
> std::string(exclusive ? "true" : "false")));
> 339             params.insert(make_pair(acl::PROP_AUTODELETE,
> std::string(autoDelete ? "true" : "false")));
> 340            341             // JPK: Create some parameters from the
> arguments.
> 342            343             //if (arguments.isSet("secontext"))
> 344                 {
> 345                     seContext = arguments.getAsString("secontext");
> 346                     params.insert(make_pair(acl::PROP_SECONTEXT,
> seContext));
> 347                 }
> (gdb)
>
>

--
Paul Pluzhnikov