Opened 6 years ago

Last modified 16 months ago

#10915 new defect

Tool to find unused functions in Tor

Reported by: nickm Owned by:
Priority: Medium Milestone: Tor: unspecified
Component: Core Tor/Tor Version:
Severity: Normal Keywords: tor-relay technical-debt tooling analysis
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

We should periodically check for dead functions in Tor, and remove them.

We should have a tool to find them for us.

We could use the cruddy approach I used to take, which I can no longer find the perl script that I used to have implement. I'll attach a cruddy implementation of that one.

We could use a tool like http://www.skynet.ie/~caolan/Packages/callcatcher.html , if that actually works, and turns out not to be stupid if I read about it for more than 60 seconds.

Other suggestions welcome, but please think of testing them before recommending them. :)

Child Tickets

Attachments (1)

find_orphaned_c.py (1.7 KB) - added by nickm 6 years ago.
Stupid broken tool to heuristically (stupidly, brokenly) look for unused functions

Download all attachments as: .zip

Change History (12)

Changed 6 years ago by nickm

Attachment: find_orphaned_c.py added

Stupid broken tool to heuristically (stupidly, brokenly) look for unused functions

comment:1 Changed 6 years ago by nickm

To use the above broken attachment, say "find_orphaned_c.py src/{common,or,tools}/*.[ch]. But watch out; it's highly dependent on how we format our C.

comment:2 Changed 6 years ago by nickm

Also, once we have a working tool, we should be smart about how we use it. Stripping out some things doesn't make sense.

comment:3 Changed 6 years ago by nickm

Milestone: Tor: 0.2.5.x-finalTor: 0.2.???

comment:4 Changed 4 years ago by cypherpunks

maybe of interest

Clang by example: Detecting unused functions
https://xaizek.github.io/2014-08-28/detecting-unused-functions/

comment:5 Changed 4 years ago by teor

Is there any reason that -Wunused-function doesn't do what we want?

comment:6 Changed 4 years ago by teor

Ah, apparently it's not as easy as that.
http://stackoverflow.com/a/4857905
explains that GCC compiler + linker will do it with the right arguments, but I wonder if it only works for externally declared functions if it's happening during linking.

comment:7 Changed 3 years ago by teor

Milestone: Tor: 0.2.???Tor: 0.3.???

Milestone renamed

comment:8 Changed 3 years ago by nickm

Keywords: tor-03-unspecified-201612 added
Milestone: Tor: 0.3.???Tor: unspecified

Finally admitting that 0.3.??? was a euphemism for Tor: unspecified all along.

comment:9 Changed 2 years ago by nickm

Keywords: tor-03-unspecified-201612 removed

Remove an old triaging keyword.

comment:10 Changed 2 years ago by nickm

Keywords: technical-debt tooling analysis added
Severity: Normal

comment:11 Changed 16 months ago by rl1987

Doesn't Coverity support this?

Note: See TracTickets for help on using tickets.