[SOLVED]GDB Panopticum - strange experience when debugging

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

[SOLVED]GDB Panopticum - strange experience when debugging

Post by paul424 »

Ogre Version: :1 12 13:
Operating System: :OpenSuse Linux:
Render System: :OpenGL3+:

HERE I WILL BE REPORTING STRANGE SITUATIONS WHEN DEBUGGING OGRE WITH GDB :

Hello I have such several short methods of dealing with GPU programs I cannot properly debug

Code: Select all

    bool Pass::hasGpuProgram(GpuProgramType programType) const {
        return getProgramUsage(programType) != NULL;
    }
    const GpuProgramPtr& Pass::getGpuProgram(GpuProgramType programType) const
	{
        OGRE_LOCK_MUTEX(mGpuProgramChangeMutex);
        OgreAssert(mProgramUsage[programType], "check whether program is available using hasGpuProgram()");
        return mProgramUsage[programType]->getProgram();
	}
    //-----------------------------------------------------------------------
    const GpuProgramPtr& Pass::getVertexProgram(void) const
    {
        return getGpuProgram(GPT_VERTEX_PROGRAM);
    }
    //-----------------------------------------------------------------------
    const String& Pass::getGpuProgramName(GpuProgramType type) const
    {
        OGRE_LOCK_MUTEX(mGpuProgramChangeMutex);

    const std::unique_ptr<GpuProgramUsage>& programUsage = getProgramUsage(type);
    if (!programUsage)
        return BLANKSTRING;
    else
        return programUsage->getProgramName();
}
//-----------------------------------------------------------------------
GpuProgramParametersSharedPtr Pass::getFragmentProgramParameters(void) const
{
    return getGpuProgramParameters(GPT_FRAGMENT_PROGRAM);
}
//-----------------------------------------------------------------------
const GpuProgramPtr& Pass::getFragmentProgram(void) const
{
    return getGpuProgram(GPT_FRAGMENT_PROGRAM);
}

I pinpointed my problem to that :
Some methods report properly the attached fragment program:

Code: Select all

 (gdb) p pass->getGpuProgram(GPT_FRAGMENT_PROGRAM)->getName()
 $2 = "myDCW1110TileFragmentShader"

Why the other way around the fragment programs are non-existent :

Code: Select all

 (gdb) p pass->mProgramUsage

Code: Select all

 $3 = {std::unique_ptr<Ogre::GpuProgramUsage> =
{get() = {<No data fields>}}, std::unique_ptr<Ogre::GpuProgramUsage> =
{get() = {<No data fields>}}, std::unique_ptr<Ogre::GpuProgramUsage> =
{get() = {<No data fields>}}, std::unique_ptr<Ogre::GpuProgramUsage> =
{get() = {<No data fields>}}, std::unique_ptr<Ogre::GpuProgramUsage> =
{get() = {<No data fields>}}, std::unique_ptr<Ogre::GpuProgramUsage> =
{get() = {<No data fields>}}}

And of course mProgramUsage is an array of type :

Code: Select all

 (gdb) ptype pass->mProgramUsage
type = class std::unique_ptr<Ogre::GpuProgramUsage> [with _Tp = Ogre::GpuProgramUsage, _Dp = std::default_delete<Ogre::GpuProgramUsage>] {
  private:
    std::__uniq_ptr_data<_Tp, _Dp, true, true> _M_t;

  public:
    unique_ptr(std::unique_ptr<Ogre::GpuProgramUsage> &&);
    unique_ptr(const std::unique_ptr<Ogre::GpuProgramUsage> &);
    ~unique_ptr();
    std::unique_ptr<Ogre::GpuProgramUsage> & operator=(std::unique_ptr<Ogre::GpuProgramUsage> &&);
    std::unique_ptr<Ogre::GpuProgramUsage> & operator=(std::nullptr_t);
    std::unique_ptr<Ogre::GpuProgramUsage> & operator=(const std::unique_ptr<Ogre::GpuProgramUsage> &);
    std::__add_lvalue_reference_helper<_Tp, true>::type operator*(void) const;
    pointer operator->(void) const;
    pointer get(void) const;
    _Dp & get_deleter(void);
    const _Dp & get_deleter(void) const;
    operator bool(void) const;
    pointer release(void);
    void reset(pointer);
    void swap(std::unique_ptr<Ogre::GpuProgramUsage> &);

typedef std::__uniq_ptr_impl<_Tp, _Dp>::pointer pointer;
typedef _Dp deleter_type;
} [6]

The problem is : why the mProgramUsage is empty ?
I suspect OGRE_LOCK_MUTEX(mGpuProgramChangeMutex); Is this right ?

Code: Select all

Ogre.log (optional)
Last edited by paul424 on Sun Jun 19, 2022 7:57 pm, edited 1 time in total.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: GDB Panopticum - strange experience when debugging

Post by dark_sylinc »

<No data fields> isn't the same as nullptr. It means GDB couldn't read the contents.

Assuming this is a full debug version (otherwise all bets are off) GDB is far from perfect when reading variables.

There are many things that come into play: stdlib version used, C++ version used (98, 03, 11, 17, etc; if there's multiple libs with different versions mixed up), version of pretty printers, GDB config settings, etc.

You could call

Code: Select all

p pass->mProgramUsage[2].get()
p pass->mProgramUsage[2]
p pass->mProgramUsage[Ogre::GPT_FRAGMENT_PROGRAM]
p pass->mProgramUsage[Ogre::GPT_FRAGMENT_PROGRAM].get()

And perhaps only one of them works.

User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

Re: GDB Panopticum - strange experience when debugging

Post by paul424 »

Thanks for a quick reply !
However none of those functions works, all I get is :

Code: Select all

 (gdb) p pass->mProgramUsage[2].get()
$1 = {<No data fields>}
(gdb) p pass->mProgramUsage[2]
$2 = std::unique_ptr<Ogre::GpuProgramUsage> = {get() = {<No data fields>}}
(gdb) p pass->mProgramUsage[Ogre::GPT_FRAGMENT_PROGRAM]
$3 = std::unique_ptr<Ogre::GpuProgramUsage> = {get() = {<No data fields>}}
(gdb) p pass->mProgramUsage[Ogre::GPT_FRAGMENT_PROGRAM].get()
$4 = {<No data fields>}
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

Re: GDB Panopticum - strange experience when debugging

Post by paul424 »

I compile Ogre with only two g++ flags : -g -O0 . Any tips/hits what flags else there should be ?

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: GDB Panopticum - strange experience when debugging

Post by dark_sylinc »

Try 1, instead of 2. 2 is geometry shader.

Also try

Code: Select all

p *pass->mProgramUsage[1].get()
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

Re: GDB Panopticum - strange experience when debugging

Post by paul424 »

yeah, I agree that was my fault, because I used the outdated pretty printers, I advice anyone to stick to the newest ones which can be found out here:

https://gcc.gnu.org/git/?p=gcc.git;a=tr ... v6;hb=HEAD

Post Reply