From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14396 invoked by alias); 21 May 2014 07:01:56 -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 14371 invoked by uid 89); 21 May 2014 07:01:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga11.intel.com Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 May 2014 07:01:27 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 21 May 2014 00:01:26 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 21 May 2014 00:01:24 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s4L71NBB010752; Wed, 21 May 2014 08:01:23 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id s4L71NJ3004300; Wed, 21 May 2014 09:01:23 +0200 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id s4L71N8J004296; Wed, 21 May 2014 09:01:23 +0200 From: Markus Metzger To: palves@redhat.com Cc: gdb-patches@sourceware.org Subject: [PATCH v3 3/3] btrace, vdso: add vdso target sections Date: Wed, 21 May 2014 07:01:00 -0000 Message-Id: <1400655682-4014-3-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1400655682-4014-1-git-send-email-markus.t.metzger@intel.com> References: <1400655682-4014-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2014-05/txt/msg00456.txt.bz2 When loading symbols for the vdso, also add its sections to target_sections. This fixes an issue with record btrace where vdso instructions could not be disassembled during replay. 2014-05-21 Markus Metzger * symfile-mem.c (symbol_file_add_from_memory): Add BFD sections. testsuite/ * gdb.btrace/vdso.c: New. * gdb.btrace/vdso.exp: New. --- gdb/symfile-mem.c | 18 +++++++++++++ gdb/testsuite/gdb.btrace/vdso.c | 30 ++++++++++++++++++++++ gdb/testsuite/gdb.btrace/vdso.exp | 53 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 gdb/testsuite/gdb.btrace/vdso.c create mode 100644 gdb/testsuite/gdb.btrace/vdso.exp diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c index 3f09c4d..b29421e 100644 --- a/gdb/symfile-mem.c +++ b/gdb/symfile-mem.c @@ -92,6 +92,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, struct section_addr_info *sai; unsigned int i; struct cleanup *cleanup; + struct target_section *sections, *sections_end, *tsec; if (bfd_get_flavour (templ) != bfd_target_elf_flavour) error (_("add-symbol-file-from-memory not supported for this target")); @@ -131,6 +132,23 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, from_tty ? SYMFILE_VERBOSE : 0, sai, OBJF_SHARED, NULL); + sections = NULL; + sections_end = NULL; + + if (build_section_table (nbfd, §ions, §ions_end) == 0) + { + make_cleanup (xfree, sections); + + /* Adjust the target section addresses by the load address. */ + for (tsec = sections; tsec != sections_end; ++tsec) + { + tsec->addr += loadbase; + tsec->endaddr += loadbase; + } + + add_target_sections (&nbfd, sections, sections_end); + } + /* This might change our ideas about frames already looked at. */ reinit_frame_cache (); diff --git a/gdb/testsuite/gdb.btrace/vdso.c b/gdb/testsuite/gdb.btrace/vdso.c new file mode 100644 index 0000000..e16a3c6 --- /dev/null +++ b/gdb/testsuite/gdb.btrace/vdso.c @@ -0,0 +1,30 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2014 Free Software Foundation, Inc. + + Contributed by Intel Corp. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +int +main (void) +{ + struct timeval tv; + + gettimeofday (&tv, 0); /* main.1. */ + + return 0; /* main.2. */ +} diff --git a/gdb/testsuite/gdb.btrace/vdso.exp b/gdb/testsuite/gdb.btrace/vdso.exp new file mode 100644 index 0000000..34a5bf0 --- /dev/null +++ b/gdb/testsuite/gdb.btrace/vdso.exp @@ -0,0 +1,53 @@ +# This testcase is part of GDB, the GNU debugger. +# +# Copyright 2014 Free Software Foundation, Inc. +# +# Contributed by Intel Corp. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# +# Test that we can access the vdso memory during replay for stepping. + +# check for btrace support +if { [skip_btrace_tests] } { return -1 } + +# start inferior +standard_testfile +if [prepare_for_testing $testfile.exp $testfile $srcfile] { + return -1 +} +if ![runto_main] { + return -1 +} + +# capture the disassembly of gettimeofday while live debugging +set live_gettimeofday [capture_command_output "disassemble gettimeofday" ""] + +# trace the test code +gdb_test_no_output "record btrace" +gdb_test "next" "main\.2.*" + +with_test_prefix "replay" { + # capture the disassembly of gettimeofday while replaying + gdb_test "record goto begin" "main\.1.*" + set replay_gettimeofday [capture_command_output "disassemble gettimeofday" ""] + + # the two disassemblys must be identical + if ![string compare $live_gettimeofday $replay_gettimeofday] { + pass "disassemble gettimeofday" + } else { + fail "disassemble gettimeofday" + } +} -- 1.8.3.1