public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "edwintorok at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug breakpoints/11094] New: cannot reexecute programs using the GDB JIT interface in shared libs
Date: Tue, 15 Dec 2009 21:01:00 -0000	[thread overview]
Message-ID: <20091215210108.11094.edwintorok@gmail.com> (raw)

When trying to debug a program (for example ClamAV) that uses the GDB JIT inside
a shared lib (for example LLVM in libclamavc++.so), then I cannot reexecute the
program.
This happens when no code was registered with the JIT interface, such as when I
simply put a breakpoint on main, and try to run twice, the 2nd run will fail
telling me it couldn't reset breakpoint -4 (or -2).

I've created a small testcase to show this problem (will attach), here is the
output:
--- shared.c:                                                                
#include <stdint.h>                                                          
typedef enum                                                                 
{                                                                            
  JIT_NOACTION = 0,                                                          
  JIT_REGISTER_FN,                                                           
  JIT_UNREGISTER_FN                                                          
} jit_actions_t;                                                             

struct jit_code_entry
{                    
  struct jit_code_entry *next_entry;
  struct jit_code_entry *prev_entry;
  const char *symfile_addr;         
  uint64_t symfile_size;            
};                                  

struct jit_descriptor
{                    
  uint32_t version;  
  /* This type should be jit_actions_t, but we use uint32_t
     to be explicit about the bitwidth.  */                
  uint32_t action_flag;                                    
  struct jit_code_entry *relevant_entry;                   
  struct jit_code_entry *first_entry;                      
};                                                         

/* GDB puts a breakpoint in this function.  */
void __attribute__((noinline)) __jit_debug_register_code() { };

/* Make sure to specify the version statically, because the
   debugger may check the version before we can set it.  */
struct jit_descriptor __jit_debug_descriptor = { 1, 0, 0, 0 };
int foo() {                                                   
    return 4;                                                 
}                                                             

--- bp_minus4.c:
int foo();      
int main()      
{               
    return foo();
}                

gcc (Debian 4.4.2-5) 4.4.2
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

GNU gdb (GDB) 7.0-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/edwin/gdbbug/bp_minus4...done.
Breakpoint 1 at 0x4005f8: file bp_minus4.c, line 4.

Breakpoint 1, main () at bp_minus4.c:4
4           return foo();
/home/edwin/gdbbug/gdb.tmp:3: Error in sourced command file:
Warning:
Cannot insert breakpoint -2.
Error accessing memory address 0x7ffff7dfa5dc: Input/output error.

(gdb) maint info breakpoints
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x00000000004005f8 in main at bp_minus4.c:4
-2      jit events     keep y   0x00007ffff7dfa5dc
-9      shlib events   keep y   0x000000381da0dcc0 <*__GI__dl_debug_state>
(gdb) quit
A debugging session is active.

        Inferior 2 [process 18147] will be killed.

Quit anyway? (y or n) y

-- 
           Summary: cannot reexecute programs using the GDB JIT interface in
                    shared libs
           Product: gdb
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: breakpoints
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: edwintorok at gmail dot com
                CC: gdb-prs at sourceware dot org
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=11094

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


             reply	other threads:[~2009-12-15 21:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-15 21:01 edwintorok at gmail dot com [this message]
2009-12-15 21:01 ` [Bug breakpoints/11094] " edwintorok at gmail dot com
2009-12-15 21:02 ` edwintorok at gmail dot com
2009-12-15 21:03 ` edwintorok at gmail dot com
2009-12-22 14:14 ` edwintorok at gmail dot com
2009-12-22 16:33 ` ppluzhnikov at google dot com
2009-12-22 17:00 ` edwintorok at gmail dot com
2009-12-22 23:39 ` ppluzhnikov at google dot com
2010-02-20 21:33 ` reid dot kleckner at gmail dot com
2010-02-20 21:47 ` reid dot kleckner at gmail dot com
2010-03-21 20:39 ` edwintorok at gmail dot com
2010-03-22 17:37 ` tromey at redhat dot com

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=20091215210108.11094.edwintorok@gmail.com \
    --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).