From patchwork Fri Feb 20 18:05:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei-cheng, Wang" X-Patchwork-Id: 5213 Received: (qmail 27659 invoked by alias); 20 Feb 2015 18:05:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 27636 invoked by uid 89); 20 Feb 2015 18:05:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, KAM_FROM_URIBL_PCCC, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pa0-f54.google.com Received: from mail-pa0-f54.google.com (HELO mail-pa0-f54.google.com) (209.85.220.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 20 Feb 2015 18:05:18 +0000 Received: by padfb1 with SMTP id fb1so9731328pad.8 for ; Fri, 20 Feb 2015 10:05:16 -0800 (PST) X-Received: by 10.70.56.34 with SMTP id x2mr18726265pdp.127.1424455515912; Fri, 20 Feb 2015 10:05:15 -0800 (PST) Received: from [192.168.2.3] ([123.110.214.155]) by mx.google.com with ESMTPSA id qq6sm27523054pbb.20.2015.02.20.10.05.13 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Feb 2015 10:05:14 -0800 (PST) Message-ID: <54E77751.2040707@gmail.com> Date: Sat, 21 Feb 2015 02:05:05 +0800 From: Wei-cheng Wang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: "uweigand"@de.ibm.com, gdb-patches@sourceware.org Subject: [PATCH 2/2] Fast tracepoint for powerpc64le Hi, This patch adds an IPA function, jump_pad_area_hint, for giving a hint where to map jump pad buffer. addr = pagesize is too low for powerpr executable. Besides, "MAP_FIXED" flag is removed. See MMAP(2) If the memory region specified by addr and len overlaps pages of any existing mapping(s), then the overlapped part of the existing ^^^^^^^^^^^^ mapping(s) will be discarded. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Thanks, Wei-cheng --- gdb/gdbserver/ChangeLog 2015-02-20 Wei-cheng Wang * tracepoint.c (initialize_tracepoint): Calling jump_pad_area_hint() to get where to map gdb_jump_pad_buffer. Remove MAP_FIXED. * tracepoint.h (jump_pad_area_hint): Add declaration. * linux-amd64-ipa.c (jump_pad_area_hint): New function. * linux-i386-ipa.c (jump_pad_area_hint): New function. * linux-ppc-ipa.c (jump_pad_area_hint): New function. --- gdb/gdbserver/linux-amd64-ipa.c | 11 +++++++++++ gdb/gdbserver/linux-i386-ipa.c | 11 +++++++++++ gdb/gdbserver/linux-ppc-ipa.c | 12 ++++++++++++ gdb/gdbserver/tracepoint.c | 7 +++---- gdb/gdbserver/tracepoint.h | 1 + 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/gdb/gdbserver/linux-amd64-ipa.c b/gdb/gdbserver/linux-amd64-ipa.c index c27ef21..db27d2a 100644 --- a/gdb/gdbserver/linux-amd64-ipa.c +++ b/gdb/gdbserver/linux-amd64-ipa.c @@ -77,6 +77,17 @@ gdb_agent_get_raw_reg (const unsigned char *raw_regs, int regnum) return *(ULONGEST *) (raw_regs + x86_64_ft_collect_regmap[regnum]); } +/* Return the address for where to allocate buffer for jump pad. + The buffer should be close enough for tracepoints. */ + +uintptr_t +jump_pad_area_hint (void) +{ + /* Allocate scratch buffer aligned on a page boundary, at a low + address (close to the main executable's code). */ + return sysconf (_SC_PAGE_SIZE); +} + #ifdef HAVE_UST #include diff --git a/gdb/gdbserver/linux-i386-ipa.c b/gdb/gdbserver/linux-i386-ipa.c index 6381a55..1fc4bd2 100644 --- a/gdb/gdbserver/linux-i386-ipa.c +++ b/gdb/gdbserver/linux-i386-ipa.c @@ -114,6 +114,17 @@ gdb_agent_get_raw_reg (unsigned char *raw_regs, int regnum) return *(int *) (raw_regs + i386_ft_collect_regmap[regnum]); } +/* Return the address for where to allocate buffer for jump pad. + The buffer should be close enough for tracepoints. */ + +uintptr_t +jump_pad_area_hint (void) +{ + /* Allocate scratch buffer aligned on a page boundary, at a low + address (close to the main executable's code). */ + return sysconf (_SC_PAGE_SIZE); +} + #ifdef HAVE_UST #include diff --git a/gdb/gdbserver/linux-ppc-ipa.c b/gdb/gdbserver/linux-ppc-ipa.c index 34b26d0..be6919b 100644 --- a/gdb/gdbserver/linux-ppc-ipa.c +++ b/gdb/gdbserver/linux-ppc-ipa.c @@ -105,6 +105,18 @@ gdb_agent_get_raw_reg (const unsigned char *raw_regs, int regnum) + ppc_ft_collect_regmap[regnum] * REGSZ); } +/* Return the address for where to allocate buffer for jump pad. + The buffer should be close enough for tracepoints. */ + +uintptr_t +jump_pad_area_hint (void) +{ + /* Main executables are normally mapped at 256MB. Unconditional branch + can jump +/- 25-bit far (+/- 32MB), so allocate the buffer at 240MB + should be close enough in most cases. */ + return 0xf000000; +} + /* Initialize ipa_tdesc and others. */ void diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c index 2382a11..ad81d7a 100644 --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -7388,13 +7388,12 @@ initialize_tracepoint (void) #define SCRATCH_BUFFER_NPAGES 20 - /* Allocate scratch buffer aligned on a page boundary, at a low - address (close to the main executable's code). */ - for (addr = pagesize; addr != 0; addr += pagesize) + addr = jump_pad_area_hint (); + for (; addr != 0; addr += pagesize) { gdb_jump_pad_buffer = mmap ((void *) addr, pagesize * SCRATCH_BUFFER_NPAGES, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (gdb_jump_pad_buffer != MAP_FAILED) break; diff --git a/gdb/gdbserver/tracepoint.h b/gdb/gdbserver/tracepoint.h index 2adcd56..05a0c2a 100644 --- a/gdb/gdbserver/tracepoint.h +++ b/gdb/gdbserver/tracepoint.h @@ -88,6 +88,7 @@ void supply_static_tracepoint_registers (struct regcache *regcache, CORE_ADDR pc); void set_trampoline_buffer_space (CORE_ADDR begin, CORE_ADDR end, char *errmsg); +uintptr_t jump_pad_area_hint (void); extern const struct target_desc *ipa_tdesc;