[PATCH 3/3] Assert 'printf_line' is non-null.
Yao Qi
yao@codesourcery.com
Wed Dec 12 04:13:00 GMT 2012
As we can see the code above, printf_line is always assigned to
a non-null string, so this patch removes the check on
'printf_line' and add an assert.
On the other hand, 'breakpoint_set_commands' will be called
unconditionally, and B->commands is non-null (B is a dprintf).
gdb:
2012-12-12 Yao Qi <yao@codesourcery.com>
* breakpoint.c (update_dprintf_command_list): Assert that
'printf_line' is non-null. Remove condition check.
---
gdb/breakpoint.c | 40 ++++++++++++++++++++--------------------
1 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 65bdc2c..ab056d4 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -8865,30 +8865,30 @@ update_dprintf_command_list (struct breakpoint *b)
internal_error (__FILE__, __LINE__,
_("Invalid dprintf style."));
+ gdb_assert (printf_line != NULL);
/* Manufacture a printf/continue sequence. */
- if (printf_line)
- {
- struct command_line *printf_cmd_line, *cont_cmd_line = NULL;
+ {
+ struct command_line *printf_cmd_line, *cont_cmd_line = NULL;
- if (strcmp (dprintf_style, dprintf_style_agent) != 0)
- {
- cont_cmd_line = xmalloc (sizeof (struct command_line));
- cont_cmd_line->control_type = simple_control;
- cont_cmd_line->body_count = 0;
- cont_cmd_line->body_list = NULL;
- cont_cmd_line->next = NULL;
- cont_cmd_line->line = xstrdup ("continue");
- }
+ if (strcmp (dprintf_style, dprintf_style_agent) != 0)
+ {
+ cont_cmd_line = xmalloc (sizeof (struct command_line));
+ cont_cmd_line->control_type = simple_control;
+ cont_cmd_line->body_count = 0;
+ cont_cmd_line->body_list = NULL;
+ cont_cmd_line->next = NULL;
+ cont_cmd_line->line = xstrdup ("continue");
+ }
- printf_cmd_line = xmalloc (sizeof (struct command_line));
- printf_cmd_line->control_type = simple_control;
- printf_cmd_line->body_count = 0;
- printf_cmd_line->body_list = NULL;
- printf_cmd_line->next = cont_cmd_line;
- printf_cmd_line->line = printf_line;
+ printf_cmd_line = xmalloc (sizeof (struct command_line));
+ printf_cmd_line->control_type = simple_control;
+ printf_cmd_line->body_count = 0;
+ printf_cmd_line->body_list = NULL;
+ printf_cmd_line->next = cont_cmd_line;
+ printf_cmd_line->line = printf_line;
- breakpoint_set_commands (b, printf_cmd_line);
- }
+ breakpoint_set_commands (b, printf_cmd_line);
+ }
}
/* Update all dprintf commands, making their command lists reflect
--
1.7.7.6
More information about the Gdb-patches
mailing list