>>The problem is your fpc build is optimized
no, no optimizations, but also no debug invormation
do I understand correctly that to see the last line of my program I need build fpc with debugging information?
I don't think it makes a difference if you add debug info to your fpc/rtl build.
Somehow at least the address of fpc_ansistr_assign is known already (as it shows up).
But that can be included from linker info. (If indeed your rtl has no debug info).
My judgement on the current outcome is made from the view of the debugger / frame dump code.
From my knowledges on how a stack is unrolled (i.e. parent frame being found), I can tell you that
- if any procedure in the stack does not have it's own frame
- then the caller/parent of that procedure is hidden.
Why the frame is omitted, I do not know. fpc_ansistr_assign is a "compilerproc" maybe that is the reason.
-----------------
There is one more explanation (based on the same "frame info" issue.)
If the error happens very close to the entrance of a function (or to the end of it), then the function may not have had time to set up its frame.
------------------
I did a test your code here.
According to the debugger
- fpc_ansistr_assign has a frame
- and fpc_ansistr_assign has set up that frame when the error happens.
I run the resulting code from console => and I got a full trace
C:\Users\martin\AppData\Local\Temp>project1.exe
doSomathing1
doSomathing2.1
An unhandled exception occurred at $0000000100004E85:
EAccessViolation: Access violation
$0000000100004E85 fpc_ansistr_assign, line 180 of ../inc/astrings.inc
$0000000100001756 doSomathing2, line 9 of project1.lpr
$00000001000017CD doSomathing1, line 15 of project1.lpr
$00000001000017F3 $main, line 18 of project1.lpr
$0000000100001806 MAIN_WRAPPER, line 67 of system.pp
$000000010000FD00 EXE_ENTRY, line 181 of system.pp
$0000000100001704 _FPC_MAINCRTSTARTUP, line 106 of sysinit.pp
- I did run my test with fpc 3.2.2
- Compiled 64 bits (that may make a difference sometimes)
- I used dwarf debug info (that may make a difference sometimes)
- My fpc has debug info, but I am not sure if that makes the difference.
For all else, you would have to check what changes, if any will make it work for you.