Incremental Source Code Analysis via Shared Library Interception

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing static analysis systems face challenges in extracting all source code compiled by a build system, as mere read access to source code files is insufficient, and they must analyze, replicate, or emulate the build system's behavior to obtain complete source code.

Innovation Solution

A static analysis system intercepts compiler calls using a shared library without modifying build utilities or compilers, allowing it to extract exactly the source code compiled by the build system, generating a full set of analysis artifacts from incremental builds, thus avoiding the need for a full rebuild.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Loss of information

If a static analysis system uses read access to source code files, then it can access source code, but it cannot extract all source code that is built by the build system

Engineering Contradiction:
Improvecompleteness of extracted source codeVSAvoidsimplicity of source code access
Core Design Contradiction:
Loss of informationVSEase of operation

Solution Approach 1:

The patent introduces a shared library as an intermediary component between the build system and the static analysis system. This shared library intercepts compiler calls and provides the static analysis system with access to the complete set of source code files that are actually compiled, including those generated by preprocessors and copied by build utilities. This resolves the contradiction by maintaining simple read access while ensuring completeness of extracted source code through the intermediary shared library.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Loss of information

If a static analysis system analyzes, replicates, or emulates build system behavior to obtain complete source code, then it can extract all source code, but it increases system complexity

Engineering Contradiction:
Improvecompleteness of extracted source codeVSAvoidcomplexity of static analysis system
Core Design Contradiction:
Loss of informationVSDevice complexity

Solution Approach 1:

Instead of requiring the static analysis system to analyze, replicate, or emulate complex build system behavior, the patent introduces a shared library intermediary that directly provides access to compiled source code files. This intermediary approach maintains completeness of source code extraction while significantly reducing the complexity of the static analysis system, as it只需 intercept compiler calls rather than replicate entire build processes.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent extracts the functionality needed for source code extraction from the complex build system and places it in a separate shared library. This extraction allows the static analysis system to obtain complete source code without needing to understand or replicate the complex build system behavior, thereby reducing system complexity while maintaining completeness.

Inventive Principle:
Principle #2Taking out (Extraction)

3Loss of information

If a static analysis system modifies build utilities or compilers to intercept compiler calls, then it can extract source code, but it requires modifying the build environment

Engineering Contradiction:
Improvecompleteness of extracted source codeVSAvoidease of deployment
Core Design Contradiction:
Loss of informationVSEase of manufacture

Solution Approach 1:

The patent uses a shared library as an intermediary that can be loaded without modifying the build utilities or compilers themselves. This approach maintains ease of deployment because the shared library can be introduced into the build environment without requiring modifications to existing build tools or compiler installations, while still enabling complete source code extraction through interception of compiler calls.

Inventive Principle:
Principle #24Intermediary (Mediator)

4Loss of information

If a static analysis system performs a full rebuild to generate analysis artifacts, then it obtains complete analysis data, but it wastes time when only a small number of source code files have changed

Engineering Contradiction:
Improvecompleteness of analysis artifactsVSAvoidbuild time
Core Design Contradiction:
Loss of informationVSLoss of time

Solution Approach 1:

The patent implements preliminary action by having the shared library intercept compiler calls and identify which source code files are actually compiled during incremental builds. This preliminary identification allows the static analysis system to generate complete analysis artifacts based on the intercepted information without performing a full rebuild, thereby saving time when only a small number of source code files have changed while maintaining completeness of analysis data.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS9378013B2Incremental source code analysis
Publication Date: 2016.06.28 MICROSOFT TECHNOLOGY LICENSING LLC
  • US9378013B2 patent drawing
  • US9378013B2 patent drawing
  • US9378013B2 patent drawing

AI summary

Methods, systems, and apparatus, including computer programs encoded on computer storage media, for generating a full set of analysis artifacts after incremental analysis of a source code base. One of the methods includes receiving a first full set of analysis artifacts and an incremental set of analysis artifacts for a project. An initial keep graph that is initially equivalent to the full build graph is generated. Any source code file or analysis artifact nodes that also occur in the incremental build graph are removed from the keep graph. Analysis artifacts for source code files in the full build graph that do not occur in the keep graph are deleted from the first full set of analysis artifacts. The analysis artifacts represented by nodes in the incremental build graph are copied into the first full set of analysis artifacts to generate a second full set of analysis artifacts for the project.