All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Miscellaneous changes to aid in troubleshooting
@ 2021-03-20  3:06 Glenn Washburn
  2021-03-20  3:06 ` [PATCH 1/4] error: Add grub_errno to printed error message Glenn Washburn
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Glenn Washburn @ 2021-03-20  3:06 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn

These are pretty self-explanatory. They've been useful in debugging grub
issues. Note that patch #2 and #3 are particularly synergistic.

Also a note about patch #4. It was used in a version of patch #3, though not
any more. I decided to leave it in this patch series because it enhances
grub_strword without any downsides (that I'm aware of).

Glenn

Glenn Washburn (4):
  error: Add grub_errno to printed error message
  misc: Add debug log condition to log output
  misc: Allow selective disabling of debug conditionals
  misc: Change grub_strword to return a string like grub_strstr

 grub-core/kern/err.c   |  2 +-
 grub-core/kern/misc.c  | 22 +++++++++++++++++-----
 grub-core/loader/xnu.c |  7 ++++---
 include/grub/misc.h    |  2 +-
 4 files changed, 23 insertions(+), 10 deletions(-)

-- 
2.27.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] error: Add grub_errno to printed error message
  2021-03-20  3:06 [PATCH 0/4] Miscellaneous changes to aid in troubleshooting Glenn Washburn
@ 2021-03-20  3:06 ` Glenn Washburn
  2021-03-20  3:06 ` [PATCH 2/4] misc: Add debug log condition to log output Glenn Washburn
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Glenn Washburn @ 2021-03-20  3:06 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 grub-core/kern/err.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-core/kern/err.c b/grub-core/kern/err.c
index 53c734de7..a12fda48b 100644
--- a/grub-core/kern/err.c
+++ b/grub-core/kern/err.c
@@ -107,7 +107,7 @@ grub_print_error (void)
     {
       if (grub_errno != GRUB_ERR_NONE)
 	{
-	  grub_err_printf (_("error: %s.\n"), grub_errmsg);
+	  grub_err_printf (_("error: [%d] %s.\n"), grub_errno, grub_errmsg);
 	  grub_err_printed_errors++;
 	}
     }
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] misc: Add debug log condition to log output
  2021-03-20  3:06 [PATCH 0/4] Miscellaneous changes to aid in troubleshooting Glenn Washburn
  2021-03-20  3:06 ` [PATCH 1/4] error: Add grub_errno to printed error message Glenn Washburn
@ 2021-03-20  3:06 ` Glenn Washburn
  2021-03-20  3:06 ` [PATCH 3/4] misc: Allow selective disabling of debug conditionals Glenn Washburn
  2021-03-20  3:06 ` [PATCH 4/4] misc: Change grub_strword to return a string like grub_strstr Glenn Washburn
  3 siblings, 0 replies; 5+ messages in thread
From: Glenn Washburn @ 2021-03-20  3:06 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn

When debugging using the "all" condition frequently gives way too much info.
So selecting a subset of conditions is desirable. This change makes it
easier to identify which conditions are desired. Before this change log
messages needed to be looked up in the source code to find the condition
used.

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 grub-core/kern/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index 3af336ee2..11b8592c8 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -182,7 +182,7 @@ grub_real_dprintf (const char *file, const int line, const char *condition,
 
   if (grub_debug_enabled (condition))
     {
-      grub_printf ("%s:%d: ", file, line);
+      grub_printf ("%s:%d:%s: ", file, line, condition);
       va_start (args, fmt);
       grub_vprintf (fmt, args);
       va_end (args);
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] misc: Allow selective disabling of debug conditionals
  2021-03-20  3:06 [PATCH 0/4] Miscellaneous changes to aid in troubleshooting Glenn Washburn
  2021-03-20  3:06 ` [PATCH 1/4] error: Add grub_errno to printed error message Glenn Washburn
  2021-03-20  3:06 ` [PATCH 2/4] misc: Add debug log condition to log output Glenn Washburn
@ 2021-03-20  3:06 ` Glenn Washburn
  2021-03-20  3:06 ` [PATCH 4/4] misc: Change grub_strword to return a string like grub_strstr Glenn Washburn
  3 siblings, 0 replies; 5+ messages in thread
From: Glenn Washburn @ 2021-03-20  3:06 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn

Sometimes you know only know which debug logging conditionals you want to
turn off.  Now debug log messages can be excluded by specifying the
conditional in the $debug string with a prepended dash.  So say you want
all debug logging on except for btrfs and scripting, then set
debug=all,-btrfs,-scripting.

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 grub-core/kern/misc.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index 11b8592c8..73563b59b 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -168,7 +168,19 @@ grub_debug_enabled (const char * condition)
   if (!debug)
     return 0;
 
-  if (grub_strword (debug, "all") || grub_strword (debug, condition))
+  if (grub_strword (debug, "all"))
+    {
+      if (debug[3] == '\0')
+          return 1;
+      const char *ptr = NULL;
+      ptr = grub_strstr (debug, condition);
+      if (ptr > debug && *(ptr-1) == '-'
+	  && (*(ptr + grub_strlen (condition)) == '\0'
+	      || grub_iswordseparator (*(ptr + grub_strlen (condition)))))
+	return 0;
+      return 1;
+    }
+  else if (grub_strword (debug, condition))
     return 1;
 
   return 0;
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] misc: Change grub_strword to return a string like grub_strstr
  2021-03-20  3:06 [PATCH 0/4] Miscellaneous changes to aid in troubleshooting Glenn Washburn
                   ` (2 preceding siblings ...)
  2021-03-20  3:06 ` [PATCH 3/4] misc: Allow selective disabling of debug conditionals Glenn Washburn
@ 2021-03-20  3:06 ` Glenn Washburn
  3 siblings, 0 replies; 5+ messages in thread
From: Glenn Washburn @ 2021-03-20  3:06 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn

This makes grub_strword more versatile. All code as of this change using
grub_strword uses it in a conditional or boolean operator context where its
return value would be silently converted to a 1 or 0, so this does not
affect current usage. A few lines in loader/xnu.c have been changed to
enhance clarity there.

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 grub-core/kern/misc.c  | 6 +++---
 grub-core/loader/xnu.c | 7 ++++---
 include/grub/misc.h    | 2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index 73563b59b..31f169291 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -320,7 +320,7 @@ grub_strrchr (const char *s, int c)
   return p;
 }
 
-int
+char *
 grub_strword (const char *haystack, const char *needle)
 {
   const char *n_pos = needle;
@@ -343,7 +343,7 @@ grub_strword (const char *haystack, const char *needle)
       next word (or the end of string) and "reset" the needle.  */
       if ( (!*haystack || grub_iswordseparator (*haystack))
          && (!*n_pos || grub_iswordseparator (*n_pos)))
-        return 1;
+        return (char *)(haystack - (n_pos - needle));
       else
         {
           n_pos = needle;
@@ -354,7 +354,7 @@ grub_strword (const char *haystack, const char *needle)
         }
     }
 
-  return 0;
+  return NULL;
 }
 
 int
diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c
index 1c0cf6a43..ce35600d9 100644
--- a/grub-core/loader/xnu.c
+++ b/grub-core/loader/xnu.c
@@ -975,7 +975,8 @@ grub_xnu_check_os_bundle_required (char *plistname,
 
   /* Set the return value for the case when no OSBundleRequired tag is found. */
   if (osbundlereq)
-    ret = grub_strword (osbundlereq, "all") || grub_strword (osbundlereq, "-");
+    ret = grub_strword (osbundlereq, "all") != 0
+      || grub_strword (osbundlereq, "-") != 0;
   else
     ret = 1;
 
@@ -996,8 +997,8 @@ grub_xnu_check_os_bundle_required (char *plistname,
 	  {
 	    for (ptr2 = stringptr; *ptr2; ptr2++)
 	      *ptr2 = grub_tolower (*ptr2);
-	    ret = grub_strword (osbundlereq, stringptr)
-	      || grub_strword (osbundlereq, "all");
+	    ret = grub_strword (osbundlereq, stringptr) != 0
+	      || grub_strword (osbundlereq, "all") != 0;
 	  }
 	if (stringptr && binnamekeyfound && binname && depth == 4)
 	  {
diff --git a/include/grub/misc.h b/include/grub/misc.h
index 7d2b55196..c2cbc8f5d 100644
--- a/include/grub/misc.h
+++ b/include/grub/misc.h
@@ -85,7 +85,7 @@ int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n);
 
 char *EXPORT_FUNC(grub_strchr) (const char *s, int c);
 char *EXPORT_FUNC(grub_strrchr) (const char *s, int c);
-int EXPORT_FUNC(grub_strword) (const char *s, const char *w);
+char *EXPORT_FUNC(grub_strword) (const char *s, const char *w);
 
 /* Copied from gnulib.
    Written by Bruno Haible <bruno@clisp.org>, 2005. */
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-20  3:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-20  3:06 [PATCH 0/4] Miscellaneous changes to aid in troubleshooting Glenn Washburn
2021-03-20  3:06 ` [PATCH 1/4] error: Add grub_errno to printed error message Glenn Washburn
2021-03-20  3:06 ` [PATCH 2/4] misc: Add debug log condition to log output Glenn Washburn
2021-03-20  3:06 ` [PATCH 3/4] misc: Allow selective disabling of debug conditionals Glenn Washburn
2021-03-20  3:06 ` [PATCH 4/4] misc: Change grub_strword to return a string like grub_strstr Glenn Washburn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.