Motr  M0
trace.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_LIB_TRACE_H__
26 #define __MOTR_LIB_TRACE_H__
27 
28 #include <stdarg.h>
29 
30 #include "lib/types.h"
31 #include "lib/arith.h"
32 #include "lib/atomic.h"
33 #include "lib/time.h" /* m0_time_t, printf_check */
34 #include "lib/misc.h" /* M0_CAT */
35 #include "motr/magic.h" /* M0_TRACE_DESCR_MAGIC */
36 
37 #ifndef __KERNEL__
38 #include "lib/user_space/trace.h"
39 #endif
40 
167 #define M0_LOG(level, ...) \
168  M0_CAT(M0_LOG, M0_COUNT_PARAMS(__VA_ARGS__))(level, __VA_ARGS__)
169 
170 #define M0_ENTRY(...) M0_LOG(M0_CALL, "> " __VA_ARGS__)
171 #define M0_LEAVE(...) M0_LOG(M0_CALL, "< " __VA_ARGS__)
172 
182 #define M0_RC_HOOK (0)
183 
184 #if M0_RC_HOOK
185 M0_INTERNAL void m0_rc_hook(int rc);
186 M0_INTERNAL void m0_err_hook(int rc);
187 #else
188 static inline void m0_rc_hook(int rc)
189 {;}
190 static inline void m0_err_hook(int rc)
191 {;}
192 #endif
193 
194 #define M0_RC(rc) ({ \
195  typeof(rc) __rc = (rc); \
196  M0_LOG(M0_CALL, "< rc=%d", __rc); \
197  m0_rc_hook(__rc); \
198  __rc; \
199 })
200 
201 #define M0_ERR(rc) ({ \
202  typeof(rc) __rc = (rc); \
203  M0_ASSERT(__rc != 0); \
204  M0_LOG(M0_ERROR, "<! rc=%d", __rc); \
205  m0_err_hook(__rc); \
206  __rc; \
207 })
208 
209 #define M0_RC_INFO(rc, fmt, ...) ({ \
210  typeof(rc) __rc = (rc); \
211  M0_LOG(M0_CALL, "< rc=%d " fmt, __rc, ## __VA_ARGS__ ); \
212  __rc; \
213 })
214 
215 #define M0_ERR_INFO(rc, fmt, ...) ({ \
216  typeof(rc) __rc = (rc); \
217  M0_ASSERT(__rc != 0); \
218  M0_LOG(M0_ERROR, "<! rc=%d " fmt, __rc, ## __VA_ARGS__ ); \
219  __rc; \
220 })
221 
222 M0_INTERNAL int m0_trace_init(void);
223 M0_INTERNAL void m0_trace_fini(void);
224 M0_INTERNAL int m0_trace_set_immediate_mask(const char *mask);
225 M0_INTERNAL int m0_trace_set_print_context(const char *ctx_name);
226 M0_INTERNAL int m0_trace_set_level(const char *level);
227 
239 #define M0_TRACE_SUBSYSTEMS \
240  M0_TRACE_SUBSYS(OTHER, 0) \
241  M0_TRACE_SUBSYS(LIB, 1) \
242  M0_TRACE_SUBSYS(UT, 2) \
243  \
244  M0_TRACE_SUBSYS(ADDB, 3) \
245  M0_TRACE_SUBSYS(ADSTOB, 4) \
246  M0_TRACE_SUBSYS(BALLOC, 5) \
247  M0_TRACE_SUBSYS(BE, 6) \
248  M0_TRACE_SUBSYS(BTREE, 7) \
249  M0_TRACE_SUBSYS(CAS, 8) \
250  M0_TRACE_SUBSYS(CLIENT, 9) \
251  M0_TRACE_SUBSYS(CM, 10) \
252  M0_TRACE_SUBSYS(COB, 11) \
253  M0_TRACE_SUBSYS(CONF, 12) \
254  M0_TRACE_SUBSYS(CONSOLE, 13) \
255  M0_TRACE_SUBSYS(DIX, 14) \
256  M0_TRACE_SUBSYS(DIXCM, 15) \
257  M0_TRACE_SUBSYS(DTM, 16) \
258  M0_TRACE_SUBSYS(EXTMAP, 17) \
259  M0_TRACE_SUBSYS(FD, 18) \
260  M0_TRACE_SUBSYS(FILE, 19) \
261  M0_TRACE_SUBSYS(FOL, 20) \
262  M0_TRACE_SUBSYS(FOP, 21) \
263  M0_TRACE_SUBSYS(FORMATION, 22) \
264  M0_TRACE_SUBSYS(HA, 23) \
265  M0_TRACE_SUBSYS(IOSERVICE, 24) \
266  M0_TRACE_SUBSYS(LAYOUT, 25) \
267  M0_TRACE_SUBSYS(LNET, 26) \
268  M0_TRACE_SUBSYS(M0D, 27) \
269  M0_TRACE_SUBSYS(M0T1FS, 28) \
270  M0_TRACE_SUBSYS(MDS, 29) \
271  M0_TRACE_SUBSYS(MEMORY, 30) \
272  M0_TRACE_SUBSYS(MGMT, 31) \
273  M0_TRACE_SUBSYS(NET, 32) \
274  M0_TRACE_SUBSYS(POOL, 33) \
275  M0_TRACE_SUBSYS(RM, 34) \
276  M0_TRACE_SUBSYS(RPC, 35) \
277  M0_TRACE_SUBSYS(SM, 36) \
278  M0_TRACE_SUBSYS(SNS, 37) \
279  M0_TRACE_SUBSYS(SNSCM, 38) \
280  M0_TRACE_SUBSYS(SPIEL, 39) \
281  M0_TRACE_SUBSYS(SSS, 40) \
282  M0_TRACE_SUBSYS(STATS, 41) \
283  M0_TRACE_SUBSYS(STOB, 42) \
284  M0_TRACE_SUBSYS(XCODE, 43) \
285  M0_TRACE_SUBSYS(FDMI, 44) \
286  M0_TRACE_SUBSYS(ISCS, 45) \
287  M0_TRACE_SUBSYS(DTM0, 46)
288 
289 #define M0_TRACE_SUBSYS(name, value) M0_TRACE_SUBSYS_ ## name = (1UL << value),
290 
293 };
294 
299 extern unsigned long m0_trace_immediate_mask;
300 
307 extern unsigned int m0_trace_print_context;
308 
319 extern unsigned int m0_trace_level;
320 
321 /*
322  * Below is the internal implementation stuff.
323  */
324 
325 enum {
330  M0_TRACE_BUF_HEADER_SIZE = (1 << 16), /* 64KB */
332  M0_TRACE_REC_ALIGN = 8, /* word size on x86_64 */
333 };
334 
335 extern struct m0_trace_buf_header *m0_logbuf_header;
336 extern void *m0_logbuf;
341 };
342 
346 
348 };
350 
358  union {
359  struct {
360  /* XXX: don't change fields order */
361  /* XXX: new fields should be added at the end */
362 
363  uint64_t tbh_magic;
365  const void *tbh_header_addr;
372  uint32_t tbh_header_size;
374  const void *tbh_buf_addr;
376  uint64_t tbh_buf_size;
378  uint16_t tbh_buf_type;
380  uint16_t tbh_buf_flags;
392  const void *tbh_magic_sym_addr;
402  const void *tbh_module_struct;
407  const void *tbh_module_core_addr;
409  unsigned int tbh_module_core_size;
411  char tbh_cli_args[1024];
419  const void *tbh_magic_sym_addresses[128];
420 
421  /* XXX: add new field right above this line */
422  };
424  };
425 };
427 
438  /* XXX: don't change fields order */
439  /* XXX: new fields should be added to the end */
440  uint64_t trh_magic;
441  uint64_t trh_sp;
442  uint64_t trh_no;
443  uint64_t trh_pos;
444  uint64_t trh_timestamp;
445  const struct m0_trace_descr *trh_descr;
447  uint32_t trh_record_size;
448  pid_t trh_pid;
449 };
450 
459  M0_NONE = 0,
460 
465  M0_ALWAYS = 1 << 0,
466 
468  M0_FATAL = 1 << 1,
473  M0_ERROR = 1 << 2,
478  M0_WARN = 1 << 3,
480  M0_NOTICE = 1 << 4,
482  M0_INFO = 1 << 5,
487  M0_DEBUG = 1 << 6,
488 
493  M0_CALL = 1 << 7,
494 };
495 
501 
503 };
504 
506  uint64_t td_magic;
507  const char *td_fmt;
508  const char *td_func;
509  const char *td_file;
510  uint64_t td_subsys;
511  int td_line;
512  int td_size;
513  int td_nr;
514  const int *td_offset;
515  const int *td_sizeof;
516  const bool *td_isstr;
518  bool td_hasstr;
519 };
520 
525 M0_INTERNAL void m0_trace_level_allow(unsigned level);
526 
527 M0_INTERNAL void m0_trace_allot(const struct m0_trace_descr *td,
528  const void *data);
529 M0_INTERNAL void m0_trace_record_print(const struct m0_trace_rec_header *trh,
530  const void *buf);
531 
532 M0_INTERNAL void m0_trace_print_subsystems(void);
533 
534 __attribute__ ((format (printf, 1, 2)))
535 void m0_console_printf(const char *fmt, ...);
536 
537 void m0_console_flush(void);
538 
539 __attribute__ ((format (printf, 1, 2)))
540 void m0_error_printf(const char *fmt, ...);
541 
542 M0_INTERNAL
543 int m0_trace_record_print_yaml(char *outbuf, size_t outbuf_size,
544  const struct m0_trace_rec_header *trh,
545  const void *tr_body, bool yaml_stream_mode);
546 
547 /*
548  * The code below abuses C preprocessor badly. Looking at it might be damaging
549  * to your eyes and sanity.
550  */
551 
572 #define M0_TRACE_POINT(LEVEL, NR, DECL, OFFSET, SIZEOF, ISSTR, HASSTR, FMT, ...)\
573 ({ \
574  struct t_body DECL; \
575  static const int _offset[NR] = OFFSET; \
576  static const int _sizeof[NR] = SIZEOF; \
577  static const bool _isstr[NR] = ISSTR; \
578  static const struct m0_trace_descr __trace_descr = { \
579  .td_magic = M0_TRACE_DESCR_MAGIC, \
580  .td_level = (LEVEL), \
581  .td_fmt = (FMT), \
582  .td_func = __func__, \
583  .td_file = __FILE__, \
584  .td_line = __LINE__, \
585  .td_subsys = M0_TRACE_SUBSYSTEM, \
586  .td_size = sizeof(struct t_body), \
587  .td_nr = (NR), \
588  .td_offset = _offset, \
589  .td_sizeof = _sizeof, \
590  .td_isstr = _isstr, \
591  .td_hasstr = (HASSTR), \
592  }; \
593  printf_check(FMT , ## __VA_ARGS__); \
594  m0_trace_allot(&__trace_descr, &(const struct t_body){ __VA_ARGS__ });\
595 })
596 
597 #ifndef M0_TRACE_SUBSYSTEM
598 # define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_OTHER
599 #endif
600 
601 enum {
603 };
604 
605 /*
606  * Helpers for M0_LOG{n}().
607  */
608 #define LOG_TYPEOF(a, v) typeof(a) v
609 #define LOG_OFFSETOF(v) offsetof(struct t_body, v)
610 #define LOG_SIZEOF(a) sizeof(a)
611 #define LOG_IS_STR_ARG(a) \
612  M0_HAS_TYPE((a), char*) ?: \
613  M0_HAS_TYPE((a), const char*) ?: \
614  M0_HAS_TYPE((a), char[]) ?: \
615  M0_HAS_TYPE((a), const char[]) ?: false
616 
617 
618 #define LOG_CHECK(a) \
619 M0_CASSERT(!M0_HAS_TYPE(a, const char []) && \
620  (sizeof(a) == 1 || sizeof(a) == 2 || sizeof(a) == 4 || \
621  sizeof(a) == 8))
622 
627 #define LOG_GROUP(...) __VA_ARGS__
628 
629 #define M0_LOG0(level, fmt) \
630  M0_TRACE_POINT(level, 0, { ; }, {}, {}, {}, false, fmt)
631 
632 #define M0_LOG1(level, fmt, a0) \
633 ({ M0_TRACE_POINT(level, 1, \
634  { LOG_TYPEOF(a0, v0); }, \
635  { LOG_OFFSETOF(v0) }, \
636  { LOG_SIZEOF(a0) }, \
637  { LOG_IS_STR_ARG(a0) }, \
638  LOG_IS_STR_ARG(a0), \
639  fmt, a0); \
640  LOG_CHECK(a0); })
641 
642 #define M0_LOG2(level, fmt, a0, a1) \
643 ({ M0_TRACE_POINT(level, 2, \
644  { LOG_TYPEOF(a0, v0); LOG_TYPEOF(a1, v1); }, \
645  LOG_GROUP({ LOG_OFFSETOF(v0), LOG_OFFSETOF(v1) }), \
646  LOG_GROUP({ LOG_SIZEOF(a0), LOG_SIZEOF(a1) }), \
647  LOG_GROUP({ LOG_IS_STR_ARG(a0), LOG_IS_STR_ARG(a1) }), \
648  LOG_IS_STR_ARG(a0) || LOG_IS_STR_ARG(a1), \
649  fmt, a0, a1); \
650  LOG_CHECK(a0); LOG_CHECK(a1); })
651 
652 #define M0_LOG3(level, fmt, a0, a1, a2) \
653 ({ M0_TRACE_POINT(level, 3, \
654  { LOG_TYPEOF(a0, v0); LOG_TYPEOF(a1, v1); LOG_TYPEOF(a2, v2); }, \
655  LOG_GROUP({ LOG_OFFSETOF(v0), LOG_OFFSETOF(v1), LOG_OFFSETOF(v2) }), \
656  LOG_GROUP({ LOG_SIZEOF(a0), LOG_SIZEOF(a1), LOG_SIZEOF(a2) }), \
657  LOG_GROUP({ LOG_IS_STR_ARG(a0), LOG_IS_STR_ARG(a1), \
658  LOG_IS_STR_ARG(a2) }), \
659  LOG_IS_STR_ARG(a0) || LOG_IS_STR_ARG(a1) || LOG_IS_STR_ARG(a2), \
660  fmt, a0, a1, a2); \
661  LOG_CHECK(a0); LOG_CHECK(a1); LOG_CHECK(a2); })
662 
663 #define M0_LOG4(level, fmt, a0, a1, a2, a3) \
664 ({ M0_TRACE_POINT(level, 4, \
665  { LOG_TYPEOF(a0, v0); LOG_TYPEOF(a1, v1); LOG_TYPEOF(a2, v2); \
666  LOG_TYPEOF(a3, v3); }, \
667  LOG_GROUP({ LOG_OFFSETOF(v0), LOG_OFFSETOF(v1), LOG_OFFSETOF(v2), \
668  LOG_OFFSETOF(v3) }), \
669  LOG_GROUP({ LOG_SIZEOF(a0), LOG_SIZEOF(a1), LOG_SIZEOF(a2), \
670  LOG_SIZEOF(a3) }), \
671  LOG_GROUP({ LOG_IS_STR_ARG(a0), LOG_IS_STR_ARG(a1), \
672  LOG_IS_STR_ARG(a2), LOG_IS_STR_ARG(a3) }), \
673  LOG_IS_STR_ARG(a0) || LOG_IS_STR_ARG(a1) || LOG_IS_STR_ARG(a2) || \
674  LOG_IS_STR_ARG(a3), \
675  fmt, a0, a1, a2, a3); \
676  LOG_CHECK(a0); LOG_CHECK(a1); LOG_CHECK(a2); LOG_CHECK(a3); })
677 
678 #define M0_LOG5(level, fmt, a0, a1, a2, a3, a4) \
679 ({ M0_TRACE_POINT(level, 5, \
680  { LOG_TYPEOF(a0, v0); LOG_TYPEOF(a1, v1); LOG_TYPEOF(a2, v2); \
681  LOG_TYPEOF(a3, v3); LOG_TYPEOF(a4, v4); }, \
682  LOG_GROUP({ LOG_OFFSETOF(v0), LOG_OFFSETOF(v1), LOG_OFFSETOF(v2), \
683  LOG_OFFSETOF(v3), LOG_OFFSETOF(v4) }), \
684  LOG_GROUP({ LOG_SIZEOF(a0), LOG_SIZEOF(a1), LOG_SIZEOF(a2), \
685  LOG_SIZEOF(a3), LOG_SIZEOF(a4) }), \
686  LOG_GROUP({ LOG_IS_STR_ARG(a0), LOG_IS_STR_ARG(a1), \
687  LOG_IS_STR_ARG(a2), LOG_IS_STR_ARG(a3), \
688  LOG_IS_STR_ARG(a4) }), \
689  LOG_IS_STR_ARG(a0) || LOG_IS_STR_ARG(a1) || LOG_IS_STR_ARG(a2) || \
690  LOG_IS_STR_ARG(a3) || LOG_IS_STR_ARG(a4), \
691  fmt, a0, a1, a2, a3, a4); \
692  LOG_CHECK(a0); LOG_CHECK(a1); LOG_CHECK(a2); LOG_CHECK(a3); \
693  LOG_CHECK(a4); })
694 
695 #define M0_LOG6(level, fmt, a0, a1, a2, a3, a4, a5) \
696 ({ M0_TRACE_POINT(level, 6, \
697  { LOG_TYPEOF(a0, v0); LOG_TYPEOF(a1, v1); LOG_TYPEOF(a2, v2); \
698  LOG_TYPEOF(a3, v3); LOG_TYPEOF(a4, v4); LOG_TYPEOF(a5, v5); }, \
699  LOG_GROUP({ LOG_OFFSETOF(v0), LOG_OFFSETOF(v1), LOG_OFFSETOF(v2), \
700  LOG_OFFSETOF(v3), LOG_OFFSETOF(v4), LOG_OFFSETOF(v5) }), \
701  LOG_GROUP({ LOG_SIZEOF(a0), LOG_SIZEOF(a1), LOG_SIZEOF(a2), \
702  LOG_SIZEOF(a3), LOG_SIZEOF(a4), LOG_SIZEOF(a5) }), \
703  LOG_GROUP({ LOG_IS_STR_ARG(a0), LOG_IS_STR_ARG(a1), \
704  LOG_IS_STR_ARG(a2), LOG_IS_STR_ARG(a3), \
705  LOG_IS_STR_ARG(a4), LOG_IS_STR_ARG(a5) }), \
706  LOG_IS_STR_ARG(a0) || LOG_IS_STR_ARG(a1) || LOG_IS_STR_ARG(a2) || \
707  LOG_IS_STR_ARG(a3) || LOG_IS_STR_ARG(a4) || LOG_IS_STR_ARG(a5), \
708  fmt, a0, a1, a2, a3, a4, a5); \
709  LOG_CHECK(a0); LOG_CHECK(a1); LOG_CHECK(a2); LOG_CHECK(a3); \
710  LOG_CHECK(a4); LOG_CHECK(a5); })
711 
712 #define M0_LOG7(level, fmt, a0, a1, a2, a3, a4, a5, a6) \
713 ({ M0_TRACE_POINT(level, 7, \
714  { LOG_TYPEOF(a0, v0); LOG_TYPEOF(a1, v1); LOG_TYPEOF(a2, v2); \
715  LOG_TYPEOF(a3, v3); LOG_TYPEOF(a4, v4); LOG_TYPEOF(a5, v5); \
716  LOG_TYPEOF(a6, v6); }, \
717  LOG_GROUP({ LOG_OFFSETOF(v0), LOG_OFFSETOF(v1), LOG_OFFSETOF(v2), \
718  LOG_OFFSETOF(v3), LOG_OFFSETOF(v4), \
719  LOG_OFFSETOF(v5), LOG_OFFSETOF(v6) }), \
720  LOG_GROUP({ LOG_SIZEOF(a0), LOG_SIZEOF(a1), LOG_SIZEOF(a2), \
721  LOG_SIZEOF(a3), LOG_SIZEOF(a4), \
722  LOG_SIZEOF(a5), LOG_SIZEOF(a6) }), \
723  LOG_GROUP({ LOG_IS_STR_ARG(a0), LOG_IS_STR_ARG(a1), \
724  LOG_IS_STR_ARG(a2), LOG_IS_STR_ARG(a3), \
725  LOG_IS_STR_ARG(a4), LOG_IS_STR_ARG(a5), \
726  LOG_IS_STR_ARG(a6) }), \
727  LOG_IS_STR_ARG(a0) || LOG_IS_STR_ARG(a1) || LOG_IS_STR_ARG(a2) || \
728  LOG_IS_STR_ARG(a3) || LOG_IS_STR_ARG(a4) || \
729  LOG_IS_STR_ARG(a5) || LOG_IS_STR_ARG(a6), \
730  fmt, a0, a1, a2, a3, a4, a5, a6); \
731  LOG_CHECK(a0); LOG_CHECK(a1); LOG_CHECK(a2); LOG_CHECK(a3); \
732  LOG_CHECK(a4); LOG_CHECK(a5); LOG_CHECK(a6); })
733 
734 #define M0_LOG8(level, fmt, a0, a1, a2, a3, a4, a5, a6, a7) \
735 ({ M0_TRACE_POINT(level, 8, \
736  { LOG_TYPEOF(a0, v0); LOG_TYPEOF(a1, v1); LOG_TYPEOF(a2, v2); \
737  LOG_TYPEOF(a3, v3); LOG_TYPEOF(a4, v4); LOG_TYPEOF(a5, v5); \
738  LOG_TYPEOF(a6, v6); LOG_TYPEOF(a7, v7); }, \
739  LOG_GROUP({ LOG_OFFSETOF(v0), LOG_OFFSETOF(v1), LOG_OFFSETOF(v2), \
740  LOG_OFFSETOF(v3), LOG_OFFSETOF(v4), LOG_OFFSETOF(v5), \
741  LOG_OFFSETOF(v6), LOG_OFFSETOF(v7) }), \
742  LOG_GROUP({ LOG_SIZEOF(a0), LOG_SIZEOF(a1), LOG_SIZEOF(a2), \
743  LOG_SIZEOF(a3), LOG_SIZEOF(a4), LOG_SIZEOF(a5), \
744  LOG_SIZEOF(a6), LOG_SIZEOF(a7) }), \
745  LOG_GROUP({ LOG_IS_STR_ARG(a0), LOG_IS_STR_ARG(a1), \
746  LOG_IS_STR_ARG(a2), LOG_IS_STR_ARG(a3), \
747  LOG_IS_STR_ARG(a4), LOG_IS_STR_ARG(a5), \
748  LOG_IS_STR_ARG(a6), LOG_IS_STR_ARG(a7) }), \
749  LOG_IS_STR_ARG(a0) || LOG_IS_STR_ARG(a1) || LOG_IS_STR_ARG(a2) || \
750  LOG_IS_STR_ARG(a3) || LOG_IS_STR_ARG(a4) || \
751  LOG_IS_STR_ARG(a5) || LOG_IS_STR_ARG(a6) || \
752  LOG_IS_STR_ARG(a7), \
753  fmt, a0, a1, a2, a3, a4, a5, a6, a7); \
754  LOG_CHECK(a0); LOG_CHECK(a1); LOG_CHECK(a2); LOG_CHECK(a3); \
755  LOG_CHECK(a4); LOG_CHECK(a5); LOG_CHECK(a6); LOG_CHECK(a7); })
756 
757 #define M0_LOG9(level, fmt, a0, a1, a2, a3, a4, a5, a6, a7, a8) \
758 ({ M0_TRACE_POINT(level, 9, \
759  { LOG_TYPEOF(a0, v0); LOG_TYPEOF(a1, v1); LOG_TYPEOF(a2, v2); \
760  LOG_TYPEOF(a3, v3); LOG_TYPEOF(a4, v4); LOG_TYPEOF(a5, v5); \
761  LOG_TYPEOF(a6, v6); LOG_TYPEOF(a7, v7); LOG_TYPEOF(a8, v8); }, \
762  LOG_GROUP({ LOG_OFFSETOF(v0), LOG_OFFSETOF(v1), LOG_OFFSETOF(v2), \
763  LOG_OFFSETOF(v3), LOG_OFFSETOF(v4), LOG_OFFSETOF(v5), \
764  LOG_OFFSETOF(v6), LOG_OFFSETOF(v7), LOG_OFFSETOF(v8) }), \
765  LOG_GROUP({ LOG_SIZEOF(a0), LOG_SIZEOF(a1), LOG_SIZEOF(a2), \
766  LOG_SIZEOF(a3), LOG_SIZEOF(a4), LOG_SIZEOF(a5), \
767  LOG_SIZEOF(a6), LOG_SIZEOF(a7), LOG_SIZEOF(a8) }), \
768  LOG_GROUP({ LOG_IS_STR_ARG(a0), LOG_IS_STR_ARG(a1), \
769  LOG_IS_STR_ARG(a2), LOG_IS_STR_ARG(a3), \
770  LOG_IS_STR_ARG(a4), LOG_IS_STR_ARG(a5), \
771  LOG_IS_STR_ARG(a6), LOG_IS_STR_ARG(a7), \
772  LOG_IS_STR_ARG(a8) }), \
773  LOG_IS_STR_ARG(a0) || LOG_IS_STR_ARG(a1) || LOG_IS_STR_ARG(a2) || \
774  LOG_IS_STR_ARG(a3) || LOG_IS_STR_ARG(a4) || \
775  LOG_IS_STR_ARG(a5) || LOG_IS_STR_ARG(a6) || \
776  LOG_IS_STR_ARG(a7) || LOG_IS_STR_ARG(a8), \
777  fmt, a0, a1, a2, a3, a4, a5, a6, a7, a8); \
778  LOG_CHECK(a0); LOG_CHECK(a1); LOG_CHECK(a2); LOG_CHECK(a3); \
779  LOG_CHECK(a4); LOG_CHECK(a5); LOG_CHECK(a6); LOG_CHECK(a7); LOG_CHECK(a8); })
780 
782 #endif /* __MOTR_LIB_TRACE_H__ */
783 
784 /*
785  * Local variables:
786  * c-indentation-style: "K&R"
787  * c-basic-offset: 8
788  * tab-width: 8
789  * fill-column: 80
790  * scroll-step: 1
791  * End:
792  */
Definition: trace.h:493
uint64_t td_subsys
Definition: trace.h:510
void m0_error_printf(const char *fmt,...)
Definition: ktrace.c:169
int td_line
Definition: trace.h:511
M0_INTERNAL void m0_trace_print_subsystems(void)
Definition: trace.c:678
uint64_t m0_time_t
Definition: time.h:37
struct m0_atomic64 tbh_cur_pos
Definition: trace.h:385
enum m0_trace_level level
Definition: trace.c:111
uint64_t trh_timestamp
Definition: trace.h:444
uint64_t tbh_buf_size
Definition: trace.h:376
void m0_console_printf(const char *fmt,...)
Definition: trace.c:801
M0_INTERNAL void m0_trace_level_allow(unsigned level)
Definition: trace.c:218
enum m0_trace_level td_level
Definition: trace.h:517
M0_INTERNAL int m0_trace_record_print_yaml(char *outbuf, size_t outbuf_size, const struct m0_trace_rec_header *trh, const void *tr_body, bool yaml_stream_mode)
Definition: trace.c:836
const bool * td_isstr
Definition: trace.h:516
const int * td_offset
Definition: trace.h:514
struct m0_bufvec data
Definition: di.c:40
static void m0_rc_hook(int rc)
Definition: trace.h:188
void * m0_logbuf
Definition: trace.c:86
const void * tbh_header_addr
Definition: trace.h:365
m0_trace_buf_flags
Definition: trace.h:343
uint64_t * tr_body
Definition: addb2.h:435
char tbh_motr_version[16]
Definition: trace.h:394
uint16_t tbh_buf_flags
Definition: trace.h:380
uint16_t tbh_magic_sym_addresses_nr
Definition: trace.h:417
Definition: sock.c:887
#define M0_TRACE_SUBSYSTEMS
Definition: trace.h:239
uint64_t td_magic
Definition: trace.h:506
char tbh_motr_kernel_ver[128]
Definition: trace.h:398
const char * td_func
Definition: trace.h:508
char tbh_header_area[M0_TRACE_BUF_HEADER_SIZE]
Definition: trace.h:423
unsigned int tbh_module_core_size
Definition: trace.h:409
const void * tbh_module_struct
Definition: trace.h:402
m0_trace_subsystem
Definition: trace.h:291
Definition: trace.h:482
uint64_t trh_sp
Definition: trace.h:441
uint32_t trh_string_data_size
Definition: trace.h:446
M0_INTERNAL int m0_trace_set_print_context(const char *ctx_name)
Definition: trace.c:562
#define UINT16_MAX
Definition: types.h:38
char tbh_motr_git_describe[64]
Definition: trace.h:396
M0_INTERNAL void m0_trace_fini(void)
Definition: trace.c:148
char * fmt(const char *format,...) __attribute__((format(printf
bool td_hasstr
Definition: trace.h:518
const void * tbh_magic_sym_addresses[128]
Definition: trace.h:419
__attribute__((format(printf, 1, 2))) void m0_console_printf(const char *fmt
const char * td_fmt
Definition: trace.h:507
uint64_t tbh_magic
Definition: trace.h:363
char tbh_cli_args[1024]
Definition: trace.h:411
uint32_t trh_record_size
Definition: trace.h:447
struct m0_atomic64 tbh_rec_cnt
Definition: trace.h:387
M0_INTERNAL void m0_trace_record_print(const struct m0_trace_rec_header *trh, const void *buf)
Definition: trace.c:746
const char * td_file
Definition: trace.h:509
M0_INTERNAL void m0_trace_allot(const struct m0_trace_descr *td, const void *body)
Definition: trace.c:225
format
Definition: hist.py:128
const void * tbh_buf_addr
Definition: trace.h:374
const void * tbh_module_core_addr
Definition: trace.h:407
void m0_console_flush(void)
Definition: ktrace.c:165
uint32_t tbh_header_size
Definition: trace.h:372
const void * tbh_magic_sym_addr
Definition: trace.h:392
Definition: trace.h:459
int td_size
Definition: trace.h:512
M0_INTERNAL int m0_trace_set_immediate_mask(const char *mask_str)
Definition: ktrace.c:77
m0_trace_level
Definition: trace.h:454
uint64_t trh_pos
Definition: trace.h:443
const int * td_sizeof
Definition: trace.h:515
M0_BASSERT(M0_TRACE_BUF_FLAGS_MAX< UINT16_MAX)
m0_trace_print_context
Definition: trace.h:496
m0_trace_buf_type
Definition: trace.h:338
static void m0_err_hook(int rc)
Definition: trace.h:190
const struct m0_trace_descr * trh_descr
Definition: trace.h:445
unsigned long m0_trace_immediate_mask
Definition: trace.c:91
M0_INTERNAL int m0_trace_init(void)
Definition: trace.c:132
struct m0_trace_buf_header * m0_logbuf_header
Definition: trace.c:85
uint64_t trh_magic
Definition: trace.h:440
m0_time_t tbh_log_time
Definition: trace.h:400
int32_t rc
Definition: trigger_fop.h:47
uint16_t tbh_buf_type
Definition: trace.h:378
uint64_t trh_no
Definition: trace.h:442
Definition: trace.h:478
M0_INTERNAL int m0_trace_set_level(const char *level_str)
Definition: trace.c:581