|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 4/8] lib/ukdebug: key-value static storage for tracing
One more 'special' stripable section. Will contain strings in format
key = value. Currently only tracebuffer format version is stored there.
Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
---
lib/ukdebug/extra.ld | 3 +++
lib/ukdebug/trace.c | 18 ++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/lib/ukdebug/extra.ld b/lib/ukdebug/extra.ld
index 43154f9d..bb0b36b8 100644
--- a/lib/ukdebug/extra.ld
+++ b/lib/ukdebug/extra.ld
@@ -5,6 +5,9 @@ SECTIONS
KEEP (*(.uk_tracepoints_list));
uk_tracepoints_end = .;
}
+ .uk_trace_keyvals : {
+ KEEP (*(.uk_trace_keyvals));
+ }
}
/* We do not want these section to be in the final image, they are
diff --git a/lib/ukdebug/trace.c b/lib/ukdebug/trace.c
index f3318557..91cc2387 100644
--- a/lib/ukdebug/trace.c
+++ b/lib/ukdebug/trace.c
@@ -43,3 +43,21 @@ char uk_trace_buffer[UK_TRACE_BUFFER_SIZE];
size_t uk_trace_buffer_free = UK_TRACE_BUFFER_SIZE;
char *uk_trace_buffer_writep = uk_trace_buffer;
+
+
+/* Store a string in format "key = value" in the section
+ * .uk_trace_keyvals. This can be anything what you want trace.py
+ * script to know about, and what you do not want to consume any space
+ * in runtime memory.
+ *
+ * This section will be stripped at the final states of building, but
+ * the key-value data can be easily extracted by:
+ *
+ * $ readelf -p .uk_trace_keyvals <your_image.gdb>
+ */
+#define TRACE_DEFINE_KEY(key, val) \
+ __attribute((__section__(".uk_trace_keyvals"))) \
+ static const char key[] __used = \
+ #key " = " #val
+
+TRACE_DEFINE_KEY(format_version, 1);
--
2.19.2
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |