File tree 2 files changed +27
-2
lines changed
runtime/druntime/src/core
2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,8 @@ private
229
229
extern (C ) void fiber_switchContext( void ** oldp, void * newp ) nothrow @nogc ;
230
230
version (AArch64 )
231
231
extern (C ) void fiber_trampoline() nothrow ;
232
+ version (LoongArch64)
233
+ extern (C ) void fiber_trampoline() nothrow ;
232
234
}
233
235
else version (LDC_Windows)
234
236
{
@@ -1847,7 +1849,7 @@ private:
1847
1849
// Only need to set return address ($r1). Everything else is fine
1848
1850
// zero initialized.
1849
1851
pstack -= size_t .sizeof * 10 ; // skip past space reserved for $r22-$r31
1850
- push (cast (size_t ) &fiber_entryPoint);
1852
+ push(cast (size_t ) &fiber_trampoline); // see threadasm.S for docs
1851
1853
pstack += size_t .sizeof; // adjust sp (newp) above lr
1852
1854
}
1853
1855
else version (AsmAArch64_Posix)
Original file line number Diff line number Diff line change @@ -544,9 +544,10 @@ fiber_switchContext:
544
544
* /
545
545
.text
546
546
.globl fiber_switchContext
547
+ .type fiber_switchContext , %function
547
548
fiber_switchContext:
548
549
.cfi_startproc
549
- .cfi_undefined $ ra
550
+ .cfi_undefined 1
550
551
# reserve space on stack
551
552
addi.d $ sp , $ sp , - 19 * 8
552
553
@@ -610,6 +611,28 @@ fiber_switchContext:
610
611
611
612
jr $ ra
612
613
.cfi_endproc
614
+
615
+ / **
616
+ * When generating any kind of backtrace (gdb , exception handling) for
617
+ * a function called in a Fiber , we need to tell the unwinder to stop
618
+ * at our Fiber main entry point , i.e. we need to mark the bottom of
619
+ * the call stack. This can be done by clearing the return address register $ ra
620
+ * prior to calling fiber_entryPoint (i.e. in fiber_switchContext) or
621
+ * using a .cfi_undefined directive for the return address register in the
622
+ * Fiber entry point. cfi_undefined seems to yield better results in gdb.
623
+ * Unfortunately we can't place it into fiber_entryPoint using inline
624
+ * asm , so we use this trampoline instead.
625
+ * /
626
+ .text
627
+ . global CSYM(fiber_trampoline)
628
+ .p2align 2
629
+ .type fiber_trampoline , %function
630
+ CSYM(fiber_trampoline):
631
+ .cfi_startproc
632
+ .cfi_undefined 1
633
+ // fiber_entryPoint never returns
634
+ bl CSYM(fiber_entryPoint)
635
+ .cfi_endproc
613
636
#elif defined(__arm__) && (defined(__ARM_EABI__) || defined(__APPLE__))
614
637
/ ************************************************************************************
615
638
* ARM ASM BITS
You can’t perform that action at this time.
0 commit comments