Debugging a bitbaked binary

meta-rpm uses groot to build the root file system. Groot will get its own discussion. What I want to talk about here is the steps I used to chase down an error that was happening while generating the root file system. In order to do this, I needed to tweak the groot code.

Groot is pulled in via a recipe in the meta-rpm repo. It is checked out from git, and built as part of the bitbake process.

If you look in the file you will see the git repo URL and commit ID that is used in the build. At the time of this writing, it looks like this:

SRC_URI = "git://;branch=main" 
SRCREV = "3dbae6acbbea1585cf3d2507523f0c91af897447"
S = "${WORKDIR}/git" 
PV = "0.1+git${SRCPV}"

In order to make local changes to groot, I checked it out in a tree parallel to where I have meta-rpm. In order to use this repo in the bitbake process, I need to change the URL to point to this repo. In addition, I can change from having the commit ID in the SRCREV to an instruction to always get the value at the head of the branch. These changes look like this:

SRC_URI = "git:///home/ayoung/devel/groot/;branch=hack;protocol=file"

I created a branch called “hack” and made my changes in there. In order to pick up the changes, I need to commit them to this branch.

Most of my changes are adding debugging trace statements.

[ayoung@zygarde groot]$ git show 464c4d8ecb7cc1dcc87b48a78cedc6f36714beea
commit 464c4d8ecb7cc1dcc87b48a78cedc6f36714beea
Author: Adam Young <>
Date:   Thu Mar 4 15:05:32 2021 -0500
    add hack
diff --git a/grootfs.c b/grootfs.c
index 51e5d5c..7a16256 100644
--- a/grootfs.c
+++ b/grootfs.c
@@ -39,6 +39,24 @@
 #include <sys/types.h>
 #include <sys/xattr.h>
+#include <stdarg.h>
+hack (const char *format, ...)
+  va_list args;
+  fprintf (stderr, "groot: ");
+  va_start (args, format);
+  vfprintf (stderr, format, args);
+  va_end (args);
+  fprintf (stderr, "\n");
 typedef struct {
   int basefd;
   long max_uid;
@@ -986,8 +1004,10 @@ grootfs_listxattr (const char *path, char *list, size_t size)
   autofree char *basename = NULL;
   autofd int dirfd = open_parent_dirfd (path, &basename);
-  if (dirfd < 0)
+  if (dirfd < 0){
     return dirfd;
+    hack("Nope");
+  }
   autofree char *proc_file = get_proc_fd_path (dirfd, basename);
   char buf_data[4096];

Even though groot has a trace statement, I added an additional one here. Why? The original one was tracing unrelated code that returned the word “Error:” that was stopping the bitbake process, and I did not want to debug that. This is throw away code just to discover the root cause of a problem.

With these changes in, I can see the results of building in the bitbake output.

$ bitbake centos8-test-image
| groot: Yep security.capability
| groot: end size = 19
| groot: input size = 19
| set_inode_xattr: Input/output error while listing attributes of "newgidmap"

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.