Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you find a particular piece of functionality in a large codebase? [closed]

I was fascinated by the "press Tab to search site" feature in chromium, so naturally I wanted to see how exactly it was implemented in code.

A little background for anybody who aren't familiar with this. After navigating to some site, say wikipedia, and doing a search, chromium remembers the name of the query variable and will let you press tab and search the site directly from the address bar. Neat!

Problem is the codebase for chromium is huge and I've had no luck in finding the method/function that handles this.

How do you approach a large codebase when you are looking for the implementation of a particular piece of functionality? Any tricks for narrowing it down? Preferably it should not require building the software with debug symbols and following the flow through the program.

like image 594
hanDerPeder Avatar asked Dec 14 '10 02:12

hanDerPeder


1 Answers

There is no one size fits all approach to this sort of problem. But for this one I would try these:

  • If there are any unique messages associated with the operation, grep all the source files for that string. A common pitfall of this technique is that messages might be assembled from pieces within the application, so it is often helpful to grep for a unique short phrase—or even a single word—to identify the source of the message. Once the text is found, then finding what references it often requires more text searches.

  • Trace execution from an easy-to-find point, like the command processing and dispatch loop. I'd look for a Tab key case and follow where it leads.

  • Look at source code directory and filenames for hints. Software is often constructed rationally, with good engineers dividing and conquering in a sensible way.

like image 81
wallyk Avatar answered Oct 12 '22 22:10

wallyk