Question

When I use GDB to debug OpenGL programs, there is a misleading behavior of GDB.

I get a address from glMapBufferARB, the address in GDB shows

$35 = (GLubyte *) 0xb74bb000 <Address 0xb74bb000 out of bounds>

And I can't print its content.

However, I can access its content in my program.

Is the address returned from glMapBufferARB different from ordinary memory address? Why GDB can't access it?

Was it helpful?

Solution

Is the address returned from glMapBufferARB different from ordinary memory address?

It likely is special -- the OpenGL user-space library and a kernel driver probably conspire to arrange a special mapping, which only they understand.

Why GDB can't access it?

GDB uses ptrace(2) to read inferior (being debugged) process memory. It is very likely that the kernel device driver that actually talks to your graphics card doesn't support ptrace, and GDB's attempt to read that memory fails. That is possibly a bug in the device driver, but if you are using a closed-source driver (Nvidia?), there is likely nothing you could do about it.

OTHER TIPS

Is the address returned from glMapBufferARB different from ordinary memory address?

Yes it may be a DMA buffer or memory on the GPU mapped into your process address space. Hence the memory lives outside your process allocation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top