From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19016 invoked by alias); 16 May 2013 14:47:00 -0000 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 Received: (qmail 19006 invoked by uid 89); 16 May 2013 14:47:00 -0000 X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,TW_FN autolearn=ham version=3.3.1 Received: from gbenson.demon.co.uk (HELO blade.nx) (80.177.220.214) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 16 May 2013 14:46:59 +0000 Received: by blade.nx (Postfix, from userid 500) id A5990263EAE; Thu, 16 May 2013 15:46:56 +0100 (BST) Date: Thu, 16 May 2013 14:47:00 -0000 From: Gary Benson To: gdb-patches@sourceware.org Subject: [RFA 1/7] Probes API convenience patch Message-ID: <20130516144656.GB2105@blade.nx> Mail-Followup-To: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="uuKVzAmB+c+zQlhu" Content-Disposition: inline In-Reply-To: <20130516144340.GA2105@blade.nx> X-Virus-Found: No X-SW-Source: 2013-05/txt/msg00625.txt.bz2 --uuKVzAmB+c+zQlhu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 203 This patch exposes part of the probes API in a more convenient way. I've included it for completeness, but it has previously been approved: http://www.cygwin.com/ml/gdb-patches/2012-07/msg00340.html --uuKVzAmB+c+zQlhu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="rtld-probes-1-convenience.patch" Content-length: 2849 2013-05-16 Gary Benson * probe.h (get_probe_argument_count): New declaration. (evaluate_probe_argument): Likewise. * probe.c (get_probe_argument_count): New function. (evaluate_probe_argument): Likewise. (probe_safe_evaluate_at_pc): Use the above new functions. diff --git a/gdb/probe.h b/gdb/probe.h index 8d44ca2..1d29b87 100644 --- a/gdb/probe.h +++ b/gdb/probe.h @@ -214,6 +214,16 @@ extern void info_probes_for_ops (char *arg, int from_tty, extern struct cmd_list_element **info_probes_cmdlist_get (void); +/* Return the argument count of the specified probe. */ + +extern unsigned get_probe_argument_count (struct probe *probe); + +/* Evaluate argument N of the specified probe. N must be between 0 + inclusive and get_probe_argument_count exclusive. */ + +extern struct value *evaluate_probe_argument (struct probe *probe, + unsigned n); + /* A convenience function that finds a probe at the PC in FRAME and evaluates argument N, with 0 <= N < number_of_args. If there is no probe at that location, or if the probe does not have enough arguments, diff --git a/gdb/probe.c b/gdb/probe.c index 77f3b13..a61f4ea 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -608,28 +608,55 @@ info_probes_command (char *arg, int from_tty) /* See comments in probe.h. */ +unsigned +get_probe_argument_count (struct probe *probe) +{ + const struct sym_probe_fns *probe_fns; + + gdb_assert (probe->objfile != NULL); + gdb_assert (probe->objfile->sf != NULL); + + probe_fns = probe->objfile->sf->sym_probe_fns; + + gdb_assert (probe_fns != NULL); + + return probe_fns->sym_get_probe_argument_count (probe); +} + +/* See comments in probe.h. */ + +struct value * +evaluate_probe_argument (struct probe *probe, unsigned n) +{ + const struct sym_probe_fns *probe_fns; + + gdb_assert (probe->objfile != NULL); + gdb_assert (probe->objfile->sf != NULL); + + probe_fns = probe->objfile->sf->sym_probe_fns; + + gdb_assert (probe_fns != NULL); + + return probe_fns->sym_evaluate_probe_argument (probe, n); +} + +/* See comments in probe.h. */ + struct value * probe_safe_evaluate_at_pc (struct frame_info *frame, unsigned n) { struct probe *probe; - const struct sym_probe_fns *probe_fns; unsigned n_args; probe = find_probe_by_pc (get_frame_pc (frame)); if (!probe) return NULL; - gdb_assert (probe->objfile != NULL); - gdb_assert (probe->objfile->sf != NULL); - gdb_assert (probe->objfile->sf->sym_probe_fns != NULL); - - probe_fns = probe->objfile->sf->sym_probe_fns; - n_args = probe_fns->sym_get_probe_argument_count (probe); - + n_args = get_probe_argument_count (probe); if (n >= n_args) return NULL; - return probe_fns->sym_evaluate_probe_argument (probe, n); + return evaluate_probe_argument (probe, n); } /* See comment in probe.h. */ --uuKVzAmB+c+zQlhu--