public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug breakpoints/27889] jit.c:1178: internal-error: void jit_event_handler(gdbarch*, objfile*): Assertion `jiter->jiter_data != nullptr' failed.
Date: Fri, 21 May 2021 13:09:19 +0000	[thread overview]
Message-ID: <bug-27889-4717-wNjoRRJ8sf@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-27889-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=27889

--- Comment #7 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6d1a09b77a9ab52d9fc627b8f5eb952892c81f90

commit 6d1a09b77a9ab52d9fc627b8f5eb952892c81f90
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri May 21 15:09:14 2021 +0200

    [gdb/breakpoint] Fix assert in jit_event_handler

    Consider a minimal test-case test.c:
    ...
    int main (void) { return 0; }
    ...
    which we can compile into llvm byte code using clang:
    ...
    $ clang -g -S -emit-llvm --target=x86_64-unknown-unknown-elf test.c
    ...
    and then run using lli, which uses the llvm jit:
    ...
    $ lli test.ll
    ...

    If we run this under gdb, we run into an assert:
    ...
    $ gdb -q -batch -ex run --args /usr/bin/lli test.ll
    Dwarf Error: Cannot not find DIE at 0x18a936e7 \
      [from module libLLVM.so.10-10.0.1-lp152.30.4.x86_64.debug]

    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib64/libthread_db.so.1".
    src/gdb/jit.c:1178: internal-error: \
      void jit_event_handler(gdbarch*, objfile*): \
      Assertion `jiter->jiter_data != nullptr' failed.
    ...

    This is caused by the following.

    When running jit_breakpoint_re_set_internal, we first handle
    libLLVM.so.10.debug, and set a jit breakpoint.

    Next we handle libLLVM.so.10:
    ...
    (gdb) p the_objfile.original_name
    $42 = 0x2494170 "libLLVM.so.10"
    ...
    but the minimal symbols we find are from libLLVM.so.10.debug:
    ...
    (gdb) p reg_symbol.objfile.original_name
    $43 = 0x38e7c50 "libLLVM.so.10-10.0.1-lp152.30.4.x86_64.debug"
    (gdb) p desc_symbol.objfile.original_name
    $44 = 0x38e7c50 "libLLVM.so.10-10.0.1-lp152.30.4.x86_64.debug"
    ...
    and consequently, the objf_data is the one from libLLVM.so.10.debug:
    ...
          jiter_objfile_data *objf_data
            = get_jiter_objfile_data (reg_symbol.objfile);
    ...
    and so we hit this:
    ...
          if (objf_data->cached_code_address == addr)
            continue;
    ...
    and no second jit breakpoint is inserted.

    Subsequently, the jit breakpoint is triggered and handled, but when finding
    the symbol for the breakpoint address we get:
    ...
    (gdb) p jit_bp_sym.objfile.original_name
    $52 = 0x2494170 "libLLVM.so.10"
    ...

    The assert 'jiter->jiter_data != nullptr' triggers because it checks
    libLLVM.so.10 while the one with jiter_data setup is libLLVM.so.10.debug.

    This fixes the assert:
    ...
           jiter_objfile_data *objf_data
    -        = get_jiter_objfile_data (reg_symbol.objfile);
    -        = get_jiter_objfile_data (the_objfile);
    ...
    but consequently we'll have two jit breakpoints, so we also make sure we
don't
    set a jit breakpoint on separate debug objects like libLLVM.so.10.debug.

    Tested on x86_64-linux.

    gdb/ChangeLog:

    2021-05-21  Tom de Vries  <tdevries@suse.de>

            PR breakpoint/27889
            * jit.c (jit_breakpoint_re_set_internal): Skip separate debug
            objects.  Call get_jiter_objfile_data with the_objfile.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2021-05-21 13:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 10:03 [Bug gdb/27889] New: " vries at gcc dot gnu.org
2021-05-20 10:08 ` [Bug gdb/27889] " vries at gcc dot gnu.org
2021-05-20 10:40 ` vries at gcc dot gnu.org
2021-05-20 11:34 ` pafee at tycoint dot com
2021-05-20 12:10 ` vries at gcc dot gnu.org
2021-05-20 13:23 ` [Bug breakpoints/27889] " vries at gcc dot gnu.org
2021-05-20 13:32 ` vries at gcc dot gnu.org
2021-05-20 13:36 ` vries at gcc dot gnu.org
2021-05-20 15:30 ` vries at gcc dot gnu.org
2021-05-21 13:09 ` cvs-commit at gcc dot gnu.org [this message]
2021-05-21 13:19 ` vries at gcc dot gnu.org
2022-06-22 19:08 ` hector.oron at gmail dot com
2022-06-22 19:10 ` hector.oron at gmail dot com
2022-06-22 19:13 ` guillaume at morinfr dot org
2022-06-23 12:20 ` vries at gcc dot gnu.org
2022-06-23 13:36 ` guillaume at morinfr dot org

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=bug-27889-4717-wNjoRRJ8sf@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).