1#
2# Copyright 2017, Data61
3# Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4# ABN 41 687 119 230.
5#
6# This software may be distributed and modified according to the terms of
7# the BSD 2-Clause license. Note that NO WARRANTY is provided.
8# See "LICENSE_BSD2.txt" for details.
9#
10# @TAG(DATA61_BSD)
11#
12
13cmake_minimum_required(VERSION 3.7.2)
14
15project(libsel4debug C ASM)
16
17set(configure_string "")
18
19config_string(
20    LibSel4DebugAllocBufferEntries
21    LIBSEL4DEBUG_ALLOC_BUFFER_ENTRIES
22    "Pointer tracking buffer entries \
23    Size of buffer to use for tracking memory allocations within \
24    instrumentation. This setting has no effect if you are not using the \
25    allocation instrumentation. Setting this value to 0 disables pointer \
26    tracking."
27    DEFAULT
28    0
29    UNQUOTE
30)
31
32config_choice(
33    LibSel4DebugFunctionInstrumentation
34    LIB_SEL4_DEBUG_FUNCTION_INSTRUMENTAITON
35    "Function instrumentation to apply to function calls. This setting will only have \
36    an effect when your CFLAGS include -finstrument-functions, in which \
37    case __cyg_profile_func_enter will be called on every function entry \
38    and __cyg_profile_func_exit will be called on every function exit. The \
39    value of this setting determines the implementation of \
40    __cyg_profile_func_enter and __cyg_profile_func_exit supplied by this \
41    library. Regardless of the option you select, you can always override \
42    the implementation by providing your own in your application. \
43    none -> \
44        No implementation of __cyg_profile_func_enter and \
45        __cyg_profile_func_exit are provided. \
46    printf -> \
47        Print entry and exit of every function call. This option is useful for \
48        a very coarse and noisy description of what your code is doing. \
49    backtrace -> \
50        Track function calls for the purposes of a backtrace. You will need to \
51        enable this option if you want to retrieve programmatic backtraces."
52    "none;LibSel4DebugFunctionInstrumentationNone;LIBSEL4DEBUG_FUNCTION_INSTRUMENTATION_NONE"
53    "printf;LibSel4DebugFunctionInstrumentationPrintf;LIBSEL4DEBUG_FUNCTION_INSTRUMENTATION_TRACE"
54    "backtrace;LibSel4DebugFunctionInstrumentationBacktrace;LIBSEL4DEBUG_FUNCTION_INSTRUMENTATION_BACKTRACE"
55)
56mark_as_advanced(LibSel4DebugAllocBufferEntries LibSel4DebugFunctionInstrumentation)
57add_config_library(sel4debug "${configure_string}")
58
59file(
60    GLOB
61        deps
62        src/*.c
63        src/sel4_arch/${KernelSel4Arch}/*.c
64        src/plat/${KernelPlatform}/*.c
65        src/sel4_arch/${KernelSel4Arch}/*.S
66)
67
68list(SORT deps)
69
70add_library(sel4debug STATIC EXCLUDE_FROM_ALL ${deps})
71target_include_directories(
72    sel4debug
73    PUBLIC include "arch_include/${KernelArch}" sel4_arch_include/${KernelSel4Arch}
74)
75target_link_libraries(sel4debug PUBLIC muslc sel4 utils PRIVATE sel4debug_Config sel4_autoconf)
76