As I’ve started to develop mod_guanxi as an Apache module version of a Guanxi Guard, I needed a way to debug it running inside Apache. I eventually gave up trying to use Eclipse and CDT and gave NetBeans a go instead.
- Make sure your Makefile can produce a debug build. I just added -g to CXXFLAGS and ran configure to get a debug specific Makefile
- After you build and use apxs to install the module, the code will be loaded by Apache so you will be able to step through it in the IDE
- Right click on the project in NetBeans and choose Properties
- Under Build/Make/Build Result, point it to the httpd executable
- Run Apache in single process mode: httpd -X
- In NetBeans, choose Debug -> Attach Debugger. In the filter, type httpd and you’ll see the single Apache process. Click on it and hit OK
That’s it. When you open the site in a browser, NetBeans will kick in and you can step through the module code.
Whenever I tried attaching to the httpd process in Eclipse the browser would just hang. Then I remembered something about gdb and automatically breaking on main(). Sure enough the apache thread was suspended in the debugger on child_main. Resuming the thread in the debugger sorted that. I can now use Eclipse to code/debug the module which is just as well really as NetBeans on the Mac is very slow and clunky but for some reason, the Eclipse attach to application debug type doesn’t let you not break at main()
A simple digest of the Cocoa Memory Management Rules.
Using alloc/new/copy means the object you’ve just created has a retainCount of 1 and you must release it, either as soon as you’re finished with it:
Cake *cake = [[Cake alloc] init];
[cake release]; (more...)
So I’ve recently upgraded to Snow Leopard, which blew away my Mysql installation as it destroys anything in /usr/local, which is where the installer puts it. I normally compile most apps and bung them in ~/apps, which means they are left alone by OS X upgraders but for simplicity’s sake I let the Mysql installer put it in /usr/local/mysql. So I upgraded to x86_64 Mysql which broke the installed gem. So I recompiled it and it complained ruby was the wrong architecture. So I recompiled ruby, rubygems and reinstalled some other gems and finally got mysql working again by uninstalling a bum mysql gem after I’d installed from source. At last I could run Gitorious on my local machine but alas no! Mongrel doesn’t work with ruby 1.9.1 it seems. Sigh.
I’m wondering just what Ruby can do for me. OK, I won a prize using it, not having used it much before, so that was a good sign but ever since, the more complex the application, the more I spend configuring, googling and compiling and the less I spend coding. For every line of Ruby code I write, there seem to be 10 lines of shell commands to enter, 10 web sites to google and 10 hours of working round ruby version incompatibilities. I had a stable Ruby setup until I went to Snow Leopard. Now I’m back to square one of seething mess.
Standing back from all this, one thing springs to mind. DLL Hell. I left those days behind years ago. Seems like they’re back.
I’ve added a sidebar widget that lets you ask me a question via my Formspring page. Hopefully I can waffle on about system integration, Single Sign On, SAML, Shibboleth, Java, PHP, C/C++, Objective-C, blah blah blah…
I’ve also been working on a new Brane using Drupal as I have a tutorial on XML encryption/decryption in the pipeline so watch this space!