This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/4] Teach arm unwinders to terminate gracefully
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Yao Qi <qiyaoltc at gmail dot com>, Antoine Tremblay <antoine dot tremblay at ericsson dot com>, gdb-patches at sourceware dot org
- Date: Wed, 06 Apr 2016 16:54:24 +0100
- Subject: Re: [PATCH 1/4] Teach arm unwinders to terminate gracefully
- Authentication-results: sourceware.org; auth=none
- References: <1452188697-23870-1-git-send-email-antoine dot tremblay at ericsson dot com> <1452188697-23870-2-git-send-email-antoine dot tremblay at ericsson dot com> <86io1ung0a dot fsf at gmail dot com> <56CEE928 dot 2080704 at redhat dot com>
Pedro Alves <palves@redhat.com> writes:
Hi Pedro,
> I think it'd work to have an ultimate-fallback unwinder that
> frame_unwind_find_by_frame returns instead of the internal error at
> the end. This would return UNWIND_UNAVAILABLE or UNWIND_MEMORY_ERROR
> in the unwinder->stop_reason method, depending on the error the last registered
> unwinder thrown. (That last unwinder will always be the arch's heuristic unwinder.)
> And it would return frame_id_build_unavailable_stack(PC) in the unwinder->this_id
> method if the last error was UNWIND_UNAVAILABLE, outer_frame_id otherwise
> (or we add a new frame_id_build_stackless function, to go along with
> frame_id_build_unavailable_stack).
I write some code to implement your suggestion here, and it looks OK
except that I can't get PC to pass to frame_id_build_unavailable_stack,
since PC is extracted from frame cache which varies on different archs
and unwinders.
I tried to define a super class frame_cache for various frame cache
(nowadays, it is defined as void *), frame_cache has one field PC, and
various frame caches are the sub class of frame_cache. Many frame
unwinding APIs need update, and many places need update too, as a
result. I stop here as I am not sure it is a right approach.
However, I think we can still do the change you suggested, but in a
smaller scope, so the change is less aggressive, and some progress can
be made, like this,
- Add an unavailable frame unwinder for gdbarch A which supports
tracepoint, as the ultimate-fallback.
- For the unwinders in gdbarch A, move the code creating frame cache to
the sniffer. If the sniffer accepts the frame, creates the frame cache.
- Exceptions are allowed to be thrown out in frame cache creation.
The exception is caught in the caller of sniffer
(frame_unwind_try_unwinder) today, so if exception is thrown, GDB
will try the next unwinder,
- In this way, only 'sniffer' in 'frame_unwind' may throw exception, so
we don't have to worry about other 'frame_unwind' methods. IOW, all
unwinders in gdbarch A except unavailable frame unwinder don't worry
about the unavailable memory/register.
- the unavailable frame unwinder is the last unwinder for gdbarch A, it
knows how/where to get PC, if PC is available, return
frame_id_build_unavailable_stack (PC), otherwise return outer_frame_id.
In this way, the change will be smaller, and we can apply this change to
each gdbarch one by one, and in the future, it is possible to have a
single gdbarch-independent unavailable frame unwinder once we figure out
how to get PC from various frame caches.
--
Yao (éå)