Re: [PATCH/7.6] Fix wrong release (maybe crash GDB) in build_target_command_list

Hui Zhu
2013-04-24T15:22:26Z

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;
}
}
}