You can do one of two things:
1) start the agent with JPDA and debug by attaching Eclipse to a running agent. You turn on JPDA by uncommenting this line from rhq-agent-env.sh:
2) you can use the standalone plugin container - deploy your plugin in there and debug it via that way (again, attach Eclipse to it via JPDA)
Heiko wrote that - he has a demo from a few years ago: http://www.pilhuhn.de/hwr/misc/2009-03-20_2212.swf
And here is some more from his blog:
My recommendation is to extend my 'ComponentTest' class, which you can find for some of the plugins in the RHQ tree, like mysql or the database plugin. You can see some examples there.
It is sort of a plugin container lite, meaning it will create your components and you can interact with them, e.g. get measurements or availability.