Christian Scheb has posted about an interesting idea in this article on his site – creating "tombstones" in your application to help you determine what code in your application is "dead".
Earlier this year I took over that project at my new company. […] The repository was cluttered by many files, that could assumed to be dead code. Unfortunately, you never know. […] The mission was clear: Cleaning up the project, without breaking things.
[…] I searched the web and came across that interesting concept of tombstones. If you haven’t heard of tombstones yet, I highly recommend this article and watching the video of David Schnepper’s ignite talk. A tombstone is basically an executable marker in your code (in the PHP world: a function call), which is placed in fragments of code, that you’ve assumed to be dead. Then, everything is deployed to production and, when a tombstone is invoked, it writes some data to a log. After a while, the logs will enable you to identify dead and undead code (called “Vampires”) in your project.
Not finding a good tool to help with this in an existing codebase, he created a library that makes it simpler to both mark the "tombstones" in your code and another to analyze the results. He includes an example of what the report might look like, showing both the used and unused bits of code where the tombstone code was placed.