Skip to contentSkip to conversation

binder: log transaction code on failure

PATCH Superseded Carlos Llamas 2 participants 5 messages Jan 10, 2025 Android drivers

lore
Share & tools
lore

Carlos Llamas

author maintainer
#0 lore raw

PATCH 1/1 binder: log transaction code on failure

When a transaction fails, log the 'tr->code' to help indentify the problematic userspace call path. This additional information will simplify debugging efforts.

Cc Steven Moreland <[email protected]>
---
 drivers/android/binder.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/android/binder.c +2 -2
index ef353ca13c35..cb4187a4e595 100644
@@ -3801,13 +3801,13 @@ static void binder_transaction(struct binder_proc *proc,
 	}
 
 	binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
-		     "%d:%d transaction %s to %d:%d failed %d/%d/%d, size %lld-%lld line %d\n",
+		     "%d:%d transaction %s to %d:%d failed %d/%d/%d, code %d size %lld-%lld line %d\n",
 		     proc->pid, thread->pid, reply ? "reply" :
 		     (tr->flags & TF_ONE_WAY ? "async" : "call"),
 		     target_proc ? target_proc->pid : 0,
 		     target_thread ? target_thread->pid : 0,
 		     t_debug_id, return_error, return_error_param,
-		     (u64)tr->data_size, (u64)tr->offsets_size,
+		     tr->code, (u64)tr->data_size, (u64)tr->offsets_size,
 		     return_error_line);
 
 	if (target_thread)
Signature · 1 line
2.47.1.613.gc27f4b7a9f-goog
maintainer
#1 lore raw
Quoted 16 lines · Carlos Llamas

When a transaction fails, log the 'tr->code' to help indentify the problematic userspace call path. This additional information will simplify debugging efforts.

Cc Steven Moreland <[email protected]>
---
 drivers/android/binder.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/android/binder.c +0 -0
index ef353ca13c35..cb4187a4e595 100644

drivers/android/binder.c static void binder_transaction(struct binder_proc *proc, · line 3804

Quoted 5 lines
drivers/android/binder.c +1 -1
@@ -3801,13 +3801,13 @@ static void binder_transaction(struct binder_proc *proc,
        }
 
        binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
-                    "%d:%d transaction %s to %d:%d failed %d/%d/%d, size %lld-%lld line %d\n",
+                    "%d:%d transaction %s to %d:%d failed %d/%d/%d, code %d size %lld-%lld line %d\n",

Shouldn't this by %u instead?

Alice

author maintainer
#2 lore raw
Quoted 19 lines · Alice Ryhl
Quoted 18 lines · Carlos Llamas

When a transaction fails, log the 'tr->code' to help indentify the problematic userspace call path. This additional information will simplify debugging efforts.

Cc Steven Moreland <[email protected]>
---
 drivers/android/binder.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/android/binder.c +0 -0
index ef353ca13c35..cb4187a4e595 100644
@@ -3801,13 +3801,13 @@ static void binder_transaction(struct binder_proc *proc,
        }
 
Quoted 5 lines

drivers/android/binder.c static void binder_transaction(struct binder_proc *proc, · line 3804

Quoted 3 lines
drivers/android/binder.c +1 -1
        binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
-                    "%d:%d transaction %s to %d:%d failed %d/%d/%d, size %lld-%lld line %d\n",
+                    "%d:%d transaction %s to %d:%d failed %d/%d/%d, code %d size %lld-%lld line %d\n",

Shouldn't this by %u instead?

Yes, with tr->code being u32 it technically should use %u. I'll send a new version. Thanks!

author maintainer
#3 lore raw

PATCH v2 1/1 binder: log transaction code on failure

In reply to Alice Ryhl

When a transaction fails, log the 'tr->code' to help indentify the problematic userspace call path. This additional information will simplify debugging efforts.

Cc Steven Moreland <[email protected]>

---

Notes:
v2: use %u format specifier per Alice's feedback

 drivers/android/binder.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/android/binder.c +2 -2
index ef353ca13c35..45c70644aee5 100644
@@ -3801,13 +3801,13 @@ static void binder_transaction(struct binder_proc *proc,
 	}
 
 	binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
-		     "%d:%d transaction %s to %d:%d failed %d/%d/%d, size %lld-%lld line %d\n",
+		     "%d:%d transaction %s to %d:%d failed %d/%d/%d, code %u size %lld-%lld line %d\n",
 		     proc->pid, thread->pid, reply ? "reply" :
 		     (tr->flags & TF_ONE_WAY ? "async" : "call"),
 		     target_proc ? target_proc->pid : 0,
 		     target_thread ? target_thread->pid : 0,
 		     t_debug_id, return_error, return_error_param,
-		     (u64)tr->data_size, (u64)tr->offsets_size,
+		     tr->code, (u64)tr->data_size, (u64)tr->offsets_size,
 		     return_error_line);
 
 	if (target_thread)
Signature · 1 line
2.47.1.613.gc27f4b7a9f-goog