* Where would you start debugging?
@ 2013-06-27 13:53 Peter Brooks
2013-06-27 14:24 ` Peter Brooks
2013-06-27 14:33 ` G.B.
0 siblings, 2 replies; 4+ messages in thread
From: Peter Brooks @ 2013-06-27 13:53 UTC (permalink / raw)
I've written a small package, there's not much point in putting it here. The moment I run it it is giving me this error:
raised CONSTRAINT_ERROR : erroneous memory access
I'm using gnat on a Mac. The odd thing is that this happens when the calling program simply has a 'with' statement mentioning the package, there's no need to call it.
So, it's clearly part of the iniitalisation of the package.
Where should I start debugging?
I'm doing some conversions from strings to enumerated types, so I've a few lines like this:
"
PACKAGE item_package IS
NEW Ada.Text_IO.Enumeration_IO( Enum => item_category );
"
So that I can to the conversion later with:
"
item_package.Get(From => String_Split.Slice(subs,1),Item => item.category(item_number),Last => last);
"
This strikes me as the most likely place for it to be going wrong - the compiler is obviously happy, but, at run time, that 'NEW' is falling over with a problem with memory allocation.
Is that likely? If it is, should I forget this method and just parse the string manually?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Where would you start debugging?
2013-06-27 13:53 Where would you start debugging? Peter Brooks
@ 2013-06-27 14:24 ` Peter Brooks
2013-06-27 14:33 ` G.B.
1 sibling, 0 replies; 4+ messages in thread
From: Peter Brooks @ 2013-06-27 14:24 UTC (permalink / raw)
It's OK - I've found the problem. It was opening the same file in two places and that gave the error.
Not immediately obvious...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Where would you start debugging?
2013-06-27 13:53 Where would you start debugging? Peter Brooks
2013-06-27 14:24 ` Peter Brooks
@ 2013-06-27 14:33 ` G.B.
2013-06-28 10:35 ` Peter Brooks
1 sibling, 1 reply; 4+ messages in thread
From: G.B. @ 2013-06-27 14:33 UTC (permalink / raw)
On 27.06.13 15:53, Peter Brooks wrote:
> I've written a small package, there's not much point in putting it here. The moment I run it it is giving me this error:
>
> raised CONSTRAINT_ERROR : erroneous memory access
>
> I'm using gnat on a Mac. The odd thing is that this happens when the calling program simply has a 'with' statement mentioning the package, there's no need to call it.
>
> So, it's clearly part of the iniitalisation of the package.
>
> Where should I start debugging?
If the with-ed package is yours, -gnatVa, -gnatwa, -fstack-check,
and -gnato could help as they add more checks and warnings.
-gnatE and -gnata might also help.
In case the with-ed package is from the run-time system or similar,
I'd add GNAT switches -x, -a, and possibly -m to the above.
Before starting gdb, I'd try a tool like valgrind (of which XCode
has an equivalent IIRC.)
> should I forget this method and just parse the string manually?
Will 'Value do?
type Enum is (Yeah, Bee, See);
...
declare
use Ada.Command_Line;
Test : Enum;
begin
Test := Enum'Value (Argument (1));
Text_IO.Put_Line (Natural'Image (Enum'Pos (Test)));
exception
when Constraint_Error =>
-- ...
end;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Where would you start debugging?
2013-06-27 14:33 ` G.B.
@ 2013-06-28 10:35 ` Peter Brooks
0 siblings, 0 replies; 4+ messages in thread
From: Peter Brooks @ 2013-06-28 10:35 UTC (permalink / raw)
G.B. <rm-dash-bau-haus@dash.futureapps.de> wrote:
> Will 'Value do?
>
> type Enum is (Yeah, Bee, See);
>
> ...
>
> declare
> use Ada.Command_Line;
> Test : Enum;
> begin
> Test := Enum'Value (Argument (1));
> Text_IO.Put_Line (Natural'Image (Enum'Pos (Test)));
> exception
> when Constraint_Error =>
> -- ...
> end;
>
Perfect - thank you!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-06-28 10:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-27 13:53 Where would you start debugging? Peter Brooks
2013-06-27 14:24 ` Peter Brooks
2013-06-27 14:33 ` G.B.
2013-06-28 10:35 ` Peter Brooks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox