This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA 3/3] Avoid duplicating text in sol-thread.c:info_cb
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Cc: Pedro Alves <palves at redhat dot com>, Joel Brobecker <brobecker at adacore dot com>
- Date: Tue, 7 May 2013 08:25:32 -0400
- Subject: [RFA 3/3] Avoid duplicating text in sol-thread.c:info_cb
- References: <518284AF dot 5090802 at redhat dot com>
This is a minor cleanup that helps avoiding duplicating the output
of a command when handling alternative situations.
gdb/ChangeLog:
* sol-thread.c (info_cb): Factorize the code a little.
Same as patch #2, I could probably self-approve, but there could be
merit in the current approach if the output was thought to one day
become different depending on some (future) factors...
---
gdb/sol-thread.c | 20 ++++++++------------
1 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index fb89723..a17a55b 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -1176,12 +1176,10 @@ info_cb (const td_thrhandle_t *th, void *s)
const struct bound_minimal_symbol msym
= lookup_minimal_symbol_by_pc (ti.ti_startfunc);
- if (msym.minsym)
- printf_filtered (" startfunc=%s",
- SYMBOL_PRINT_NAME (msym.minsym));
- else
- printf_filtered (" startfunc=%s",
- paddress (target_gdbarch (), ti.ti_startfunc));
+ printf_filtered (" startfunc=%s",
+ msym.minsym
+ ? SYMBOL_PRINT_NAME (msym.minsym)
+ : paddress (target_gdbarch (), ti.ti_startfunc));
}
/* If thread is asleep, print function that went to sleep. */
@@ -1190,12 +1188,10 @@ info_cb (const td_thrhandle_t *th, void *s)
const struct bound_minimal_symbol msym
= lookup_minimal_symbol_by_pc (ti.ti_pc);
- if (msym.minsym)
- printf_filtered (" sleepfunc=%s",
- SYMBOL_PRINT_NAME (msym.minsym));
- else
- printf_filtered (" sleepfunc=%s",
- paddress (target_gdbarch (), ti.ti_pc));
+ printf_filtered (" sleepfunc=%s",
+ msym.minsym
+ ? SYMBOL_PRINT_NAME (msym.minsym)
+ : paddress (target_gdbarch (), ti.ti_pc));
}
printf_filtered ("\n");
--
1.7.0.4