Skip to content

Commit

Permalink
Add clang source based coverage option (#1790)
Browse files Browse the repository at this point in the history
  • Loading branch information
tklengyel authored May 1, 2024
1 parent fc91516 commit e2594a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ if cpp.compiles(code, name: '-fstrict-flex-arrays=2', args: ['-fstrict-flex-arra
add_project_arguments('-fstrict-flex-arrays=2', language: ['c', 'cpp'])
endif

coverage_link_args=[]
hardened_link_args=[]

# Declare additional debug flags
Expand Down Expand Up @@ -112,6 +113,13 @@ elif get_option('hardening')
config_h.set('HARDENING', 1)
endif

if get_option('coverage')
add_project_arguments('-fprofile-instr-generate', language: ['c', 'cpp'])
add_project_arguments('-fcoverage-mapping', language: ['c', 'cpp'])
coverage_link_args += '-fprofile-instr-generate'
coverage_link_args += '-fcoverage-mapping'
endif

if get_option('threadsafety')
config_h.set('ENABLE_THREADSAFETY', 1)
endif
Expand Down Expand Up @@ -148,7 +156,7 @@ executable('drakvuf',
dependencies : deps,
link_language : 'cpp',
link_with : [libdrakvuf, drakvuf_plugins, libinjector],
link_args : hardened_link_args,
link_args : [hardened_link_args, coverage_link_args],
install : true,
)

Expand All @@ -159,7 +167,7 @@ executable('injector',
dependencies : deps,
link_language : 'cpp',
link_with : [libdrakvuf, libinjector],
link_args : hardened_link_args,
link_args : [hardened_link_args, coverage_link_args],
install : true,
)

Expand All @@ -170,7 +178,7 @@ executable('proc_stat',
dependencies : deps,
link_language : 'cpp',
link_with : libdrakvuf,
link_args : hardened_link_args
link_args : [hardened_link_args, coverage_link_args]
)

if get_option('xtf')
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ option('release', type : 'boolean', value : false)
option('xtf', type : 'boolean', value : 'false')
option('repl', type : 'boolean', value : 'false')
option('threadsafety', type : 'boolean', value : 'false')
option('coverage', type : 'boolean', value : 'false')

option('plugin-syscalls', type : 'boolean', value : true)
option('plugin-poolmon', type : 'boolean', value : true)
Expand Down

0 comments on commit e2594a0

Please sign in to comment.