Skip to content

Instantly share code, notes, and snippets.

@mominul
Last active October 2, 2025 19:56
Show Gist options
  • Select an option

  • Save mominul/74354837340a64ac62ee6bfa109b0286 to your computer and use it in GitHub Desktop.

Select an option

Save mominul/74354837340a64ac62ee6bfa109b0286 to your computer and use it in GitHub Desktop.
debug.yml
# sg scan -U --rule .\debug.yml
id: insert-debug
language: c++
rule:
kind: compound_statement
pattern: $A
inside:
kind: function_definition
transform:
DEBUG:
# replace:
# by: |
# {
# OutputDebugStringA(__FUNCSIG__);
# replace: '\{'
# source: $A
substring:
source: $A
startChar: 1
endChar: -1
fix: |
{
OutputDebugStringA(__FUNCSIG__);
$DEBUG
}
id: insert-debug
language: rust
rule:
kind: block
pattern: $A
inside:
kind: function_item
transform:
DEBUG:
substring:
source: $A
startChar: 1
endChar: -1
fix: |
{
eprintln!("DEBUG: {}", std::any::type_name::<fn()>());
$DEBUG
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment