This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix execution_direction's type
- From: Pedro Alves <palves at redhat dot com>
- To: Simon Marchi <simon dot marchi at ericsson dot com>, gdb-patches at sourceware dot org
- Date: Fri, 09 Oct 2015 18:26:49 +0100
- Subject: Re: [PATCH] Fix execution_direction's type
- Authentication-results: sourceware.org; auth=none
- References: <1444404887-10192-1-git-send-email-palves at redhat dot com> <5617F611 dot 4060301 at ericsson dot com>
On 10/09/2015 06:14 PM, Simon Marchi wrote:
> On 15-10-09 11:34 AM, Pedro Alves wrote:
>> @@ -3817,6 +3828,7 @@ fetch_inferior_event (void *client_data)
>> struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
>> struct cleanup *ts_old_chain;
>> int was_sync = sync_execution;
>> + enum exec_direction_kind save_exec_dir = execution_direction;
>> int cmd_done = 0;
>> ptid_t waiton_ptid = minus_one_ptid;
>>
>> @@ -3849,7 +3861,7 @@ fetch_inferior_event (void *client_data)
>> event. */
>> target_dcache_invalidate ();
>>
>> - make_cleanup_restore_integer (&execution_direction);
>> + make_cleanup (restore_execution_direction, &save_exec_dir);
>> execution_direction = target_execution_direction ();
>>
>> ecs->ptid = do_target_wait (waiton_ptid, &ecs->ws,
>
> Isn't it dangerous to record a cleanup with a pointer to a local variable?
>
> What if something throws the exception is caught in a parent frame? The
> content of the memory location pointed by the cleanup will be undefined
> at that time, won't it?
No, the cleanups are run _before_ the throwing scope is left (that is,
before longjmp), from within throw_exception.
Thanks,
Pedro Alves