From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fe5eccc4fca3fd64 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-25 19:25:32 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!intgwpad.nntp.telstra.net!news.telstra.net!news-server.bigpond.net.au!not-for-mail From: "Greg Bek" Newsgroups: comp.lang.ada References: <%Elx8.52627$WV1.16784880@typhoon.ne.ipsvc.net> Subject: Re: Ada / Motif Binding Question X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Message-ID: Date: Fri, 26 Apr 2002 02:25:31 GMT NNTP-Posting-Host: 144.136.168.109 X-Complaints-To: news@bigpond.net.au X-Trace: news-server.bigpond.net.au 1019787931 144.136.168.109 (Fri, 26 Apr 2002 12:25:31 EST) NNTP-Posting-Date: Fri, 26 Apr 2002 12:25:31 EST Organization: BigPond Internet Services (http://www.bigpond.net.au) Xref: archiver1.google.com comp.lang.ada:23130 Date: 2002-04-26T02:25:31+00:00 List-Id: I recognise Apex code when I see the formatting, so.... At a guess (it's been awhile since I've done this), the storage error is being raise by the callback because the first thing the Exit_Option routine does is a stack check at the top of the routine. At runtime with Apex we usually store the stack limit in a known register, rather than in memory, because the value is referenced frequently, so the code runs faster. But... In this case the code is being called from a non Ada context, so the content of the stack limit register is not guaranteed to be correct, and in fact probably isn't. It works this way because you haven't given the compiler enough information about how the routine is being used. All the compiler can see is a nested routine, which it thinks can only be called from the enclosing Ada scope. To resolve the problem you need to put a pragma Export() on the routine, which forces the complier to generate conservative code because the routine can now be called from anywhere. The procedure prolog will now load the stack limit register from a know location in memory (actually out of the task control block). You may still have a problem as the routine is in a nested local scope. In which case you need to move it in a separately compiled package, as routines in package have static scope. There are many examples that come with the AXI bindings, both standard X as well as MOTIF. I recommend plagiarism as a path to success with GUI programming. Greg Bek ------------------------------------------- Greg Bek mailto:gab@rational.com Product Manager Rational Software, Cupertino CA 95014 Ph: +1 408 863 4394 Fax: + 1 408 863 4180 ------------------------------------------- "Tony Yu" wrote in message news:%Elx8.52627$WV1.16784880@typhoon.ne.ipsvc.net... > Hi, > I recently started using the Motif binding with Ada and had great > difficulty getting the callback functions to work properly. The following > is a small program I created: > > -------------------------------------------------------------------------- -- > -------------------------- > with X_Support.Xt, X_Support.Lib, X_Support.Xm, X_Support.Xm_Defs, > Ada.Text_Io; > > with X_Support.Form, X_Support.Push_Button; > > > > procedure My_Test is > > Appshell : X_Support.Xt.Widget := X_Support.Xt.Null_Widget; > > App_Con : X_Support.Xt.Xt_App_Context; > > Form, Exitbutton : X_Support.Xt.Widget; > > Argc : Natural := 0; > > Argv : X_Support.Xt.Argv_Type; > > procedure My_Proc is > > begin > > Ada.Text_Io.Put_Line ("Hello!"); > > end My_Proc; > > procedure Exit_Option (W : X_Support.Xt.Widget; > > Client_Data : X_Support.Xt.Xt_Pointer; > > Call_Data : X_Support.Xt.Xt_Pointer) is > > My_String : String (1 .. 625) := (others => ' '); > > procedure C_Exit (Status : Integer); > > pragma Import (C, C_Exit, External_Name => "exit"); > > begin > > C_Exit (0); > > end Exit_Option; > > begin > > X_Support.Xt.Xt_Initializers.Xt_App_Initialize > > (App_Context_Return => App_Con, > > Application_Class => "", > > Argc_In_Out => Argc, > > Argv_In_Out => Argv, > > Widget_Id => Appshell); > > Form := X_Support.Xt.Xt_Instance_Management.Xt_Create_Managed_Widget > > ("form", X_Support.Form.Xm_Form_Widget_Class, Appshell); > > Exitbutton := > > X_Support.Xt.Xt_Instance_Management.Xt_Create_Managed_Widget > > (Name => "EXIT", > > Of_Class => X_Support.Push_Button. > > Xm_Push_Button_Widget_Class, > > Parent => Form); > > X_Support.Xt.Xt_Callbacks.Xt_Add_Callback > > (Exitbutton, X_Support.Xm_Defs.Nactivatecallback, > > Exit_Option'Address, X_Support.Xt.Null_Xt_Pointer); > > X_Support.Xt.Xt_Instance_Management.Xt_Realize_Widget (Appshell); > > X_Support.Xt.Xt_Event_Management.Xt_App_Main_Loop (App_Con); > > end My_Test; > > -------------------------------------------------------------------------- -- > -------------------------------------------------------------------------- -- > - > > After invoking the callback, I get the following error: > > -> ** MAIN PROGRAM ABANDONED -- EXCEPTION "STORAGE_ERROR" RAISED > > If I suppress the Storage_Error check, I get the following: > > -> exception_handler: below bottom of user stack > > > > I suspect that the callback procedure is not being allocated enough stack > space for me to declare such a string. I've had similar exceptions when I > perform a Text_Io, or call another procedure/function within the callback > procedure. Oh, I compiled this program using Rational Apex 3.2.0b. Is > there a way to increase the stack size allocated to the callback procedure? > Any help would be appreciated! Thanks in advance! > > -Tony Yu > > P.S. I appologise if this topic has been mentioned before. > > >