all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: pillowtrucker--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Alan Mackenzie <acm@muc.de>
Cc: Eli Zaretskii <eliz@gnu.org>, Bob Weiner <rswgnu@gmail.com>,
	70423@debbugs.gnu.org
Subject: bug#70423: 29.3; cc-mode hang at 100% cpu and consuming all available memory
Date: Fri, 19 Apr 2024 20:49:20 +0000	[thread overview]
Message-ID: <eOiJasWE0SvvPlztFVWAPINid_tx2_7gUknuj0VvlloNVZKKY66MgXssxnDwGtdiwbufBlMcJxUx1nPDV_U1urbiTIvKB26ahG7wusb62D0=@proton.me> (raw)
In-Reply-To: <ZiFo-eQsT0ieb5MD@ACM>


[-- Attachment #1.1: Type: text/plain, Size: 6419 bytes --]

Hello again, Alan!

I've been using a git revision of hyperbole with the regex removed while Bob works on the new regex. I've hit a few other small glitches while using it, but nothing anywhere as major as the main issue at hand, and they're most definitely unrelated.

I also had a look in the other bug report and it seemed like there was also some kind of patch on the cc-mode side in emacs 30/trunk ? Or did I misunderstand that conversation ? I could try running an emacs git build if that's the case, although I'm not sure how many of my other packages will remain compatible, so it's not really a priority.

My init.el script is really innocent, although I've later asked some friends and they agree that they would also probably never run something like that. I just thought it would be a fun challenge to do everything to reproduce the issue in one init script. The base64-encoded string is just a gzipped copy of the .cpp file with which I could reproduce the issue. You should get the same string by running "gzip --stdout drm_formats.cpp|base64" on the attached .cpp file. (However, I don't know if all gzip versions produce the same output given the same input, and it will make me look even more suspicious if the strings don't match.)

Regardless, I've been productively working on other C++ code with the regexp turned off and it's been a great relief not to have to struggle with having to restart my workspace/desktop so often.

Thank you for both of yours work! And good luck with the new regexp!
If you put it in some git tag/branch that I can pull easily, I could maybe assist with testing it ? Let me know if that's an option.

Kind regards,
M

On Thursday, April 18th, 2024 at 8:39 PM, Alan Mackenzie <acm@muc.de> wrote:

> Hello, Pillowtrucker!
> 

> On Tue, Apr 16, 2024 at 19:51:09 +0000, pillowtrucker@proton.me wrote:
> 

> > Greetings!
> 

> > I have been able to replicate a (relatively) minimum environment for
> > this — hyperbole + clang-format.el. I think lsp-mode aggravates the
> > issue somehow, but is not necessary to enter the infinite loop. Without
> > lsp-mode, however, the memory usage seems flat, as opposed to
> > ballooning when it is present. I would also guess that if you are able
> > to plug in that regexp into cc-mode without installing all of
> > hyperbole.el, you would probably get the same effect, but I didn't know
> > how to do that.
> 

> 

> 

> > You will need gzip and the clang-format utility for this from your
> > linux distribution or compiled from source. Preferably version 18.1.3
> > of the llvm suite, but it might work with earlier versions. I don't
> > think /how/ it's formatting the file matters as much as the fact of it
> > being altered to some degree.
> 

> 

> OK. I haven't actually evaluated your init.el (as I don't fully
> understand it), but I have a strong hypothesis for the looping.
> 

> You're loading hyperbole as part of the initialisation. This sets up the
> value of defun-prompt-regexp to a ~760 character long string, whereas
> normally in C++ Mode, this variable is nil.
> 

> This variable is what is seen in the second backtrace below, although it
> is bowdlerised to a very short string ending in ... . See the line below
> emphasised with <=========================.
> 

> This regexp is known to be faulty, and sometimes to cause infinite
> looping. By coincidence, I have recently rewritten this regexp at the
> request of Bob Weiner (in the Cc:), the maintainer of hyperbole, and he
> is currently testing the regexp. This faulty regexp may be the cause of
> your bug, too.
> 

> So, could I ask you please to be patient, and wait for Bob to complete
> his tests. If they are successful, a new version of hyperbole is the
> likely outcome, and this may solve your bug.
> 

> If there is any way you can run your test without installing the
> hyperbole package, please do so, and let me know whether or not the hang
> still occurs.
> 

> Thanks!
> 

> > Please follow these steps:
> > 1. start with an empty directory
> > $ export MYDEBUGDIR=emacs-debugging
> > 2. use the attached init.el file as follows:
> > $ emacs-29.3 --init-directory=${MYDEBUGDIR} -l init.el
> > 3. Wait for the script to reach the point where it's in an infinite loop (check top/htop for emacs with 100% usage, maybe wait a few seconds or minutes to make sure it is not just taking a long time to run the formatting) and press C-g to send "quit".
> 

> > This results in a hang and the debugger should show something like this:
> 

> 

> [ .... ]
> 

> > or maybe you will see:
> 

> > Debugger entered--Lisp error: (quit)
> > re-search-backward("^\\s(\\|\\(?:^[ \11]\\(template\\s-<[^>;.{}]+>\\s-*\\)?\\(..." nil move 1) <==========================================================================
> > beginning-of-defun-raw(nil)
> > beginning-of-defun()
> > c-get-fallback-scan-pos(18908)
> > c-parse-state-get-strategy(18908 1)
> > c-parse-state-1()
> > c-parse-state()
> > c-laomib-invalidate-cache(18908 18910)
> > c-before-change(18908 18910)
> > clang-format--replace(18908 2 "\n")
> > apply(clang-format--replace (18908 2 "\n"))
> > clang-format-region(1 18910 nil nil)
> > clang-format-buffer()
> > load-with-code-conversion("/home/wrath/emacs-debugging2/init.el" "/home/wrath/emacs-debugging2/init.el" nil t)
> > command-line-1(("-l" "emacs-debugging2/init.el"))
> > command-line()
> > normal-top-level()
> 

> > Either way it does seem like the problem lies somewhere in cc-mode
> > choking either on the file itself or on that regular expression.
> 

> > I license the attached init.el under the terms of the AGPL-3 or later
> > version. The drm_formats.cpp file is part of the MIR Server project and
> > is licensed under the terms of the GPL-v3. Both licenses attached. I'm
> > not sure if I am allowed to re-license the MIR file as AGPL, but I
> > believe they are in any case compatible to be distributed together.
> 

> > Thank you for having a look at this issue, it has been plaguing me
> > since november and even making rust look like an ever so slightly more
> > pleasant alternative to dealing with constant hangs/crashes and having
> > to restore frame/window layouts when editing C/C++..
> 

> > Kind regards,
> > M.
> 

> 

> --
> Alan Mackenzie (Nuremberg, Germany).

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: drm_formats.cpp --]
[-- Type: text/x-c++src; filename="drm_formats.cpp"; name="drm_formats.cpp", Size: 18910 bytes --]

/*
 * Copyright © Canonical Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 2 or 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "mir/graphics/drm_formats.h"
#include "mir_toolkit/common.h"

#include <cstdint>
#include <drm_fourcc.h>
#include <stdexcept>
#include <memory>
#include <array>
#include <boost/throw_exception.hpp>

#ifdef MIR_HAVE_DRM_GET_MODIFIER_NAME
#include <xf86drm.h>
#endif

namespace mg = mir::graphics;

auto mg::drm_format_to_string(uint32_t format) -> char const*
{
#define STRINGIFY(val) \
    case val:          \
        return #val;

    if (!(format & DRM_FORMAT_BIG_ENDIAN))
    {
        switch (format)
        {
#include "drm-formats"

            default:
                return "Unknown DRM format; rebuild Mir against newer DRM headers?";
        }

    }
#undef STRINGIFY

#define STRINGIFY_BIG_ENDIAN(val) \
    case val:                    \
        return #val " (big endian)";

    switch (format & (~DRM_FORMAT_BIG_ENDIAN))
    {
#include "drm-formats-big-endian"

        default:
            return "Unknown DRM format; rebuild Mir against newer DRM headers?";
    }
#undef STRINGIFY_BIGENDIAN
}

struct mg::DRMFormat::FormatInfo
{
    uint32_t format;
    bool has_alpha;
    uint32_t opaque_equivalent;
    uint32_t alpha_equivalent;
    std::optional<mg::DRMFormat::RGBComponentInfo> components;
};

namespace
{
constexpr std::array const formats = {
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_XRGB4444,
        false,
        DRM_FORMAT_XRGB4444,
        DRM_FORMAT_ARGB4444,
        mg::DRMFormat::RGBComponentInfo{
            4, 4, 4, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_XBGR4444,
        false,
        DRM_FORMAT_XBGR4444,
        DRM_FORMAT_ABGR4444,
        mg::DRMFormat::RGBComponentInfo{
            4, 4, 4, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_RGBX4444,
        false,
        DRM_FORMAT_RGBX4444,
        DRM_FORMAT_RGBA4444,
        mg::DRMFormat::RGBComponentInfo{
            4, 4, 4, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_BGRX4444,
        false,
        DRM_FORMAT_BGRX4444,
        DRM_FORMAT_BGRA4444,
        mg::DRMFormat::RGBComponentInfo{
            4, 4, 4, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_ARGB4444,
        true,
        DRM_FORMAT_XRGB4444,
        DRM_FORMAT_ARGB4444,
        mg::DRMFormat::RGBComponentInfo{
            4, 4, 4, 4
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_ABGR4444,
        true,
        DRM_FORMAT_XBGR4444,
        DRM_FORMAT_ABGR4444,
        mg::DRMFormat::RGBComponentInfo{
            4, 4, 4, 4
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_RGBA4444,
        true,
        DRM_FORMAT_RGBX4444,
        DRM_FORMAT_RGBA4444,
        mg::DRMFormat::RGBComponentInfo{
            4, 4, 4, 4
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_BGRA4444,
        true,
        DRM_FORMAT_BGRX4444,
        DRM_FORMAT_BGRA4444,
        mg::DRMFormat::RGBComponentInfo{
            4, 4, 4, 4
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_XRGB1555,
        false,
        DRM_FORMAT_XRGB1555,
        DRM_FORMAT_ARGB1555,
        mg::DRMFormat::RGBComponentInfo{
            5, 5, 5, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_XBGR1555,
        false,
        DRM_FORMAT_XBGR1555,
        DRM_FORMAT_ABGR1555,
        mg::DRMFormat::RGBComponentInfo{
            5, 5, 5, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_RGBX5551,
        false,
        DRM_FORMAT_RGBX5551,
        DRM_FORMAT_RGBA5551,
        mg::DRMFormat::RGBComponentInfo{
            5, 5, 5, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_BGRX5551,
        false,
        DRM_FORMAT_BGRX5551,
        DRM_FORMAT_BGRA5551,
        mg::DRMFormat::RGBComponentInfo{
            5, 5, 5, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_ARGB1555,
        true,
        DRM_FORMAT_XRGB1555,
        DRM_FORMAT_ARGB1555,
        mg::DRMFormat::RGBComponentInfo{
            5, 5, 5, 1
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_ABGR1555,
        true,
        DRM_FORMAT_XBGR1555,
        DRM_FORMAT_ABGR1555,
        mg::DRMFormat::RGBComponentInfo{
            5, 5, 5, 1
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_RGBA5551,
        true,
        DRM_FORMAT_RGBX5551,
        DRM_FORMAT_RGBA5551,
        mg::DRMFormat::RGBComponentInfo{
            5, 5, 5, 1
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_BGRA5551,
        true,
        DRM_FORMAT_BGRX5551,
        DRM_FORMAT_BGRA5551,
        mg::DRMFormat::RGBComponentInfo{
            5, 5, 5, 1
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_RGB565,
        false,
        DRM_FORMAT_RGB565,
        DRM_FORMAT_INVALID,
        mg::DRMFormat::RGBComponentInfo{
            5, 6, 5, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_BGR565,
        false,
        DRM_FORMAT_BGR565,
        DRM_FORMAT_INVALID,
        mg::DRMFormat::RGBComponentInfo{
            5, 6, 5, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_RGB888,
        false,
        DRM_FORMAT_RGB888,
        DRM_FORMAT_INVALID,
        mg::DRMFormat::RGBComponentInfo{
            8, 8, 8, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_BGR888,
        false,
        DRM_FORMAT_BGR888,
        DRM_FORMAT_INVALID,
        mg::DRMFormat::RGBComponentInfo{
            8, 8, 8, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_XRGB8888,
        false,
        DRM_FORMAT_XRGB8888,
        DRM_FORMAT_ARGB8888,
        mg::DRMFormat::RGBComponentInfo{
            8, 8, 8, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_XBGR8888,
        false,
        DRM_FORMAT_XBGR8888,
        DRM_FORMAT_ABGR8888,
        mg::DRMFormat::RGBComponentInfo{
            8, 8, 8, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_RGBX8888,
        false,
        DRM_FORMAT_RGBX8888,
        DRM_FORMAT_RGBA8888,
        mg::DRMFormat::RGBComponentInfo{
            8, 8, 8, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_BGRX8888,
        false,
        DRM_FORMAT_BGRX8888,
        DRM_FORMAT_BGRA8888,
        mg::DRMFormat::RGBComponentInfo{
            8, 8, 8, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_ARGB8888,
        true,
        DRM_FORMAT_XRGB8888,
        DRM_FORMAT_ARGB8888,
        mg::DRMFormat::RGBComponentInfo{
            8, 8, 8, 8
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_ABGR8888,
        true,
        DRM_FORMAT_XBGR8888,
        DRM_FORMAT_ABGR8888,
        mg::DRMFormat::RGBComponentInfo{
            8, 8, 8, 8
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_RGBA8888,
        true,
        DRM_FORMAT_RGBX8888,
        DRM_FORMAT_RGBA8888,
        mg::DRMFormat::RGBComponentInfo{
            8, 8, 8, 8
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_BGRA8888,
        true,
        DRM_FORMAT_BGRX8888,
        DRM_FORMAT_BGRA8888,
        mg::DRMFormat::RGBComponentInfo{
            8, 8, 8, 8
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_XRGB2101010,
        false,
        DRM_FORMAT_XRGB2101010,
        DRM_FORMAT_ARGB2101010,
        mg::DRMFormat::RGBComponentInfo{
            10, 10, 10, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_XBGR2101010,
        false,
        DRM_FORMAT_XBGR2101010,
        DRM_FORMAT_ABGR2101010,
        mg::DRMFormat::RGBComponentInfo{
            10, 10, 10, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_RGBX1010102,
        false,
        DRM_FORMAT_RGBX1010102,
        DRM_FORMAT_RGBA1010102,
        mg::DRMFormat::RGBComponentInfo{
            10, 10, 10, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_BGRX1010102,
        false,
        DRM_FORMAT_BGRX1010102,
        DRM_FORMAT_BGRA1010102,
        mg::DRMFormat::RGBComponentInfo{
            10, 10, 10, {}
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_ARGB2101010,
        true,
        DRM_FORMAT_XRGB2101010,
        DRM_FORMAT_ARGB2101010,
        mg::DRMFormat::RGBComponentInfo{
            10, 10, 10, 2
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_ABGR2101010,
        true,
        DRM_FORMAT_XBGR2101010,
        DRM_FORMAT_ABGR2101010,
        mg::DRMFormat::RGBComponentInfo{
            10, 10, 10, 2
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_RGBA1010102,
        true,
        DRM_FORMAT_RGBX1010102,
        DRM_FORMAT_RGBA1010102,
        mg::DRMFormat::RGBComponentInfo{
            10, 10, 10, 2
        },
    },
    mg::DRMFormat::FormatInfo{
        DRM_FORMAT_BGRA1010102,
        true,
        DRM_FORMAT_BGRX1010102,
        DRM_FORMAT_BGRA1010102,
        mg::DRMFormat::RGBComponentInfo{
            10, 10, 10, 2
        },
    },
};

constexpr auto find_format_info(uint32_t fourcc) -> mg::DRMFormat::FormatInfo const*
{
    for (auto const& format: formats)
    {
        if (format.format == fourcc)
            return &format;
    }
    /* The format array doesn't cover all DRM_FORMAT_*, only the ones relevant to Mir
     * (and not all of them, yet: eg YUV formats), so we must have a sentinel value
     * for the missing ones
     */
    return nullptr;
}

/* Generate a bunch of variables named format_info_DRM_FORMAT_FOO pointing to associated FormatInfo */
#define STRINGIFY(format) \
    constexpr mg::DRMFormat::FormatInfo const* format_info_##format = find_format_info(format);

#include "drm-formats"

#undef STRINGIFY

constexpr auto maybe_info_for_format(uint32_t fourcc_format) -> mg::DRMFormat::FormatInfo const*
{
    switch (fourcc_format)
    {
#define STRINGIFY(format) \
    case format: \
        return format_info_##format; \

#include "drm-formats"

#undef STRINGIFY
        default:
            BOOST_THROW_EXCEPTION((
                std::runtime_error{
                    std::string{"Unknown DRM format "} + std::to_string(fourcc_format) +
                    " (may need to rebuild Mir against newer DRM headers?)"}));
    }

}

constexpr auto info_for_format(uint32_t fourcc_format) -> mg::DRMFormat::FormatInfo const&
{
    auto const info = maybe_info_for_format(fourcc_format);

    if (info)
    {
        return *info;
    }
    BOOST_THROW_EXCEPTION((
        std::runtime_error{
            std::string{"Unsupported DRM format: "} + mg::drm_format_to_string(fourcc_format)}));
}

}

mg::DRMFormat::DRMFormat(uint32_t fourcc_format)
    : info{&info_for_format(fourcc_format)}
{
}

auto mg::DRMFormat::name() const -> const char*
{
    return drm_format_to_string(info->format);
}

auto mg::DRMFormat::opaque_equivalent() const -> const std::optional<DRMFormat>
{
    if (info->opaque_equivalent != DRM_FORMAT_INVALID)
    {
        return DRMFormat{info->opaque_equivalent};
    }
    return {};
}

auto mg::DRMFormat::alpha_equivalent() const -> const std::optional<DRMFormat>
{
    if (info->alpha_equivalent != DRM_FORMAT_INVALID)
    {
        return DRMFormat{info->alpha_equivalent};
    }
    return {};
}

bool mg::DRMFormat::has_alpha() const
{
    return info->has_alpha;
}

auto mg::DRMFormat::components() const -> std::optional<RGBComponentInfo> const&
{
    return info->components;
}

mg::DRMFormat::operator uint32_t() const
{
    return info->format;
}

auto mg::DRMFormat::as_mir_format() const -> std::optional<MirPixelFormat>
{
    switch (info->format)
    {
    case DRM_FORMAT_ARGB8888:
        return mir_pixel_format_argb_8888;
    case DRM_FORMAT_XRGB8888:
        return mir_pixel_format_xrgb_8888;
    case DRM_FORMAT_RGBA4444:
        return mir_pixel_format_rgba_4444;
    case DRM_FORMAT_RGBA5551:
        return mir_pixel_format_rgba_5551;
    case DRM_FORMAT_RGB565:
        return mir_pixel_format_rgb_565;
    case DRM_FORMAT_RGB888:
        return mir_pixel_format_rgb_888;
    case DRM_FORMAT_BGR888:
        return mir_pixel_format_bgr_888;
    case DRM_FORMAT_XBGR8888:
        return mir_pixel_format_xbgr_8888;
    case DRM_FORMAT_ABGR8888:
        return mir_pixel_format_abgr_8888;
    default:
        return std::nullopt;
    }
}

auto mg::DRMFormat::from_mir_format(MirPixelFormat format)
    -> DRMFormat
{
    switch (format)
    {
    case mir_pixel_format_argb_8888:
        return DRMFormat{DRM_FORMAT_ARGB8888};
    case mir_pixel_format_xrgb_8888:
        return DRMFormat{DRM_FORMAT_XRGB8888};
    case mir_pixel_format_abgr_8888:
        return DRMFormat{DRM_FORMAT_ABGR8888};
    case mir_pixel_format_xbgr_8888:
        return DRMFormat{DRM_FORMAT_XBGR8888};
    case mir_pixel_format_bgr_888:
        return DRMFormat{DRM_FORMAT_BGR888};
    case mir_pixel_format_rgb_888:
        return DRMFormat{DRM_FORMAT_RGB888};
    case mir_pixel_format_rgb_565:
        return DRMFormat{DRM_FORMAT_RGB565};
    case mir_pixel_format_rgba_5551:
        return DRMFormat{DRM_FORMAT_RGBA5551};
    case mir_pixel_format_rgba_4444:
        return DRMFormat{DRM_FORMAT_RGBA4444};
    case mir_pixel_format_invalid:
        /* We *could* do something with DRM_FORMAT_INVALID here, but
         * let's not. Let's maintain that DRMFormat is always valid
         */
        BOOST_THROW_EXCEPTION((std::runtime_error{"Attempt to look up DRM format info of invalid pixel format"}));
    case mir_pixel_formats:
        BOOST_THROW_EXCEPTION((std::logic_error{"Attempt to look up format info of sentinel pixel format"}));
#ifndef __clang__
    /* Clang accepts that the above cases are exhaustive, gcc does not
     * Have a default clause here to pacify gcc, but omit it for clang
     * so that we fail to build if the above is *not* exhaustive.
     */
    default:
        BOOST_THROW_EXCEPTION((std::logic_error{"Exhaustive switch needs updating"}));
#endif
    }
}


auto mg::drm_modifier_to_string(uint64_t modifier) -> std::string
{
#ifdef MIR_HAVE_DRM_GET_MODIFIER_NAME
    struct CStrDeleter
    {
    public:
        void operator()(char* c_str)
        {
            if (c_str)
            {
                free (c_str);
            }
        }
    };

    auto const vendor =
        [&]() -> std::string
        {
            std::unique_ptr<char[], CStrDeleter> vendor{drmGetFormatModifierVendor(modifier)};
            if (vendor)
            {
                return vendor.get();
            }
            return "(UNKNOWN VENDOR)";
        }();

    auto const name =
        [&]() -> std::string
        {
            std::unique_ptr<char[], CStrDeleter> name{drmGetFormatModifierName(modifier)};
            if (name)
            {
                return name.get();
            }
            return "(UNKNOWN MODIFIER)";
        }();

    return vendor + ":" + name;
}
#else
#define STRINGIFY(val) \
    case val:          \
        return #val;

    switch (modifier)
    {
#ifdef DRM_FORMAT_MOD_INVALID
        STRINGIFY(DRM_FORMAT_MOD_INVALID)
#endif
#ifdef DRM_FORMAT_MOD_LINEAR
        STRINGIFY(DRM_FORMAT_MOD_LINEAR)
#endif
#ifdef I915_FORMAT_MOD_X_TILED
        STRINGIFY(I915_FORMAT_MOD_X_TILED)
#endif
#ifdef I915_FORMAT_MOD_Y_TILED
        STRINGIFY(I915_FORMAT_MOD_Y_TILED)
#endif
#ifdef I915_FORMAT_MOD_Yf_TILED
        STRINGIFY(I915_FORMAT_MOD_Yf_TILED)
#endif
#ifdef I915_FORMAT_MOD_Y_TILED_CCS
        STRINGIFY(I915_FORMAT_MOD_Y_TILED_CCS)
#endif
#ifdef I915_FORMAT_MOD_Yf_TILED_CCS
        STRINGIFY(I915_FORMAT_MOD_Yf_TILED_CCS)
#endif
#ifdef I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS
        STRINGIFY(I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS)
#endif
#ifdef I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS
        STRINGIFY(I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS)
#endif
#ifdef DRM_FORMAT_MOD_SAMSUNG_64_32_TILE
        STRINGIFY(DRM_FORMAT_MOD_SAMSUNG_64_32_TILE)
#endif
#ifdef DRM_FORMAT_MOD_SAMSUNG_16_16_TILE
        STRINGIFY(DRM_FORMAT_MOD_SAMSUNG_16_16_TILE)
#endif
#ifdef DRM_FORMAT_MOD_QCOM_COMPRESSED
        STRINGIFY(DRM_FORMAT_MOD_QCOM_COMPRESSED)
#endif
#ifdef DRM_FORMAT_MOD_VIVANTE_TILED
        STRINGIFY(DRM_FORMAT_MOD_VIVANTE_TILED)
#endif
#ifdef DRM_FORMAT_MOD_VIVANTE_SUPER_TILED
        STRINGIFY(DRM_FORMAT_MOD_VIVANTE_SUPER_TILED)
#endif
#ifdef DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED
        STRINGIFY(DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED)
#endif
#ifdef DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED
        STRINGIFY(DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED)
#endif
#ifdef DRM_FORMAT_MOD_NVIDIA_TEGRA_TILED
        STRINGIFY(DRM_FORMAT_MOD_NVIDIA_TEGRA_TILED)
#endif
#ifdef DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_ONE_GOB
        STRINGIFY(DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_ONE_GOB)
#endif
#ifdef DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_TWO_GOB
        STRINGIFY(DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_TWO_GOB)
#endif
#ifdef DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_FOUR_GOB
        STRINGIFY(DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_FOUR_GOB)
#endif
#ifdef DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_EIGHT_GOB
        STRINGIFY(DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_EIGHT_GOB)
#endif
#ifdef DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_SIXTEEN_GOB
        STRINGIFY(DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_SIXTEEN_GOB)
#endif
#ifdef DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_THIRTYTWO_GOB
        STRINGIFY(DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_THIRTYTWO_GOB)
#endif
#ifdef DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED
        STRINGIFY(DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED)
#endif
#ifdef DRM_FORMAT_MOD_BROADCOM_SAND32
        STRINGIFY(DRM_FORMAT_MOD_BROADCOM_SAND32)
#endif
#ifdef DRM_FORMAT_MOD_BROADCOM_SAND64
        STRINGIFY(DRM_FORMAT_MOD_BROADCOM_SAND64)
#endif
#ifdef DRM_FORMAT_MOD_BROADCOM_SAND128
        STRINGIFY(DRM_FORMAT_MOD_BROADCOM_SAND128)
#endif
#ifdef DRM_FORMAT_MOD_BROADCOM_SAND256
        STRINGIFY(DRM_FORMAT_MOD_BROADCOM_SAND256)
#endif
#ifdef DRM_FORMAT_MOD_BROADCOM_UIF
        STRINGIFY(DRM_FORMAT_MOD_BROADCOM_UIF)
#endif
#ifdef DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED
        STRINGIFY(DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED)
#endif
#ifdef DRM_FORMAT_MOD_ALLWINNER_TILED
        STRINGIFY(DRM_FORMAT_MOD_ALLWINNER_TILED)
#endif

        default:
            return "(unknown)";
    }

#undef STRINGIFY
}
#endif


[-- Attachment #1.3: publickey - pillowtrucker@proton.me - 0x40BB2176.asc --]
[-- Type: application/pgp-keys, Size: 657 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

  reply	other threads:[~2024-04-19 20:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 13:36 bug#70423: 29.3; cc-mode hang at 100% cpu and consuming all available memory 1stmil.eth via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-16 15:52 ` bug#70423: Possible workaround/culprit pillowtrucker--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-16 18:31   ` Dmitry Gutov
2024-04-16 16:22 ` bug#70423: 29.3; cc-mode hang at 100% cpu and consuming all available memory Eli Zaretskii
2024-04-16 17:05   ` Alan Mackenzie
2024-04-16 17:59 ` Alan Mackenzie
2024-04-16 19:51   ` pillowtrucker--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-18 18:39     ` Alan Mackenzie
2024-04-19 20:49       ` pillowtrucker--- via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-04-20  9:22         ` Alan Mackenzie
2024-04-20 13:14           ` Robert Weiner
2024-04-20 15:52             ` Robert Weiner
2024-05-02  8:40               ` Eli Zaretskii
2024-05-02 22:01                 ` Robert Weiner
2024-05-03  5:54                   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='eOiJasWE0SvvPlztFVWAPINid_tx2_7gUknuj0VvlloNVZKKY66MgXssxnDwGtdiwbufBlMcJxUx1nPDV_U1urbiTIvKB26ahG7wusb62D0=@proton.me' \
    --to=bug-gnu-emacs@gnu.org \
    --cc=70423@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=eliz@gnu.org \
    --cc=pillowtrucker@proton.me \
    --cc=rswgnu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.