Is there a way to force emitting of stack frame for a specific function?
Andrey Zherikov
andrey.zherikov at gmail.com
Fri Oct 9 02:01:30 UTC 2020
On Thursday, 8 October 2020 at 13:13:16 UTC, Imperatorn wrote:
> Can you share some code? You don't want to use try-catch?
Here is minimal example that illustrates this:
=====================
import std.stdio;
void do_assert() { assert(false); }
void stackFrame()
{
//pragma(inline, false);
do_assert();
}
void main()
{
try
{
stackFrame();
}
catch(Exception e)
{
e.writeln();
}
}
=====================
Stack trace with "dmd -g -O -run test.d" command (no stackFrame
function in it):
0x0040CC6B in _d_assertp
0x00410CFB in void rt.dmain2._d_run_main2(char[][], uint, extern
(C) int function(char[][])*).runAll().__lambda1()
0x00410C75 in void rt.dmain2._d_run_main2(char[][], uint, extern
(C) int function(char[][])*).runAll()
0x00410B10 in _d_run_main2
0x0040CDB6 in _d_run_main
0x0040234C in main at
C:\D\dmd2\windows\bin\..\..\src\druntime\import\core\internal\entrypoint.d(30)
0x7653F989 in BaseThreadInitThunk
0x77CB74B4 in RtlGetAppContainerNamedObjectPath
0x77CB7484 in RtlGetAppContainerNamedObjectPath
=====================
Stack trace with "dmd -g -O -gs -run test.d" command (stackFrame
function is there):
0x0040C573 in _d_assertp
0x004022C4 in void test.stackFrame() at C:\Users\andrey\test.d(7)
0x004022F9 in _Dmain at C:\Users\andrey\test.d(14)
0x00410603 in void rt.dmain2._d_run_main2(char[][], uint, extern
(C) int function(char[][])*).runAll().__lambda1()
0x0041057D in void rt.dmain2._d_run_main2(char[][], uint, extern
(C) int function(char[][])*).runAll()
0x00410418 in _d_run_main2
0x0040C6BE in _d_run_main
0x00402353 in main at
C:\D\dmd2\windows\bin\..\..\src\druntime\import\core\internal\entrypoint.d(30)
0x00434535 in mainCRTStartup
0x7653F989 in BaseThreadInitThunk
0x77CB74B4 in RtlGetAppContainerNamedObjectPath
0x77CB7484 in RtlGetAppContainerNamedObjectPath
=====================
The question: is it possible to tell compiler to always generate
stack frame for my stackFrame function?
"pragma(inline, false)" doesn't help here - the result is
completely the same.
More information about the Digitalmars-d-learn
mailing list