+#ifdef DEBUG
+
+#define DBG_USER_STR_CUTOFF 32
+
+/*
+ * In debug mode, print user string (truncated, if necessary).
+ */
+static inline
+void dbg_load_ref_user_str_printk(const struct estack_entry *user_str_reg)
+{
+ size_t pos = 0;
+ char last_char;
+ char user_str[DBG_USER_STR_CUTOFF];
+
+ pagefault_disable();
+ do {
+ last_char = get_char(user_str_reg, pos);
+ user_str[pos] = last_char;
+ pos++;
+ } while (last_char != '\0' && pos < sizeof(user_str));
+ pagefault_enable();
+
+ user_str[sizeof(user_str) - 1] = '\0';
+ dbg_printk("load field ref user string: '%s%s'\n", user_str,
+ last_char != '\0' ? "[...]" : "");
+}
+#else
+static inline
+void dbg_load_ref_user_str_printk(const struct estack_entry *user_str_reg)
+{
+}
+#endif
+