From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1645 invoked by alias); 14 Jul 2011 17:41:50 -0000 Received: (qmail 1630 invoked by uid 22791); 14 Jul 2011 17:41:48 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_DB X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Jul 2011 17:41:13 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6EHfBGF027278 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 14 Jul 2011 13:41:11 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p6EHfBWO002599; Thu, 14 Jul 2011 13:41:11 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p6EHf9x0016333; Thu, 14 Jul 2011 13:41:10 -0400 From: Tom Tromey To: Sanjoy Das Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 2/2] Add symbol-handling callbacks to the jit-reader interface. References: <1310588446-23904-1-git-send-email-sanjoy@playingwithpointers.com> <1310588446-23904-2-git-send-email-sanjoy@playingwithpointers.com> Date: Thu, 14 Jul 2011 17:54:00 -0000 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") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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-07/txt/msg00373.txt.bz2 >>>>> "Sanjoy" == Sanjoy Das 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 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