• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 14630481637

23 Apr 2025 07:04PM UTC coverage: 72.178% (-0.002%) from 72.18%
14630481637

push

github

DaanDeMeyer
mkosi: Run clangd within the tools tree instead of the build container

Running within the build sandbox has a number of disadvantages:
- We have a separate clangd cache for each distribution/release combo
- It requires to build the full image before clangd can be used
- It breaks every time the image becomes out of date and requires a
  rebuild
- We can't look at system headers as we don't have the knowledge to map
  them from inside the build sandbox to the corresponding path on the host

Instead, let's have mkosi.clangd run clangd within the tools tree. We
already require building systemd for both the host and the target anyway,
and all the dependencies to build systemd are installed in the tools tree
already for that, as well as clangd since it's installed together with the
other clang tooling we install in the tools tree. Unlike the previous approach,
this approach only requires the mkosi tools tree to be built upfront, which has
a much higher chance of not invalidating its cache. We can also trivially map
system header lookups from within the sandbox to the path within mkosi.tools
on the host so that starts working as well.

297054 of 411557 relevant lines covered (72.18%)

686269.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.41
/src/core/manager-dump.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include "build.h"
4
#include "fd-util.h"
5
#include "fileio.h"
6
#include "hashmap.h"
7
#include "manager.h"
8
#include "manager-dump.h"
9
#include "memstream-util.h"
10
#include "unit-serialize.h"
11
#include "version.h"
12

13
void manager_dump_jobs(Manager *s, FILE *f, char **patterns, const char *prefix) {
20✔
14
        Job *j;
20✔
15

16
        assert(s);
20✔
17
        assert(f);
20✔
18

19
        HASHMAP_FOREACH(j, s->jobs) {
90✔
20

21
                if (!strv_fnmatch_or_empty(patterns, j->unit->id, FNM_NOESCAPE))
70✔
22
                        continue;
10✔
23

24
                job_dump(j, f, prefix);
60✔
25
        }
26
}
20✔
27

28
int manager_get_dump_jobs_string(Manager *m, char **patterns, const char *prefix, char **ret) {
×
29
        _cleanup_(memstream_done) MemStream ms = {};
×
30
        FILE *f;
×
31

32
        assert(m);
×
33
        assert(ret);
×
34

35
        f = memstream_init(&ms);
×
36
        if (!f)
×
37
                return -errno;
×
38

39
        manager_dump_jobs(m, f, patterns, prefix);
×
40

41
        return memstream_finalize(&ms, ret, NULL);
×
42
}
43

44
void manager_dump_units(Manager *s, FILE *f, char **patterns, const char *prefix) {
16✔
45
        Unit *u;
16✔
46
        const char *t;
16✔
47

48
        assert(s);
16✔
49
        assert(f);
16✔
50

51
        HASHMAP_FOREACH_KEY(u, t, s->units) {
2,756✔
52
                if (u->id != t)
2,740✔
53
                        continue;
100✔
54

55
                if (!strv_fnmatch_or_empty(patterns, u->id, FNM_NOESCAPE))
2,640✔
56
                        continue;
2,310✔
57

58
                unit_dump(u, f, prefix);
330✔
59
        }
60
}
16✔
61

62
static void manager_dump_header(Manager *m, FILE *f, const char *prefix) {
×
63

64
        /* NB: this is a debug interface for developers. It's not supposed to be machine readable or be
65
         * stable between versions. We take the liberty to restructure it entirely between versions and
66
         * add/remove fields at will. */
67

68
        fprintf(f, "%sManager: systemd " PROJECT_VERSION_FULL " (" GIT_VERSION ")\n", strempty(prefix));
×
69
        fprintf(f, "%sFeatures: %s\n", strempty(prefix), systemd_features);
×
70

71
        for (ManagerTimestamp q = 0; q < _MANAGER_TIMESTAMP_MAX; q++) {
×
72
                const dual_timestamp *t = m->timestamps + q;
×
73

74
                if (dual_timestamp_is_set(t))
×
75
                        fprintf(f, "%sTimestamp %s: %s\n",
×
76
                                strempty(prefix),
77
                                manager_timestamp_to_string(q),
78
                                timestamp_is_set(t->realtime) ? FORMAT_TIMESTAMP(t->realtime) :
×
79
                                                                FORMAT_TIMESPAN(t->monotonic, 1));
×
80
        }
81

82
        for (const char *n = sd_bus_track_first(m->subscribed); n; n = sd_bus_track_next(m->subscribed))
×
83
                fprintf(f, "%sSubscribed: %s\n", strempty(prefix), n);
×
84
}
×
85

86
void manager_dump(Manager *m, FILE *f, char **patterns, const char *prefix) {
10✔
87
        assert(m);
10✔
88
        assert(f);
10✔
89

90
        /* If no pattern is provided, dump the full manager state including the manager version, features and
91
         * so on. Otherwise limit the dump to the units/jobs matching the specified patterns. */
92
        if (!patterns)
10✔
93
                manager_dump_header(m, f, prefix);
×
94

95
        manager_dump_units(m, f, patterns, prefix);
10✔
96
        manager_dump_jobs(m, f, patterns, prefix);
10✔
97
}
10✔
98

99
int manager_get_dump_string(Manager *m, char **patterns, char **ret) {
10✔
100
        _cleanup_(memstream_done) MemStream ms = {};
10✔
101
        FILE *f;
10✔
102

103
        assert(m);
10✔
104
        assert(ret);
10✔
105

106
        f = memstream_init(&ms);
10✔
107
        if (!f)
10✔
108
                return -errno;
×
109

110
        manager_dump(m, f, patterns, NULL);
10✔
111

112
        return memstream_finalize(&ms, ret, NULL);
10✔
113
}
114

115
void manager_test_summary(Manager *m) {
×
116
        assert(m);
×
117

118
        printf("-> By units:\n");
×
119
        manager_dump_units(m, stdout, /* patterns= */ NULL, "\t");
×
120

121
        printf("-> By jobs:\n");
×
122
        manager_dump_jobs(m, stdout, /* patterns= */ NULL, "\t");
×
123
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc