git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to build to debug with gdb?

From
Matheus Tavares Bernardino <matheus.bernardino@usp.br>
Date
Aug 27, 2019, 17:55 UTC
Message-ID
<CAHd-oW6MtoYAwv36_Jsx5qQzvLguXdvrA6NRA+D3ayHGmfVSqw@mail.gmail.com>
In-Reply-To
<20190827162725.GA29263@instance-template-2.europe-west6-a.c.vaulted-journal-250706.internal>
On Tue, Aug 27, 2019 at 1:27 PM Giuseppe Crino' <giuscri@gmail.com> wrote:
Show 6 quoted lines
>
> Hello, to debug some issues I built and installed git via
>
> $ make prefix=/usr/local DEVELOPER=1 CFLAGS="-O0 -g"
> $ sudo make install
> $ git --version # git version 2.23.0.40.g4d8aada92f

Hmm, could it be perhaps that CFLAGS is being overwritten? To debug Git with GDB I always add this to my config.mak file:

CFLAGS += -g3 -O0 LDFLAGS += -g3 -O0

And then just compile with `make`. Maybe give it a try?
Show 21 quoted lines
> But it seems there's still some optimization going on that prevents gdb from working correctly.
>
> For example
>
> (gdb) b builtin/config.c:752
> Breakpoint 1 at 0x43942: file builtin/config.c, line 752.
> (gdb) r config --global --edit
> Starting program: /usr/local/bin/git config --global --edit
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/x86_64-linux-gnu/libth
> read_db.so.1".
>
> Breakpoint 1, cmd_config (argc=0, argv=<optimized out>,
>     prefix=<optimized out>) at builtin/config.c:753
>     753                             if (fd >= 0) {
>     (gdb) p fd
>     $1 = <optimized out>
>
>  What am I missing?
>
>  -Giuseppe
Previous: Giuseppe Crino'Next: Randall S. Becker
Message 2 of 9 in “How to build to debug with gdb?”
  1. Giuseppe Crino'Aug 27, 2019
  2. Matheus Tavares BernardinoAug 27, 2019
  3. Randall S. BeckerAug 27, 2019
  4. Johannes SixtAug 27, 2019
  5. Giuseppe Crino'Aug 28, 2019
  6. SZEDER GáborAug 28, 2019
  7. Giuseppe Crino'Aug 28, 2019
  8. Giuseppe Crino'Aug 28, 2019
  9. SZEDER GáborAug 27, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.