Re: PostgreSQL stops when adding a breakpoint in CLion - Mailing list pgsql-hackers

From Stanislav Bashkyrtsev
Subject Re: PostgreSQL stops when adding a breakpoint in CLion
Date
Msg-id CAMtnYL_-vTYTT-1ufkjerGX523=HGgA27XmAFbgSTRmJ1XwFWA@mail.gmail.com
Whole thread Raw
In response to Re: PostgreSQL stops when adding a breakpoint in CLion  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: PostgreSQL stops when adding a breakpoint in CLion
List pgsql-hackers
Why do you think postgres quits?
The process was running and then it stopped. And in the console I see:
2022-01-03 23:23:29.495 MSK [76717] LOG:  checkpoint starting: shutdown immediate
2022-01-03 23:23:29.498 MSK [76717] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.001 s, total=0.005 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB

 
AFAIK CLion uses gdb or lldb for
> debugging, which are the debugger of choice for many (most?) hackers on
> this list. So that should work fine.
Yep, and it worked for me too.. Yesterday :) I see that CLion uses LLDB on MacOS by default. 

Now sure why you start it in single-user mode, but I don't think that
> should affect debugging.
Well, --single seems convenient because CLion starts that process and attaches to it right away. I don't have to look for a way of attaching to the forks. Maybe it's a good point to mention that I'm not very familiar with developing in C/C++ and therefore have a vague understanding of how to set up an efficient dev environment. Moreover in multi-user mode CLion/LLDB keeps stopping in postmaster.c:
selres = select(nSockets, &rmask, NULL, NULL, &timeout);

>Try redirecting the output to a log file, maybe
> that'll tell you what happened.
I see all the output in the console, so not sure what redirecting to a file would achieve.


On Mon, Jan 3, 2022 at 10:08 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Tomas Vondra <tomas.vondra@enterprisedb.com> writes:
> On 1/3/22 16:54, Stanislav Bashkyrtsev wrote:
>> - If I put a breakpoint before I start the process then everything works
>> fine
>> - But if I put/remove a breakpoint after it's fully initialized - the
>> process just stops

> Why do you think postgres quits? AFAIK CLion uses gdb or lldb for
> debugging, which are the debugger of choice for many (most?) hackers on
> this list. So that should work fine.

FWIW, it's normal in gdb that if you attach to an existing process,
the process stops until you say "continue".  I know nothing of CLion,
but it likely follows that convention too.

                        regards, tom lane

pgsql-hackers by date:

Previous
From: SATYANARAYANA NARLAPURAM
Date:
Subject: Re: pg_receivewal fail to streams when the partial file to write is not fully initialized present in the wal receiver directory
Next
From: Alvaro Herrera
Date:
Subject: Re: [PATCH] pg_stat_toast v6