Re: [PATCH] Add Windows support for backtrace_functions (MSVC only)

Euler Taveira <euler@eulerto.com>

From: "Euler Taveira" <euler@eulerto.com>
To: Álvaro Herrera <alvherre@kurilemu.de>
Cc: "Bryan Green" <dbryan.green@gmail.com>, "Michael Paquier" <michael@paquier.xyz>, "Jakub Wartak" <jakub.wartak@enterprisedb.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-10-29T12:53:16Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add backtrace support for Windows using DbgHelp API

On Tue, Oct 28, 2025, at 1:51 PM, Álvaro Herrera wrote:
> On 2025-Oct-27, Euler Taveira wrote:
>
>> On Mon, Oct 27, 2025, at 2:58 PM, Bryan Green wrote:
>> >     Thanks for even glancing at this.  I did not add any regression 
>> > tests because the output goes to the server log and not the client.
>> 
>> Since Michael said WIN32-specific tests and mentioned log pattern, he is
>> referring to TAP tests. You can add src/test/modules/test_backtrace that
>> exercises this code path.
>
> Hmm, are we really sure this is necessary?
>

Good question. We are testing an external API. Maybe a test in this thread is
enough to convince someone that the code is correct.

>> I didn't test your patch but I'm wondering if we could add an
>> abstraction here.  I mean invent pg_backtrace() and
>> pg_backtrace_symbols() that maps to the current functions (Unix-like).
>
> Do we really need this?  I don't think we're going to add support for
> backtraces anywhere else any time soon, so this looks premature.  What
> other programs do you think we have where this would be useful?  I have
> a really hard time imagining that things like psql and pg_dump would be
> improved by having backtrace-reporting support.  And if we have a single
> place in the code using a facility, then ISTM the platform-specific code
> can live there with no damage.
>

It was just a suggestion; not a requirement. As you said it would avoid rework
in the future if or when someone decides to use this code in other parts of the
software. I wouldn't propose this change if I knew it was complicated to have a
simple and clean abstraction.


-- 
Euler Taveira
EDB   https://www.enterprisedb.com/