@cryptotaxi247 / netdata-1 / commits / f739ab110

allow debugging memory per module (#4524)

* debug info * removed debug code

Costa Tsaousis committed Oct 30, 2018 at 23:14 UTC f739ab110b21c0d13d67569810302d36bd635746
9 files changed +209 -206
collectors/proc.plugin/plugin_proc.c
+13
@@ -94,8 +94,12 @@ void *proc_main(void *ptr) {
94 usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
95 heartbeat_t hb;
96 heartbeat_init(&hb);
97 + size_t iterations = 0;
98
99 while(!netdata_exit) {
100 + iterations++;
101 + (void)iterations;
102 +
103 usec_t hb_dt = heartbeat_next(&hb, step);
104 usec_t duration = 0ULL;
105
@@ -109,10 +113,19 @@ void *proc_main(void *ptr) {
113
114 debug(D_PROCNETDEV_LOOP, "PROC calling %s.", pm->name);
115
116 +//#ifdef NETDATA_LOG_ALLOCATIONS
117 +// if(pm->func == do_proc_interrupts)
118 +// log_thread_memory_allocations = iterations;
119 +//#endif
120 pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt);
121 pm->duration = heartbeat_monotonic_dt_to_now_usec(&hb) - duration;
122 duration += pm->duration;
123
124 +//#ifdef NETDATA_LOG_ALLOCATIONS
125 +// if(pm->func == do_proc_interrupts)
126 +// log_thread_memory_allocations = 0;
127 +//#endif
128 +
129 if(unlikely(netdata_exit)) break;
130 }
131
database/rrdhost.c
+1 -1
@@ -231,7 +231,7 @@ RRDHOST *rrdhost_create(const char *hostname,
231
232 snprintfz(filename, FILENAME_MAX, "%s/alarm-notify.sh", netdata_configured_plugins_dir);
233 host->health_default_exec = strdupz(config_get(CONFIG_SECTION_HEALTH, "script to execute on alarm", filename));
234 - host->health_default_recipient = strdup("root");
234 + host->health_default_recipient = strdupz("root");
235
236
237 // ------------------------------------------------------------------------
database/rrdset.c
+3 -3
@@ -616,10 +616,10 @@ RRDSET *rrdset_create_custom(
616 st->rrd_memory_mode = (memory_mode == RRD_MEMORY_MODE_NONE) ? RRD_MEMORY_MODE_NONE : RRD_MEMORY_MODE_ALLOC;
617 }
618
619 - st->plugin_name = plugin?strdup(plugin):NULL;
620 - st->module_name = module?strdup(module):NULL;
619 + st->plugin_name = plugin?strdupz(plugin):NULL;
620 + st->module_name = module?strdupz(module):NULL;
621
622 - st->config_section = strdup(config_section);
622 + st->config_section = strdupz(config_section);
623 st->rrdhost = host;
624 st->memsize = size;
625 st->entries = entries;
database/rrdsetvar.c
+1 -1
@@ -169,7 +169,7 @@ RRDSETVAR *rrdsetvar_custom_chart_variable_create(RRDSET *st, const char *name)
169 rs = rrdsetvar_create(st, n, RRDVAR_TYPE_CALCULATED, v, RRDVAR_OPTION_ALLOCATED|RRDVAR_OPTION_CUSTOM_CHART_VAR);
170 rrdset_unlock(st);
171
172 - free(n);
172 + freez(n);
173 return rs;
174 }
175
libnetdata/buffer/buffer.c
+1 -2
@@ -381,8 +381,7 @@ void buffer_free(BUFFER *b) {
381 freez(b);
382 }
383
384 -void buffer_increase(BUFFER *b, size_t free_size_required)
385 -{
384 +void buffer_increase(BUFFER *b, size_t free_size_required) {
385 buffer_overflow_check(b);
386
387 size_t left = b->size - b->len;
libnetdata/clocks/clocks.c
+46
@@ -156,3 +156,49 @@ inline usec_t heartbeat_monotonic_dt_to_now_usec(heartbeat_t *hb) {
156 if(!hb || !hb->monotonic) return 0ULL;
157 return now_monotonic_usec() - hb->monotonic;
158 }
159 +
160 +int sleep_usec(usec_t usec) {
161 +
162 +#ifndef NETDATA_WITH_USLEEP
163 + // we expect microseconds (1.000.000 per second)
164 + // but timespec is nanoseconds (1.000.000.000 per second)
165 + struct timespec rem, req = {
166 + .tv_sec = (time_t) (usec / 1000000),
167 + .tv_nsec = (suseconds_t) ((usec % 1000000) * 1000)
168 + };
169 +
170 + while (nanosleep(&req, &rem) == -1) {
171 + if (likely(errno == EINTR)) {
172 + debug(D_SYSTEM, "nanosleep() interrupted (while sleeping for %llu microseconds).", usec);
173 + req.tv_sec = rem.tv_sec;
174 + req.tv_nsec = rem.tv_nsec;
175 + } else {
176 + error("Cannot nanosleep() for %llu microseconds.", usec);
177 + break;
178 + }
179 + }
180 +
181 + return 0;
182 +#else
183 + int ret = usleep(usec);
184 + if(unlikely(ret == -1 && errno == EINVAL)) {
185 + // on certain systems, usec has to be up to 999999
186 + if(usec > 999999) {
187 + int counter = usec / 999999;
188 + while(counter--)
189 + usleep(999999);
190 +
191 + usleep(usec % 999999);
192 + }
193 + else {
194 + error("Cannot usleep() for %llu microseconds.", usec);
195 + return ret;
196 + }
197 + }
198 +
199 + if(ret != 0)
200 + error("usleep() failed for %llu microseconds.", usec);
201 +
202 + return ret;
203 +#endif
204 +}
libnetdata/clocks/clocks.h
+2
@@ -128,4 +128,6 @@ extern usec_t heartbeat_next(heartbeat_t *hb, usec_t tick);
128 /* Returns elapsed time in microseconds since last heartbeat */
129 extern usec_t heartbeat_monotonic_dt_to_now_usec(heartbeat_t *hb);
130
131 +extern int sleep_usec(usec_t usec);
132 +
133 #endif /* NETDATA_CLOCKS_H */
libnetdata/libnetdata.c
+119 -175
@@ -27,182 +27,172 @@ const char *program_version = VERSION;
27 // routines.
28
29 #ifdef NETDATA_LOG_ALLOCATIONS
30 -static struct memory_statistics {
31 - volatile size_t malloc_calls_made;
32 - volatile size_t calloc_calls_made;
33 - volatile size_t realloc_calls_made;
34 - volatile size_t strdup_calls_made;
35 - volatile size_t free_calls_made;
36 - volatile size_t memory_calls_made;
37 - volatile size_t allocated_memory;
38 - volatile size_t mmapped_memory;
39 -} memory_statistics;
40 -
41 -static inline void print_allocations(const char *file, const char *function, const unsigned long line) {
42 - static struct memory_statistics old = { 0, 0, 0, 0, 0, 0, 0, 0 };
43 -
44 - //if(unlikely(!(memory_statistics.memory_calls_made % 5))) {
45 - fprintf(stderr, "(%04lu@%-10.10s:%-15.15s): Allocated %zu KB (+%zu B), mmapped %zu KB (+%zu B): malloc %zu (+%zu), calloc %zu (+%zu), realloc %zu (+%zu), strdup %zu (+%zu), free %zu (+%zu)\n",
46 - line, file, function,
47 - (memory_statistics.allocated_memory + 512) / 1024, memory_statistics.allocated_memory - old.allocated_memory,
48 - (memory_statistics.mmapped_memory + 512) / 1024, memory_statistics.mmapped_memory - old.mmapped_memory,
49 - memory_statistics.malloc_calls_made, memory_statistics.malloc_calls_made - old.malloc_calls_made,
50 - memory_statistics.calloc_calls_made, memory_statistics.calloc_calls_made - old.calloc_calls_made,
51 - memory_statistics.realloc_calls_made, memory_statistics.realloc_calls_made - old.realloc_calls_made,
52 - memory_statistics.strdup_calls_made, memory_statistics.strdup_calls_made - old.strdup_calls_made,
53 - memory_statistics.free_calls_made, memory_statistics.free_calls_made - old.free_calls_made
54 - );
55 -
56 - memcpy(&old, &memory_statistics, sizeof(struct memory_statistics));
57 - //}
30 +static __thread struct memory_statistics {
31 + volatile ssize_t malloc_calls_made;
32 + volatile ssize_t calloc_calls_made;
33 + volatile ssize_t realloc_calls_made;
34 + volatile ssize_t strdup_calls_made;
35 + volatile ssize_t free_calls_made;
36 + volatile ssize_t memory_calls_made;
37 + volatile ssize_t allocated_memory;
38 + volatile ssize_t mmapped_memory;
39 +} memory_statistics = { 0, 0, 0, 0, 0, 0, 0, 0 };
40 +
41 +__thread size_t log_thread_memory_allocations = 0;
42 +
43 +static inline void print_allocations(const char *file, const char *function, const unsigned long line, const char *type, size_t size) {
44 + static __thread struct memory_statistics old = { 0, 0, 0, 0, 0, 0, 0, 0 };
45 +
46 + fprintf(stderr, "%s iteration %zu MEMORY TRACE: %lu@%s : %s : %s : %zu\n",
47 + netdata_thread_tag(),
48 + log_thread_memory_allocations,
49 + line, file, function,
50 + type, size
51 + );
52 +
53 + fprintf(stderr, "%s iteration %zu MEMORY ALLOCATIONS: (%04lu@%-40.40s:%-40.40s): Allocated %zd KB (%+zd B), mmapped %zd KB (%+zd B): %s : malloc %zd (%+zd), calloc %zd (%+zd), realloc %zd (%+zd), strdup %zd (%+zd), free %zd (%+zd)\n",
54 + netdata_thread_tag(),
55 + log_thread_memory_allocations,
56 + line, file, function,
57 + (memory_statistics.allocated_memory + 512) / 1024, memory_statistics.allocated_memory - old.allocated_memory,
58 + (memory_statistics.mmapped_memory + 512) / 1024, memory_statistics.mmapped_memory - old.mmapped_memory,
59 + type,
60 + memory_statistics.malloc_calls_made, memory_statistics.malloc_calls_made - old.malloc_calls_made,
61 + memory_statistics.calloc_calls_made, memory_statistics.calloc_calls_made - old.calloc_calls_made,
62 + memory_statistics.realloc_calls_made, memory_statistics.realloc_calls_made - old.realloc_calls_made,
63 + memory_statistics.strdup_calls_made, memory_statistics.strdup_calls_made - old.strdup_calls_made,
64 + memory_statistics.free_calls_made, memory_statistics.free_calls_made - old.free_calls_made
65 + );
66 +
67 + memcpy(&old, &memory_statistics, sizeof(struct memory_statistics));
68 }
69
60 -static inline void malloc_accounting(const char *file, const char *function, const unsigned long line, size_t size) {
61 -#if defined(HAVE_C___ATOMIC) && !defined(NETDATA_NO_ATOMIC_INSTRUCTIONS)
62 - __atomic_fetch_add(&memory_statistics.memory_calls_made, 1, __ATOMIC_SEQ_CST);
63 - __atomic_fetch_add(&memory_statistics.malloc_calls_made, 1, __ATOMIC_SEQ_CST);
64 - __atomic_fetch_add(&memory_statistics.allocated_memory, size, __ATOMIC_SEQ_CST);
65 -#else
66 - // this is for debugging - we don't care locking it
67 - memory_statistics.memory_calls_made++;
68 - memory_statistics.malloc_calls_made++;
69 - memory_statistics.allocated_memory += size;
70 -#endif
71 - print_allocations(file, function, line);
70 +static inline void mmap_accounting(size_t size) {
71 + if(log_thread_memory_allocations) {
72 + memory_statistics.memory_calls_made++;
73 + memory_statistics.mmapped_memory += size;
74 + }
75 }
76
74 -static inline void mmap_accounting(size_t size) {
75 -#if defined(HAVE_C___ATOMIC) && !defined(NETDATA_NO_ATOMIC_INSTRUCTIONS)
76 - __atomic_fetch_add(&memory_statistics.malloc_calls_made, 1, __ATOMIC_SEQ_CST);
77 - __atomic_fetch_add(&memory_statistics.mmapped_memory, size, __ATOMIC_SEQ_CST);
78 -#else
79 - // this is for debugging - we don't care locking it
80 - memory_statistics.memory_calls_made++;
81 - memory_statistics.mmapped_memory += size;
82 -#endif
77 +void *mallocz_int(const char *file, const char *function, const unsigned long line, size_t size) {
78 + if(log_thread_memory_allocations) {
79 + memory_statistics.memory_calls_made++;
80 + memory_statistics.malloc_calls_made++;
81 + memory_statistics.allocated_memory += size;
82 + print_allocations(file, function, line, "malloc()", size);
83 + }
84 +
85 + size_t *n = (size_t *)malloc(sizeof(size_t) + size);
86 + if (unlikely(!n)) fatal("mallocz() cannot allocate %zu bytes of memory.", size);
87 + *n = size;
88 + return (void *)&n[1];
89 }
90
85 -static inline void calloc_accounting(const char *file, const char *function, const unsigned long line, size_t size) {
86 -#if defined(HAVE_C___ATOMIC) && !defined(NETDATA_NO_ATOMIC_INSTRUCTIONS)
87 - __atomic_fetch_add(&memory_statistics.memory_calls_made, 1, __ATOMIC_SEQ_CST);
88 - __atomic_fetch_add(&memory_statistics.calloc_calls_made, 1, __ATOMIC_SEQ_CST);
89 - __atomic_fetch_add(&memory_statistics.allocated_memory, size, __ATOMIC_SEQ_CST);
90 -#else
91 - // this is for debugging - we don't care locking it
92 - memory_statistics.memory_calls_made++;
93 - memory_statistics.calloc_calls_made++;
94 - memory_statistics.allocated_memory += size;
95 -#endif
96 - print_allocations(file, function, line);
91 +void *callocz_int(const char *file, const char *function, const unsigned long line, size_t nmemb, size_t size) {
92 + size = nmemb * size;
93 +
94 + if(log_thread_memory_allocations) {
95 + memory_statistics.memory_calls_made++;
96 + memory_statistics.calloc_calls_made++;
97 + memory_statistics.allocated_memory += size;
98 + print_allocations(file, function, line, "calloc()", size);
99 + }
100 +
101 + size_t *n = (size_t *)calloc(1, sizeof(size_t) + size);
102 + if (unlikely(!n)) fatal("callocz() cannot allocate %zu bytes of memory.", size);
103 + *n = size;
104 + return (void *)&n[1];
105 }
106
99 -static inline void realloc_accounting(const char *file, const char *function, const unsigned long line, void *ptr, size_t size) {
100 - (void)ptr;
107 +void *reallocz_int(const char *file, const char *function, const unsigned long line, void *ptr, size_t size) {
108 + if(!ptr) return mallocz_int(file, function, line, size);
109
102 -#if defined(HAVE_C___ATOMIC) && !defined(NETDATA_NO_ATOMIC_INSTRUCTIONS)
103 - __atomic_fetch_add(&memory_statistics.memory_calls_made, 1, __ATOMIC_SEQ_CST);
104 - __atomic_fetch_add(&memory_statistics.realloc_calls_made, 1, __ATOMIC_SEQ_CST);
105 - __atomic_fetch_add(&memory_statistics.allocated_memory, size, __ATOMIC_SEQ_CST);
106 -#else
107 - // this is for debugging - we don't care locking it
108 - memory_statistics.memory_calls_made++;
109 - memory_statistics.realloc_calls_made++;
110 - memory_statistics.allocated_memory += size;
111 -#endif
112 - print_allocations(file, function, line);
110 + size_t *n = (size_t *)ptr;
111 + n--;
112 + size_t old_size = *n;
113 +
114 + n = realloc(n, sizeof(size_t) + size);
115 + if (unlikely(!n)) fatal("reallocz() cannot allocate %zu bytes of memory (from %zu bytes).", size, old_size);
116 +
117 + if(log_thread_memory_allocations) {
118 + memory_statistics.memory_calls_made++;
119 + memory_statistics.realloc_calls_made++;
120 + memory_statistics.allocated_memory += (size - old_size);
121 + print_allocations(file, function, line, "realloc()", size - old_size);
122 + }
123 +
124 + *n = size;
125 + return (void *)&n[1];
126 }
127
115 -static inline void strdup_accounting(const char *file, const char *function, const unsigned long line, const char *s) {
128 +char *strdupz_int(const char *file, const char *function, const unsigned long line, const char *s) {
129 size_t size = strlen(s) + 1;
130
118 -#if defined(HAVE_C___ATOMIC) && !defined(NETDATA_NO_ATOMIC_INSTRUCTIONS)
119 - __atomic_fetch_add(&memory_statistics.memory_calls_made, 1, __ATOMIC_SEQ_CST);
120 - __atomic_fetch_add(&memory_statistics.strdup_calls_made, 1, __ATOMIC_SEQ_CST);
121 - __atomic_fetch_add(&memory_statistics.allocated_memory, size, __ATOMIC_SEQ_CST);
122 -#else
123 - // this is for debugging - we don't care locking it
124 - memory_statistics.memory_calls_made++;
125 - memory_statistics.strdup_calls_made++;
126 - memory_statistics.allocated_memory += size;
127 -#endif
128 - print_allocations(file, function, line);
131 + if(log_thread_memory_allocations) {
132 + memory_statistics.memory_calls_made++;
133 + memory_statistics.strdup_calls_made++;
134 + memory_statistics.allocated_memory += size;
135 + print_allocations(file, function, line, "strdup()", size);
136 + }
137 +
138 + size_t *n = (size_t *)malloc(sizeof(size_t) + size);
139 + if (unlikely(!n)) fatal("strdupz() cannot allocate %zu bytes of memory.", size);
140 +
141 + *n = size;
142 + char *t = (char *)&n[1];
143 + strcpy(t, s);
144 + return t;
145 }
146
131 -static inline void free_accounting(const char *file, const char *function, const unsigned long line, void *ptr) {
132 - (void)file;
133 - (void)function;
134 - (void)line;
147 +void freez_int(const char *file, const char *function, const unsigned long line, void *ptr) {
148 + if(unlikely(!ptr)) return;
149
136 - if(likely(ptr)) {
137 -#if defined(HAVE_C___ATOMIC) && !defined(NETDATA_NO_ATOMIC_INSTRUCTIONS)
138 - __atomic_fetch_add(&memory_statistics.memory_calls_made, 1, __ATOMIC_SEQ_CST);
139 - __atomic_fetch_add(&memory_statistics.free_calls_made, 1, __ATOMIC_SEQ_CST);
140 -#else
141 - // this is for debugging - we don't care locking it
150 + size_t *n = (size_t *)ptr;
151 + n--;
152 + size_t size = *n;
153 +
154 + if(log_thread_memory_allocations) {
155 memory_statistics.memory_calls_made++;
156 memory_statistics.free_calls_made++;
144 -#endif
157 + memory_statistics.allocated_memory -= size;
158 + print_allocations(file, function, line, "free()", size);
159 }
146 -}
147 -#endif
160
149 -#ifdef NETDATA_LOG_ALLOCATIONS
150 -char *strdupz_int(const char *file, const char *function, const unsigned long line, const char *s) {
151 - strdup_accounting(file, function, line, s);
161 + free(n);
162 +}
163 #else
153 -char *strdupz(const char *s) {
154 -#endif
164
165 +char *strdupz(const char *s) {
166 char *t = strdup(s);
167 if (unlikely(!t)) fatal("Cannot strdup() string '%s'", s);
168 return t;
169 }
170
161 -#ifdef NETDATA_LOG_ALLOCATIONS
162 -void *mallocz_int(const char *file, const char *function, const unsigned long line, size_t size) {
163 - malloc_accounting(file, function, line, size);
164 -#else
165 -void *mallocz(size_t size) {
166 -#endif
171 +void freez(void *ptr) {
172 + free(ptr);
173 +}
174
175 +void *mallocz(size_t size) {
176 void *p = malloc(size);
177 if (unlikely(!p)) fatal("Cannot allocate %zu bytes of memory.", size);
178 return p;
179 }
180
173 -#ifdef NETDATA_LOG_ALLOCATIONS
174 -void *callocz_int(const char *file, const char *function, const unsigned long line, size_t nmemb, size_t size) {
175 - calloc_accounting(file, function, line, nmemb * size);
176 -#else
181 void *callocz(size_t nmemb, size_t size) {
178 -#endif
179 -
182 void *p = calloc(nmemb, size);
183 if (unlikely(!p)) fatal("Cannot allocate %zu bytes of memory.", nmemb * size);
184 return p;
185 }
186
185 -#ifdef NETDATA_LOG_ALLOCATIONS
186 -void *reallocz_int(const char *file, const char *function, const unsigned long line, void *ptr, size_t size) {
187 - realloc_accounting(file, function, line, ptr, size);
188 -#else
187 void *reallocz(void *ptr, size_t size) {
190 -#endif
191 -
188 void *p = realloc(ptr, size);
189 if (unlikely(!p)) fatal("Cannot re-allocate memory to %zu bytes.", size);
190 return p;
191 }
192
197 -#ifdef NETDATA_LOG_ALLOCATIONS
198 -void freez_int(const char *file, const char *function, const unsigned long line, void *ptr) {
199 - free_accounting(file, function, line, ptr);
200 -#else
201 -void freez(void *ptr) {
193 #endif
194
204 - free(ptr);
205 -}
195 +// --------------------------------------------------------------------------------------------------------------------
196
197 void json_escape_string(char *dst, const char *src, size_t size) {
198 const char *t;
@@ -235,52 +225,6 @@ void json_fix_string(char *s) {
225 }
226 }
227
238 -int sleep_usec(usec_t usec) {
239 -
240 -#ifndef NETDATA_WITH_USLEEP
241 - // we expect microseconds (1.000.000 per second)
242 - // but timespec is nanoseconds (1.000.000.000 per second)
243 - struct timespec rem, req = {
244 - .tv_sec = (time_t) (usec / 1000000),
245 - .tv_nsec = (suseconds_t) ((usec % 1000000) * 1000)
246 - };
247 -
248 - while (nanosleep(&req, &rem) == -1) {
249 - if (likely(errno == EINTR)) {
250 - debug(D_SYSTEM, "nanosleep() interrupted (while sleeping for %llu microseconds).", usec);
251 - req.tv_sec = rem.tv_sec;
252 - req.tv_nsec = rem.tv_nsec;
253 - } else {
254 - error("Cannot nanosleep() for %llu microseconds.", usec);
255 - break;
256 - }
257 - }
258 -
259 - return 0;
260 -#else
261 - int ret = usleep(usec);
262 - if(unlikely(ret == -1 && errno == EINVAL)) {
263 - // on certain systems, usec has to be up to 999999
264 - if(usec > 999999) {
265 - int counter = usec / 999999;
266 - while(counter--)
267 - usleep(999999);
268 -
269 - usleep(usec % 999999);
270 - }
271 - else {
272 - error("Cannot usleep() for %llu microseconds.", usec);
273 - return ret;
274 - }
275 - }
276 -
277 - if(ret != 0)
278 - error("usleep() failed for %llu microseconds.", usec);
279 -
280 - return ret;
281 -#endif
282 -}
283 -
228 unsigned char netdata_map_chart_names[256] = {
229 [0] = '\0', //
230 [1] = '_', //
libnetdata/libnetdata.h
+23 -24
@@ -204,26 +204,6 @@
204
205 #define GUID_LEN 36
206
207 -#include "os.h"
208 -#include "storage_number/storage_number.h"
209 -#include "buffer/buffer.h"
210 -#include "locks/locks.h"
211 -#include "avl/avl.h"
212 -#include "inlined.h"
213 -#include "clocks/clocks.h"
214 -#include "threads/threads.h"
215 -#include "popen/popen.h"
216 -#include "simple_pattern/simple_pattern.h"
217 -#include "socket/socket.h"
218 -#include "config/appconfig.h"
219 -#include "log/log.h"
220 -#include "procfile/procfile.h"
221 -#include "dictionary/dictionary.h"
222 -#include "eval/eval.h"
223 -#include "statistical/statistical.h"
224 -#include "adaptive_resortable_list/adaptive_resortable_list.h"
225 -#include "url/url.h"
226 -
207 extern void netdata_fix_chart_id(char *s);
208 extern void netdata_fix_chart_name(char *s);
209
@@ -237,6 +217,7 @@ extern int snprintfz(char *dst, size_t n, const char *fmt, ...) PRINTFLIKE(3, 4
217
218 // memory allocation functions that handle failures
219 #ifdef NETDATA_LOG_ALLOCATIONS
220 +extern __thread size_t log_thread_memory_allocations;
221 #define strdupz(s) strdupz_int(__FILE__, __FUNCTION__, __LINE__, s)
222 #define callocz(nmemb, size) callocz_int(__FILE__, __FUNCTION__, __LINE__, nmemb, size)
223 #define mallocz(size) mallocz_int(__FILE__, __FUNCTION__, __LINE__, size)
@@ -248,13 +229,13 @@ extern void *callocz_int(const char *file, const char *function, const unsigned
229 extern void *mallocz_int(const char *file, const char *function, const unsigned long line, size_t size);
230 extern void *reallocz_int(const char *file, const char *function, const unsigned long line, void *ptr, size_t size);
231 extern void freez_int(const char *file, const char *function, const unsigned long line, void *ptr);
251 -#else
232 +#else // NETDATA_LOG_ALLOCATIONS
233 extern char *strdupz(const char *s) MALLOCLIKE NEVERNULL;
234 extern void *callocz(size_t nmemb, size_t size) MALLOCLIKE NEVERNULL;
235 extern void *mallocz(size_t size) MALLOCLIKE NEVERNULL;
236 extern void *reallocz(void *ptr, size_t size) MALLOCLIKE NEVERNULL;
237 extern void freez(void *ptr);
257 -#endif
238 +#endif // NETDATA_LOG_ALLOCATIONS
239
240 extern void json_escape_string(char *dst, const char *src, size_t size);
241 extern void json_fix_string(char *s);
@@ -268,8 +249,6 @@ extern struct rlimit rlimit_nofile;
249
250 extern int enable_ksm;
251
271 -extern int sleep_usec(usec_t usec);
272 -
252 extern char *fgets_trim_len(char *buf, size_t buf_size, FILE *fp, size_t *len);
253
254 extern int verify_netdata_host_prefix();
@@ -306,4 +285,24 @@ extern void recursive_config_double_dir_load(
285 extern void netdata_cleanup_and_exit(int ret) NORETURN;
286 extern char *netdata_configured_host_prefix;
287
288 +#include "os.h"
289 +#include "storage_number/storage_number.h"
290 +#include "threads/threads.h"
291 +#include "buffer/buffer.h"
292 +#include "locks/locks.h"
293 +#include "avl/avl.h"
294 +#include "inlined.h"
295 +#include "clocks/clocks.h"
296 +#include "popen/popen.h"
297 +#include "simple_pattern/simple_pattern.h"
298 +#include "socket/socket.h"
299 +#include "config/appconfig.h"
300 +#include "log/log.h"
301 +#include "procfile/procfile.h"
302 +#include "dictionary/dictionary.h"
303 +#include "eval/eval.h"
304 +#include "statistical/statistical.h"
305 +#include "adaptive_resortable_list/adaptive_resortable_list.h"
306 +#include "url/url.h"
307 +
308 #endif // NETDATA_LIB_H