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=-0.9 required=5.0 tests=BAYES_00,FROM_NUMERIC_TLD autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,682c6a4dc0495d48 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!newsfeed.stanford.edu!news.kjsl.com!news-peer-lilac.gradwell.net!not-for-mail From: "Stuart" Newsgroups: comp.lang.ada References: Subject: Re: Stackusage at runtime Date: Tue, 4 Nov 2008 15:40:46 -0000 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 Message-ID: <491068b1$1_1@glkas0286.greenlnk.net> X-Original-NNTP-Posting-Host: glkas0286.greenlnk.net NNTP-Posting-Host: 20.133.0.1 X-Trace: 1225813272 news.gradwell.net 499 dnews/20.133.0.1:50070 X-Complaints-To: news-abuse@gradwell.net Xref: g2news2.google.com comp.lang.ada:8296 Date: 2008-11-04T15:40:46+00:00 List-Id: wrote in message news:bf764407-9606-4ee4-aa22-cbb6d00dd84c@d36g2000prf.googlegroups.com... > Is it possible to figure out how much of the stack is used at a > specific moment? > -> Ada95 Crosscompiler to PPC > (It is a little bit hard to optimize the stacksize ...) Compare the value of the stack pointer to its base value! For a PowerPC it is very likely that the code will be conforming to the Embedded Application Binary Interface (EABI), so the stack pointer will be register r1 (aka gpr1). Reading this will require a bit of machine code - either use package machine code or call out to an assembler routine depending on how 'pure' you want to be. Making this a subprogram would allow you to quickly find the stack pointer value anywhere in your program. Depending on what you actually need you might need to make adjustments for the stack frame of the subprogram returning the value (but I would suspect this is quite small and the discrepancy introduced to be of minimal interest if you are optimizing the programme). The base value of the stack is often defined by a symbol (you will need to check your compiler's documentation) though take care as to whether you need the address represented by the symbol or the value at that address (in my experience it is usually the former). As a pedagogical point - the Ada language does not really define what the stack (if any) is used for, so your results may not be universally applicable (but I suspect that is not a significant concern). -- Stuart