From patchwork Sun Nov 26 23:00:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominik Czarnota X-Patchwork-Id: 24542 Received: (qmail 58059 invoked by alias); 26 Nov 2017 23:01:39 -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 58034 invoked by uid 89); 26 Nov 2017 23:01:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Search, halting, hey X-HELO: mail-wm0-f65.google.com Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 26 Nov 2017 23:01:37 +0000 Received: by mail-wm0-f65.google.com with SMTP id b189so30744722wmd.0 for ; Sun, 26 Nov 2017 15:01:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=XjsBdtSSKWvY6hgE7b1y6dxMFzi+4Koq9tLT1ifIIng=; b=EJvI9/ZY71o0VrrnUYhj/iz6CyY86CFmEyPeCDaaPf/xQ5SuflrZ9lctdP04Ad6/+D 2PajV9quGD6sm/bklwrVVFapIW6Q217OYUPi4Z1HA+LxRxHnbGDyR9trX/XSYUWpmzzx rjipMBjVqhDmnc/mxSlmsMHSfW/Z26qcZJsjiEDDIhtjh3+ZoP2Ugeo+WjpW/ApeLLCj 4gZZn0pbp0r32kwenWMw1BXdhEl7TFfkXyf2CT3RqHTUwMO8gd8h8Yk2sQVyYkcvaBmB QXj5AqU5bNpkrcWgzU57D8IwsBaWgGlemKErnlKMaqnjDqMUgRjP4+LSvj2FEPob2Kq4 3HwA== X-Gm-Message-State: AJaThX5esbyTzNYUTSC4npeh1MJp/mES0NVpwbV6vnuBFzQBsBf/0CV5 F5+HnOjosXAQNk9XX3kntC7EUHLUGXaFztzhzQ6VhPvo X-Google-Smtp-Source: AGs4zMa1YSm5sg1/HpORgarCDtek8o/VQ4hKwXEGA5VE3lQ9L/nJvhdGR7b4OoFBaVvcUSK8/SWbs0EY6i/205iZygw= X-Received: by 10.80.187.99 with SMTP id y90mr44585698ede.154.1511737295069; Sun, 26 Nov 2017 15:01:35 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.134.45 with HTTP; Sun, 26 Nov 2017 15:00:54 -0800 (PST) From: Dominik Czarnota Date: Mon, 27 Nov 2017 00:00:54 +0100 Message-ID: Subject: Add possibility to disable showing search memory access warnings To: gdb-patches@sourceware.org Hey, This patches adds a `disable-search-warnings` parameter that can be set to make memory searching not displaying warnings like: `Unable to access X bytes of target memory at Y, halting search.` As far as I know this is used by `find` command and Python API's `inferior.search_memory` method. The latter is used in GDB plugins like pwndbg (https://github.com/pwndbg/pwndbg) where we have a `search` command that lets one search all memory for given values. By the way, is there some kind of code linter for Gdb? What's the best way to stay within the same coding convention gdb uses? It seems to me that some code mixes tabs with spaces, is that some relict of the past? Should new code use one or another? If so, which one? Thanks, disconnect3d gdb/ChangeLog: * target.c: Add disable_search_warnings boolean parameter. diff --git a/gdb/target.c b/gdb/target.c index 3bfc8b5aef..a79e1ce5ac 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -162,6 +162,18 @@ int may_insert_fast_tracepoints = 1; int may_stop = 1; + +/* Whether not to show search memory access warnings. */ + +int disable_search_warnings = 0; + +static void +show_disable_search_warnings (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("Search memory access warnings are %s.\n"), value); +} + /* Non-zero if we want to see trace of target level stuff. */ static unsigned int targetdebug = 0; @@ -2345,9 +2357,10 @@ simple_search_memory (struct target_ops *ops, search_buf.data (), start_addr, search_buf_size) != search_buf_size) { - warning (_("Unable to access %s bytes of target " - "memory at %s, halting search."), - pulongest (search_buf_size), hex_string (start_addr)); + if (!disable_search_warnings) + warning (_("Unable to access %s bytes of target " + "memory at %s, halting search."), + pulongest (search_buf_size), hex_string (start_addr)); return -1; } @@ -2400,10 +2413,10 @@ simple_search_memory (struct target_ops *ops, &search_buf[keep_len], read_addr, nr_to_read) != nr_to_read) { - warning (_("Unable to access %s bytes of target " - "memory at %s, halting search."), - plongest (nr_to_read), - hex_string (read_addr)); + if (!disable_search_warnings) + warning (_("Unable to access %s bytes of target " + "memory at %s, halting search."), + pulongest (nr_to_read), hex_string (read_addr)); return -1; } @@ -4084,6 +4097,17 @@ verbose."), show_targetdebug, &setdebuglist, &showdebuglist); + add_setshow_boolean_cmd ("disable-search-warnings", class_support, + &disable_search_warnings, _("\ +Set mode for disabling search memory warnings."), _("\ +Show mode for disabling search memory warnings."), _("\ +When this mode is on, both find command and Python API's \n\ +inferior.search_memory function won't warn about being \n\ +unable to access target memory. "), + NULL, + show_disable_search_warnings, + &setlist, &showlist); + add_setshow_boolean_cmd ("trust-readonly-sections", class_support, &trust_readonly, _("\ Set mode for reading from readonly sections."), _("\