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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5978c98b23dbfa0b X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.213.99 with SMTP id nr3mr5844020pbc.2.1324496777981; Wed, 21 Dec 2011 11:46:17 -0800 (PST) Path: lh20ni48986pbb.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Debugging Ada Date: Wed, 21 Dec 2011 20:46:16 +0100 Organization: A noiseless patient Spider Message-ID: <87zkelvhbr.fsf@ludovic-brenta.org> References: <4b7ed906-dfbb-4f73-826e-f1c94ec320e7@k10g2000yqk.googlegroups.com> <5567da15-bd12-4dee-be27-b98525ea1323@x19g2000yqf.googlegroups.com> <1fcdb3e7-6125-4cdc-9514-dd3cff2a7350@h3g2000yqa.googlegroups.com> <0892748e-8943-41e3-8843-9121838b4465@f33g2000yqh.googlegroups.com> <56da68a5-1d00-4ec7-863b-c9a2a7a64f95@l19g2000yqc.googlegroups.com> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="mnicikp1ChhOotoChjSKKA"; logging-data="31709"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18GXYsPqk8R4xgOXFRe//jH" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:Od3Aijy6oFc6mhhKAkyxJpR4L6c= sha1:e28lvl2OwMXVEJiXjED0nrWsnq4= Content-Type: text/plain; charset=us-ascii Date: 2011-12-21T20:46:16+01:00 List-Id: awdorrin writes: > Ah, I see what you are saying. I don't think that is what is going on > in this situation. > > The code I'm working with is a mix of Ada and C, and it was originally > written under Ada83. > > The 'SysConfig' package is importing a C character array: > char g_cfg_file_names[100][128]; (up to 100 file names, 128 > characters each) > as: > pragma Import( C, CFG_FILES, "g_cfg_file_names"); > > LAN_CFG is part of an enumeration defined in the SysConfig package to > map to the index numbers of that array. OK, I think I understand the problem better too. Your initial description of the problem was: > Then in the package's main procedure when I try to use the > LAN_CFG_FILE, sometimes the value is corrupted. I'm beginning to think that perhaps the elaboration order varies between compilations. The pragma Import (C, CFG_FILES, "g_cfg_file_names") indicates that: - the Ada language rules require that g_cfg_file_names is elaborated before LAN_CFG_FILE - the Ada compiler cannot enforce this rule, so it simply assumes that the rule is followed - the C compiler must emit code that elaborates *and* initializes g_cfg_file_names. It is possible that what you see as "corrupted" is simply an uninitialized value. - the binder must emit code that calls the C initialization routine *before* the elaboration of LAN_CFG_FILE Maybe you should inspect the binder-generated file (b~*.adb) to see what happens. It is this file that does the elaboration, so it is fairly easy to see what gets elaborated first. Also, you can place a breakpoint in this file, just like in any other file, before running your program in gdb. This might help too. HTH -- Ludovic Brenta.