Re: PostgreSQL stops when adding a breakpoint in CLion

From: Stanislav Bashkyrtsev <stanislav(dot)bashkirtsev(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: PostgreSQL stops when adding a breakpoint in CLion
Date: 2022-01-03 20:26:32
Message-ID: CAMtnYL_-vTYTT-1ufkjerGX523=HGgA27XmAFbgSTRmJ1XwFWA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)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
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2022-01-03 21:03:11 Re: [PATCH] pg_stat_toast v6
Previous Message SATYANARAYANA NARLAPURAM 2022-01-03 20:10:32 Re: pg_receivewal fail to streams when the partial file to write is not fully initialized present in the wal receiver directory