Skip to content
Tom Fletcher edited this page Mar 6, 2021 · 14 revisions

Introduction

Gscope is a software development tool used to browse C/C++ [and other] source languages.

Gscope was originally developed as GUI front end to the classic Unix application "cscope'. While portions of original cscope code remains part of gscope, cross-porting, bug fixes, performance enhancements and database format changes to the original ccsope code makes gscope a unique and independent fork of the original cscope open source project.

Features

Extremely easy to get started. Just type: gscope -R at the root of your source tree.

Highly optimized code. Very fast parsing and searching. Scales to huge data sets (Verified across 100K files, 20M lines)

Gscope provides all of the search functionality of classic cscope:

  • Search for

    • All References to a symbol
    • Global Definitions
    • Functions called by a function
    • Functions calling a function
    • Literal string Text matching
    • Regular Expression Text matching
    • A source filename
    • Files including a specified file
  • Fuzzy parser allows limited cross-referencing of several additional file types:

    • Make files
    • Some Linker command files
    • Yacc/Bison

In addition to core search functionality, Gscope provides these additional capabilities:

  • A GTK2 or GTK3 based GUI implementation
  • A graphical function (static) call browser
  • Interactive search history/recall/edit
  • Graceful interrupt/cancel of lengthy search operations.
  • Save and load search history (between sessions)
  • Save search results to file (Multiple formats: HTML, plain text and CSV)
  • "List all functions" command
  • Session specific, quick-pick, temporary configuration options.
  • "Sticky" application start-up configuration options.
  • Advanced source file search (including recursive directory search with filtering)
  • Enhanced include file search (include search path)
  • Highly Configurable, but carefully crafted defaults. The default configuration works for most users 'right out of the box'
  • Reliable and intelligent re-parsing cross reference data
  • 35% Faster source parsing than classic cscope with ~10% smaller cross reference data files.
    Performance is file I/O limited and is drastically improved when a large file cache [with lots of
    cache hits] is active.
  • Built in, syntax highlighting text viewer.
  • Expanded text editor compatibility (including SlickEdit integration).
  • Customizable Site-wide defaults

Why Use Gscope?

As a developer, you might ask: Can't I get the same results using grep? Or maybe you have a modern text editor and/or IDE that builds some of this information for you.

The answer boils down to 4 characteristics:

  1. Speed
  2. Simplicity
  3. Scope
  4. Forgiving

Speed - Application Performance
Gscope is a natively compiled (and optimized) C program that can parse and look-up data extremely quickly from very large source data sets. It can also handle insanely large[1] search results (hundreds of thousands of hits with tens of thousands of characters-per-source-line).

Simplicity of operation (and getting started)
The work-flow of the GUI is simple and intuitive, but where Gscope shines is how easy it is to get going. Most Editors and IDEs have fairly complex and stringent cross-reference configuration items that must be set up before any useful cross-referencing can occur. Sometimes re-generating a cross reference is either complex, or very time consuming. With Gscope, a novice user can be up and running in just a few seconds. From the Linux command prompt, the user simply issues the following two commands:

# cd <my-project-source-dir>
# gscope -R

To rebuild the database of an active Gscope session, simply select the menu item: Commands-->Rebuild Cross Reference

Gscope comes configured with a set of defaults that are applicable to most users, so initial setup time is nearly zero. Some users never touch the default configuration, but there are extensive configuration items available to modify the behavior and start-up configuration of Gscope if you feel the need to tweak.

Scope
Unlike some IDEs and Text editors, Gscope parses ALL of the source files in the filesystem(s) specified by the source search parameters, independent of the subset of files utilized by a specific product build. This is useful when many targets are built from various sub-sets of files in a multiple product source code repository and all variants need to be maintained. Both models (single-subset or all-files search) have their place. Gscope is an "all inclusive" alternative.

Forgiving
Gscope can parse and search code that does not currently compile. Some IDEs will not provide any symbolic cross-referencing unless the code compiles. Missing files and simple syntax or structural errors do not prevent Gscope from analyzing whatever it can parse. The fuzzy parser is very tolerant and makes the best of what it can process. Of course there are limitations. A code tree that is grossly (lexically) broken will not generate a lot of interesting cross reference data.

Notes

1: The utility of these very large search results can be somewhat dubious unless you are trying build a catalog. (see "Save Results As" command)