From: Olivier Hainque <[email protected]>

A null "pc" return address in the Unwind_Backtrace callback
normally means that unwinding has reached the top of the call
chain. Or something else, abnormal. Recognize this early as a
stop condition, which makes sure we don't accidentally add an
entry for it after applying possible offsets.

gcc/ada/ChangeLog:

        * tracebak.c (trace_callback): Return early for pc == 0;

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/tracebak.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/ada/tracebak.c b/gcc/ada/tracebak.c
index 2c80b2a1610..709322ad13d 100644
--- a/gcc/ada/tracebak.c
+++ b/gcc/ada/tracebak.c
@@ -655,6 +655,10 @@ trace_callback (struct _Unwind_Context * uw_context, 
uw_data_t * uw_data)
   pc = (char *) _Unwind_GetIP (uw_context);
 #endif
 
+  /* Common case of top-of-call-chain reached.  */
+  if (pc == (char *)0)
+    return _URC_NORMAL_STOP;
+
   if (uw_data->n_frames_skipped < uw_data->n_frames_to_skip)
     {
       uw_data->n_frames_skipped ++;
-- 
2.53.0

Reply via email to