Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Sanjoy Das <sanjoy@playingwithpointers.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] Add symbol-handling callbacks to the jit-reader interface.
Date: Thu, 14 Jul 2011 17:54:00 -0000	[thread overview]
Message-ID: <m3y600dakq.fsf@fleche.redhat.com> (raw)
In-Reply-To: <1310588446-23904-2-git-send-email-sanjoy@playingwithpointers.com>	(Sanjoy Das's message of "Thu, 14 Jul 2011 01:50:46 +0530")

>>>>> "Sanjoy" == Sanjoy Das <sanjoy@playingwithpointers.com> writes:

Sanjoy> Implements the callbacks in `struct gdbjit_symtab_callbacks'. This
Sanjoy> will allow the JIT debug info reader to be able to parse the debug
Sanjoy> info and actually push the symbols into GDB.

Sanjoy> +#include <dlfcn.h>

I assume this isn't portable.

You could either lift the needed code from GCC's plugin interface, or I
suppose use libtool's libltdl.

Sanjoy> +/* The environment variable we poke at to get the file name of the shared object
Sanjoy> +   to load. */
Sanjoy> +
Sanjoy> +static const char *jit_dbg_reader_so_name_env = "JIT_DEBUG_READER";

I don't think environment variables are a good way to go.

Either it should be automatic in a trusted-library scenario, or it
should require a command from the user.

Sanjoy> +static const char *jit_init_reader_sym = "gdbjit_init_reader";

Instead of a separate symbol for each function, how about just a single
function that we call that returns a struct full of function pointers?

Sanjoy> +struct jit_dbg_reader
Sanjoy> +{
Sanjoy> +  jit_init_reader_fn *init;
Sanjoy> +  jit_read_debug_info_fn *read;
Sanjoy> +  jit_unwind_frame_fn *unwind;
Sanjoy> +  jit_get_frame_id_fn *get_frame_id;
Sanjoy> +  jit_destroy_reader_fn *destroy;
Sanjoy> +
Sanjoy> +  void *handle, *private_data;
Sanjoy> +};

A struct and all its fields should have comments.

Sanjoy> +  handle = dlopen (file_name, RTLD_NOW);
Sanjoy> +  if (!handle)
Sanjoy> +    goto cleanup;

I think there is a GNU requirement that plugins should export a symbol
like "plugin_is_GPL_compatible".  See GCC.

Sanjoy> +static struct gdbjit_symtab *
Sanjoy> +jit_symtab_open_impl (struct gdbjit_symtab_callbacks *cb, const char *file_name)
Sanjoy> +{
Sanjoy> +  struct gdbjit_symtab *ret = XZALLOC (struct gdbjit_symtab);

Does anything ever free this?  I couldn't find it.

Sanjoy> +/* Returns true if the block corrensponding to old should be placed before the

Typo, "corresponding".

Sanjoy> +   block corrensponding to new in the final blockvector. */

Likewise.

Sanjoy> +static struct gdbjit_block *
Sanjoy> +jit_new_block_impl (struct gdbjit_symtab_callbacks *cb,
Sanjoy> +                    struct gdbjit_symtab *symtab,
Sanjoy> +                    struct gdbjit_block *parent,
Sanjoy> +                    CORE_ADDR begin, CORE_ADDR end, const char *name)
Sanjoy> +{
Sanjoy> +  struct gdbjit_block *block = XZALLOC (struct gdbjit_block);
Sanjoy> +
Sanjoy> +  (void) cb;

Don't do that.

Sanjoy> +  if (stab->linetable) {

Brace placement.

Sanjoy> +  if (target_read_memory (target_mem, gdb_mem, sz))

This has a QUIT in it, so it can presumably throw an exception if the
user C-c's at exactly the wrong moment.

So I think this needs some kind of TRY_CATCH wrapper.  There's another
case of this as well.


I found it quite hard to read this patch for some reason; maybe I'm just
having a bad day.  Anyway I feel certain I have missed various important
things.

Tom


  reply	other threads:[~2011-07-14 17:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-13 20:23 [PATCH 1/2] jit-reader.h: describe interface implemented by the JIT readers Sanjoy Das
2011-07-13 20:23 ` [PATCH 2/2] Add symbol-handling callbacks to the jit-reader interface Sanjoy Das
2011-07-14 17:54   ` Tom Tromey [this message]
2011-07-22 16:42     ` Joel Brobecker
2011-07-22 17:12       ` Tom Tromey
2011-07-14 17:43 ` [PATCH 1/2] jit-reader.h: describe interface implemented by the JIT readers Tom Tromey

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=m3y600dakq.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sanjoy@playingwithpointers.com \
    /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