Supposing I use the glPushName() . . . glPopName() functions, how would I be able to retrieve the current name pushed? I need it for debugging purposes.

Thank you.

Haven’t checked the spec, but from the man pages there does not seem to be a glGet*() function for the element on top of the name stack like there is for the matrix stacks.
You could use your own wrapper functions myGlPushName(), myGlPopName() that in addition to calling the regular OpenGL functions also push the name on a stack that you keep. For release builds you could omit your own stack and only call the GL functions.

Not a bad idea. Thanks. That got me past a bug.