Am Monday 26 October 2015, 08:26:57 schrieb Joel Sherrill:
> Hi
> 
> I am on travel this week but I thought we had this problem
> solved. I poked on a build server I used but can't find
> the change and it doesn't look to be committed.
> 

Yes, it was me back then too ;-)
I have been occupied the last months.

> The issue was that the contents of read_attr_t has changed
> and the Ada definition of the same structure needs to be
> updated. This is defined in pthread.h in newlib or an
> installed tools. The Ada version is in
> gcc/ada/s-osinte-rtems.ads.
> 
> Currently the Ada version is smaller than the C version
> and it is just luck that something important isn't
> overwritten and we get a simple crash.
> 
> The other pthread_*_attr_t structures should be double
> checked as well.
> 

Yes, I already have that change locally in newlib, it solves the stack 
corruption issue, but the program still fails to run properly.
With the gnatD-option Arnaud suggested I figured the following today:

Complete_Master is called from finalizer of the procedure Hello. At the start 
it calls STPO.Self to get the id of the current task. It should be the id of 
the Ada-main task, but it's the id of the subordinate hello_task.
Then, of course, Complete_Master does not work properly.  rtems STPO.Self 
essentially calls rtems_task_self(). So either this function returns wrong ids 
or the context switch is not handled properly.
The gnat-rts uses the posix-API, but rtems_task_self is from the classic API. 
Could it produce problems if one mixes them?

For testing I added a 2nd task to the example and printed the result of 
STPO.Self at several places of the program. Depending on the order of 
declaration of the tasks I got different results, but never the right ones.
Tomorrow I will take a rtems-posix-example and see if I get proper ids if I 
call rtems_task_self from within the posix-threads.

@Arnaud: I saw quite a lot of #pragma Debug-lines in the rts-code. Is there a 
simple way of activating them without having to recompile gnat?

Best regards,

    Jan

> --joel sherrill
> 
> On 10/25/2015 12:59 PM, Arnaud Charlet wrote:
> >>>> I would like to know from where Complete_Master is called to break there
> >>>> and
> >>>> find out why it uses the wrong id.
> >>>
> >>> Why don't you simply put a breakpoint on Complete_Master?
> >>
> >> That's how I found out about the wrong/weird Self_Id.
> >
> > Then you should also get a backtrace which will give you extra info.
> >
> >>> You can also build hello.adb with the -gnatD switch to debug at the code
> >>> expansion level where you'll see the call to Complete_Master.
> >>>
> >>
> >> Thank you, that option helps a lot. Will check out the generated code
> >> tomorrow.
> >
> > Glad to hear it.
> >
> > Arno
> >

Reply via email to