[PATCH] core: Add sub-system level logging support only for debugging

7 views
Skip to first unread message

hcha...@xvisor-x86.org

unread,
Jun 3, 2022, 10:27:12 AM6/3/22
to xvisor...@googlegroups.com, Himanshu Chauhan
From: Himanshu Chauhan <hcha...@xvisor-x86.org>

This patch adds a sub-system level logging support for debuggin.
A sub-system level log can be defined using
DEFINE_VMM_DEBUG_LOG_SUBSYS_LEVEL(<subsystem>, <log_level>)

Further logs can be printed
VMM_DEBUG_LOG(<subsystem>, <log_level>, ...)

This way we can control logging at the sub-system level. Only a
specific sub-system logging can be enabled when required. This
can save clutter.

Signed-off-by: Himanshu Chauhan <hcha...@xvisor-x86.org>
---
core/include/vmm_debug_log.h | 59 ++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 core/include/vmm_debug_log.h

diff --git a/core/include/vmm_debug_log.h b/core/include/vmm_debug_log.h
new file mode 100644
index 00000000..1315be7b
--- /dev/null
+++ b/core/include/vmm_debug_log.h
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2022 Himanshu Chauhan.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * @file vmm_debug_log.h
+ * @author Himanshu Chauhan (hcha...@xvisor-x86.org)
+ * @brief Header file for addings logs for debugging.
+ *
+ * This is different then STDIO logging facilities. This debug log
+ * facility can be used sub-system wise where each subsystem can
+ * have a different log level. This can stop the clutter printed
+ * on console when all subsystem use the same log levels.
+ *
+ * TODO: Make this a wrapper to vmm_stdio logging so that color
+ * coding can be used, if required.
+ */
+
+#ifndef __VMM_DEBUG_LOG_H
+#define __VMM_DEBUG_LOG_H
+
+enum {
+ VMM_DEBUG_LOG_LVL_ERR,
+ VMM_DEBUG_LOG_LVL_INFO,
+ VMM_DEBUG_LOG_LVL_DEBUG,
+ VMM_DEBUG_LOG_LVL_VERBOSE
+};
+
+#define DECLARE_VMM_DEBUG_LOG_SUBSYS_LEVEL(subsys) \
+ int vmm_debug_ ## subsys ## _log_lvl
+
+#define DEFINE_VMM_DEBUG_LOG_SUBSYS_LEVEL(subsys, lvl) \
+ DECLARE_VMM_DEBUG_LOG_SUBSYS_LEVEL(subsys) __read_mostly = lvl
+
+#define VMM_DEBUG_LOG_SUBSYS_LEVEL(subsys) \
+ vmm_debug_##subsys##_log_lvl
+
+#define VMM_DEBUG_LOG(subsys, lvl, fmt, args...) \
+ do { \
+ extern DECLARE_VMM_DEBUG_LOG_SUBSYS_LEVEL(subsys); \
+ if (VMM_DEBUG_LOG_ ## lvl <= VMM_DEBUG_LOG_SUBSYS_LEVEL(subsys)) { \
+ vmm_printf(fmt, ##args); \
+ } \
+ } while(0);
+
+#endif
--
2.34.1

Himanshu Chauhan

unread,
Jun 5, 2022, 12:21:51 PM6/5/22
to xvisor...@googlegroups.com
Retracting this and the next patch. Moving to x86 code only.
Reply all
Reply to author
Forward
0 new messages