This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH/7.6] Fix wrong release (maybe crash GDB) in build_target_command_list
- From: Hui Zhu <teawater at gmail dot com>
- To: Tom Tromey <tromey at redhat dot com>, Yao Qi <yao at codesourcery dot com>
- Cc: gdb-patches ml <gdb-patches at sourceware dot org>, Joel Brobecker <brobecker at adacore dot com>
- Date: Wed, 24 Apr 2013 23:21:44 +0800
- Subject: Re: [PATCH/7.6] Fix wrong release (maybe crash GDB) in build_target_command_list
- References: <CANFwon0RCwi1CQepWnZuuPvXUNVHXJU-UbknXaR_U3h8shUc8g at mail dot gmail dot com> <87haiwngpr dot fsf at fleche dot redhat dot com>
On Wed, Apr 24, 2013 at 10:30 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Hui" == Hui Zhu <teawater@gmail.com> writes:
>
> Hui> 2013-04-24 Hui Zhu <hui@codesourcery.com>
>
> Hui> * breakpoint.c (build_target_command_list): Change loc->cond_bytecode
> Hui> to loc->cmd_bytecode.
>
> Is it possible to make a test case for this?
I tried but looks free conditions cannot crash GDB. :(
>
> The patch looks good.
>
> I am curious about this code in build_target_command_list:
>
> aexpr = parse_cmd_to_aexpr (bl->address,
> loc->owner->extra_string);
> loc->cmd_bytecode = aexpr;
>
> if (!aexpr)
> continue;
>
> The "continue" seems to mean that null_command_or_parse_error will not
> be set in the "parse error" case.
I think it is right, because even if one of breakpoint loc doesn't
have commands. GDB still need send other commands to target.
>
> Also, parse_cmd_to_aexpr calls 'error' in a few spots but then in
> another spot is careful not to. This seems somewhat odd.
This function looks have something still not right. I am just working
on 15180 to make it better.
On 04/24/2013 09:29 PM, Hui Zhu wrote:
- if (!loc->cond_bytecode)
+ if (!loc->cmd_bytecode)
Nit: "if (loc->cmd_bytecode == NULL)" is better.
Fixed.
Thanks,
Hui
>
> Tom
2013-04-24 Hui Zhu <hui@codesourcery.com>
* breakpoint.c (build_target_command_list): Change loc->cond_bytecode
to loc->cmd_bytecode.
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2343,11 +2343,11 @@ build_target_command_list (struct bp_loc
{
/* Only go as far as the first NULL bytecode is
located. */
- if (!loc->cond_bytecode)
+ if (loc->cmd_bytecode == NULL)
return;
- free_agent_expr (loc->cond_bytecode);
- loc->cond_bytecode = NULL;
+ free_agent_expr (loc->cmd_bytecode);
+ loc->cmd_bytecode = NULL;
}
}
}