From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25227 invoked by alias); 5 Jan 2011 20:02:02 -0000 Received: (qmail 25211 invoked by uid 22791); 5 Jan 2011 20:02:01 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,TW_BJ,TW_YM,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Jan 2011 20:01:55 +0000 Received: from wpaz29.hot.corp.google.com (wpaz29.hot.corp.google.com [172.24.198.93]) by smtp-out.google.com with ESMTP id p05K1qxL009624 for ; Wed, 5 Jan 2011 12:01:52 -0800 Received: from qwd6 (qwd6.prod.google.com [10.241.193.198]) by wpaz29.hot.corp.google.com with ESMTP id p05K1kF7019287 for ; Wed, 5 Jan 2011 12:01:51 -0800 Received: by qwd6 with SMTP id 6so15816311qwd.9 for ; Wed, 05 Jan 2011 12:01:50 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.95.200 with SMTP id e8mr20279187qcn.213.1294257710854; Wed, 05 Jan 2011 12:01:50 -0800 (PST) Received: by 10.220.118.80 with HTTP; Wed, 5 Jan 2011 12:01:50 -0800 (PST) In-Reply-To: <20110105193621.A8CBF190B3A@elbrus2.mtv.corp.google.com> References: <20110105193621.A8CBF190B3A@elbrus2.mtv.corp.google.com> Date: Wed, 05 Jan 2011 20:02:00 -0000 Message-ID: Subject: Re: [patch] Add "debug jit" for easier tracing of JIT support internals From: Doug Evans To: Paul Pluzhnikov Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-01/txt/msg00084.txt.bz2 On Wed, Jan 5, 2011 at 11:36 AM, Paul Pluzhnikov w= rote: > Greetings, > > This is on the rather obvious side ... > > Thanks, > > -- > Paul Pluzhnikov > > 2010-01-05 =A0Paul Pluzhnikov =A0 > > =A0 =A0 =A0 =A0* jit.c (jit_debug): New variable. > =A0 =A0 =A0 =A0(show_jit_debug): New function. > =A0 =A0 =A0 =A0(jit_register_code, jit_inferior_init): Add debug output. > =A0 =A0 =A0 =A0(_initialize_jit): Register "debug jit" command. > > > > Index: jit.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/jit.c,v > retrieving revision 1.8 > diff -u -p -r1.8 jit.c > --- jit.c =A0 =A0 =A0 1 Jan 2011 15:33:09 -0000 =A0 =A0 =A0 1.8 > +++ jit.c =A0 =A0 =A0 5 Jan 2011 19:35:32 -0000 > @@ -21,6 +21,8 @@ > > =A0#include "jit.h" > =A0#include "breakpoint.h" > +#include "command.h" > +#include "gdbcmd.h" > =A0#include "gdbcore.h" > =A0#include "observer.h" > =A0#include "objfiles.h" > @@ -48,6 +50,17 @@ static CORE_ADDR jit_descriptor_addr =3D 0 > > =A0static int registering_code =3D 0; > > +/* Non-zero if we want to see trace of jit level stuff. =A0*/ > + > +static int jit_debug =3D 0; > + > +static void > +show_jit_debug (struct ui_file *file, int from_tty, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct cmd_list_element *c, const char *val= ue) > +{ > + =A0fprintf_filtered (file, _("JIT debugging is %s.\n"), value); > +} > + > =A0/* Helper cleanup function to clear an integer flag like the one above= . =A0*/ > > =A0static void > @@ -219,6 +232,13 @@ jit_register_code (struct gdbarch *gdbar > =A0 const struct bfd_arch_info *b; > =A0 CORE_ADDR *entry_addr_ptr; > > + =A0if (jit_debug) > + =A0 =A0fprintf_unfiltered (gdb_stdlog, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "jit_register_code, symfile= _addr =3D %s, " > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "symfile_size =3D %zu\n", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 paddress (gdbarch, code_ent= ry->symfile_addr), > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 code_entry->symfile_size); > + > =A0 nbfd =3D bfd_open_from_target_memory (code_entry->symfile_addr, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 code_entry->symfile_size, gnutarget); > =A0 old_cleanups =3D make_cleanup_bfd_close (nbfd); > @@ -314,6 +334,11 @@ jit_inferior_init (struct gdbarch *gdbar > =A0 struct jit_code_entry cur_entry; > =A0 CORE_ADDR cur_entry_addr; > > + =A0if (jit_debug) > + =A0 =A0fprintf_unfiltered (gdb_stdlog, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "jit_inferior_init, registe= ring_code =3D %d\n", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 registering_code); > + > =A0 /* When we register code, GDB resets its breakpoints in case symbols = have > =A0 =A0 =A0changed. =A0That in turn calls this handler, which makes us lo= ok for new > =A0 =A0 =A0code again. =A0To avoid being re-entered, we check this flag. = =A0*/ > @@ -329,6 +354,10 @@ jit_inferior_init (struct gdbarch *gdbar > =A0 if (reg_addr =3D=3D 0) > =A0 =A0 return; > > + =A0if (jit_debug) > + =A0 =A0fprintf_unfiltered (gdb_stdlog, "jit_inferior_init, reg_addr =3D= %s\n", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 paddress (gdbarch, reg_addr= )); > + > =A0 /* Lookup the descriptor symbol and cache the addr. =A0If it is missi= ng, we > =A0 =A0 =A0assume we are not attached to a JIT and return early. =A0*/ > =A0 desc_symbol =3D lookup_minimal_symbol (jit_descriptor_name, NULL, NUL= L); > @@ -338,6 +367,11 @@ jit_inferior_init (struct gdbarch *gdbar > =A0 if (jit_descriptor_addr =3D=3D 0) > =A0 =A0 return; > > + =A0if (jit_debug) > + =A0 =A0fprintf_unfiltered (gdb_stdlog, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "jit_inferior_init, jit_des= criptor_addr =3D %s\n", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 paddress (gdbarch, jit_desc= riptor_addr)); > + > =A0 /* Read the descriptor so we can check the version number and load an= y already > =A0 =A0 =A0JITed functions. =A0*/ > =A0 jit_read_descriptor (gdbarch, &descriptor); > @@ -453,6 +487,15 @@ extern void _initialize_jit (void); > =A0void > =A0_initialize_jit (void) > =A0{ > + =A0add_setshow_zinteger_cmd ("jit", class_maintenance, &jit_debug, _("\ > +Set JIT debugging."), _("\ > +Show JIT debugging."), _("\ > +When non-zero, JIT debugging is enabled. =A0Higher numbers are more\n\ > +verbose."), > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 NULL, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 show_jit_debug, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &setdebuglist, &sho= wdebuglist); > + > =A0 observer_attach_inferior_created (jit_inferior_created_observer); > =A0 observer_attach_inferior_exit (jit_inferior_exit_hook); > =A0 jit_objfile_data =3D register_objfile_data (); > "works for me". I'd suggest removing "Higher numbers are more verbose." and while I haven't tried it, I wonder if show_jit_debug is necessary (bummer if it is, we should fix that).