public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3987] libphobos: Remove unused variables in gcc.backtrace.
@ 2021-09-30 16:41 Iain Buclaw
  0 siblings, 0 replies; only message in thread
From: Iain Buclaw @ 2021-09-30 16:41 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0111153234120de7f87b050df78f0d9819ca4214

commit r12-3987-g0111153234120de7f87b050df78f0d9819ca4214
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Fri Sep 24 10:49:13 2021 +0200

    libphobos: Remove unused variables in gcc.backtrace.
    
    The core.runtime module always overrides the default parameter value for
    constructor calls.  MaxAlignment is not required because a class can be
    created on the stack with the `scope' keyword.
    
    libphobos/ChangeLog:
    
            * libdruntime/core/runtime.d (runModuleUnitTests): Use scope to new
            LibBacktrace on the stack.
            * libdruntime/gcc/backtrace.d (FIRSTFRAME): Remove.
            (LibBacktrace.MaxAlignment): Remove.
            (LibBacktrace.this): Remove default initialization of firstFrame.
            (UnwindBacktrace.this): Likewise.

Diff:
---
 libphobos/libdruntime/core/runtime.d  | 14 +++-----------
 libphobos/libdruntime/gcc/backtrace.d | 24 ++----------------------
 2 files changed, 5 insertions(+), 33 deletions(-)

diff --git a/libphobos/libdruntime/core/runtime.d b/libphobos/libdruntime/core/runtime.d
index 848b607ae69..5fc99046d23 100644
--- a/libphobos/libdruntime/core/runtime.d
+++ b/libphobos/libdruntime/core/runtime.d
@@ -483,17 +483,9 @@ extern (C) bool runModuleUnitTests()
             fprintf(stderr, "Segmentation fault while running unittests:\n");
             fprintf(stderr, "----------------\n");
 
-            enum alignment = LibBacktrace.MaxAlignment;
-            enum classSize = __traits(classInstanceSize, LibBacktrace);
-
-            void[classSize + alignment] bt_store = void;
-            void* alignedAddress = cast(byte*)((cast(size_t)(bt_store.ptr + alignment - 1))
-                & ~(alignment - 1));
-
-            (alignedAddress[0 .. classSize]) = typeid(LibBacktrace).initializer[];
-            auto bt = cast(LibBacktrace)(alignedAddress);
-            // First frame is LibBacktrace ctor. Second is signal handler, but include that for now
-            bt.__ctor(1);
+            // First frame is LibBacktrace ctor. Second is signal handler,
+            // but include that for now
+            scope bt = new LibBacktrace(1);
 
             foreach (size_t i, const(char[]) msg; bt)
                 fprintf(stderr, "%s\n", msg.ptr ? msg.ptr : "???");
diff --git a/libphobos/libdruntime/gcc/backtrace.d b/libphobos/libdruntime/gcc/backtrace.d
index 8f5582d7469..3c4d65f417f 100644
--- a/libphobos/libdruntime/gcc/backtrace.d
+++ b/libphobos/libdruntime/gcc/backtrace.d
@@ -24,24 +24,6 @@ module gcc.backtrace;
 
 import gcc.libbacktrace;
 
-version (Posix)
-{
-    // NOTE: The first 5 frames with the current implementation are
-    //       inside core.runtime and the object code, so eliminate
-    //       these for readability.  The alternative would be to
-    //       exclude the first N frames that are in a list of
-    //       mangled function names.
-    private enum FIRSTFRAME = 5;
-}
-else
-{
-    // NOTE: On Windows, the number of frames to exclude is based on
-    //       whether the exception is user or system-generated, so
-    //       it may be necessary to exclude a list of function names
-    //       instead.
-    private enum FIRSTFRAME = 0;
-}
-
 // Max size per line of the traceback.
 private enum MAX_BUFSIZE = 1536;
 
@@ -205,8 +187,6 @@ static if (BACKTRACE_SUPPORTED && !BACKTRACE_USES_MALLOC)
     // FIXME: state is never freed as libbacktrace doesn't provide a free function...
     public class LibBacktrace : Throwable.TraceInfo
     {
-        enum MaxAlignment = (void*).alignof;
-
         static void initLibBacktrace()
         {
             if (!initialized)
@@ -216,7 +196,7 @@ static if (BACKTRACE_SUPPORTED && !BACKTRACE_USES_MALLOC)
             }
         }
 
-        this(int firstFrame = FIRSTFRAME)
+        this(int firstFrame)
         {
             _firstFrame = firstFrame;
 
@@ -365,7 +345,7 @@ else
      */
     public class UnwindBacktrace : Throwable.TraceInfo
     {
-        this(int firstFrame = FIRSTFRAME)
+        this(int firstFrame)
         {
             _firstFrame = firstFrame;
             _callstack = getBacktrace();


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-30 16:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 16:41 [gcc r12-3987] libphobos: Remove unused variables in gcc.backtrace Iain Buclaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).