Skip to content

Bug Report: diagtool not found on Windows #4802

@TorCroft

Description

@TorCroft

Bug Report: diagtool not found on Windows

Summary

On Windows systems, CodeChecker fails to find the diagtool binary because it searches for diagtool instead of diagtool.exe.

CodeChecker version

  • Current repository state (commit: ce5ed25)

To Reproduce

Steps to reproduce the behaviour:

  1. Install CodeChecker on Windows
  2. Run analysis with ClangTidy analyzer
  3. The get_diagtool_bin() function in analyzer.py fails to locate diagtool.exe

Root Cause

In analyzer/codechecker_analyzer/analyzers/clangtidy/analyzer.py, line 153:

diagtool_bin = clang_tidy_bin.parent / 'diagtool'

The code hardcodes the binary name as diagtool without considering the .exe extension required on Windows platforms.

Expected Behaviour

The function should:

  • Look for diagtool.exe on Windows (sys.platform == 'win32')
  • Look for diagtool on Unix-like systems
  • Similarly handle versioned binaries like diagtool-14.exe

Affected File

analyzer/codechecker_analyzer/analyzers/clangtidy/analyzer.py - get_diagtool_bin() function

Fix

The fix adds platform-specific binary name handling:

# Find diagtool next to the clang binary.
diagtool_name = 'diagtool.exe' if sys.platform == 'win32' else 'diagtool'
diagtool_bin = clang_tidy_bin.parent / diagtool_name
if diagtool_bin.exists():
    return diagtool_bin

# Sometimes diagtool binary has a version number in its name: diagtool-14.
version = ClangTidy.get_binary_version()

if version:
    versioned_name = f'diagtool-{version.major}'
    if sys.platform == 'win32':
        versioned_name += '.exe'
    if diagtool_bin.with_name(versioned_name).exists():
        return diagtool_bin.with_name(versioned_name)

Desktop (please complete the following information)

  • OS: Windows 11 Pro
  • Platform: win32

Additional Context

  • This issue affects all Windows users using ClangTidy analyzer
  • The same pattern should be checked for any other binary lookups in the codebase
  • The sys.platform == 'win32' check is already used in other parts of the codebase for Windows-specific handling

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions