From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by sourceware.org (Postfix) with ESMTPS id 0F9093858C78 for ; Wed, 19 Jul 2023 23:54:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F9093858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-570877f7838so3052067b3.0 for ; Wed, 19 Jul 2023 16:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689810852; x=1690415652; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=PqSbrmN5iBRDXz/csZjrZfVOWMQOwbuaCi4sY9qeC98=; b=Yv4r22gBWJ/0D5KNz3dnXBHephOqQJP95c9hhVd0iQ2zoJJxit04UeSsZUfb4KufKX jcMe+tBlo+g1XWbqMBXOMI8sVHQ3re5FboWgnoN3Pt55AUD8+7iVsl8ewb8pAxKS605n o1vc9s+/WDjZ/ICSbu89XEvo+qccv+j4cDQJinS2cV/XGuYT7pg4506CYfzRjnr8UWE2 xjTVljDuAqZ290qK/VJR6K0hAnuL1iskByv7RgB3Jtj3vqf5lRFDO6QcAzkvycU68Zbj NXzTzRRJEZDSAJ8kabm0rhcYCfQ27xNr9aUmQ2/EB8kMqkClAFS9yQpYVibl5sy9hFt3 iXcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689810852; x=1690415652; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=PqSbrmN5iBRDXz/csZjrZfVOWMQOwbuaCi4sY9qeC98=; b=VfEcfrasstAn0cc1kzI2AoIDf1hoNRMfP7bPRpibWfUAGXxC2tjxZVHOaVrIo8WIi4 zYkKghTx1xcEfT1zoggHcgZJAV4EyjNtRE8gHhQojE0R6hYIXe2NTxH5QScCQlaBn3v6 2Zgb4FsuUwuGIbSIjNRd8tHqxWSovuepOk9tKemnfPv6yb5kEoQ4321D6mYSf86cnvYA s4smM/lSl7d4CQjQHt553Hymjqxj4E1a5qoIUG3E/udpOS0euSGNsSNHohsA1aWl0ToA wnDwEOIkhe2zrnonUl9zosXZLqbAZmZxihgWghyUzsBILHKSZzW+cdGDYtIHHAZPZyB5 AlaQ== X-Gm-Message-State: ABy/qLanXiRQGJxt+3ZIukuAmSqATay+rO8HWICl8o+dkefsOcBIlQl6 PEx6RqFFcu07Bo74MA7vo62M9mO9tOC3AvNbzcmjRUU7cn0= X-Google-Smtp-Source: APBJJlFxO3bMOsMe/jSAmjG/J8gHEp1e7A17qhrbmvMx8EFrqwkaTGs8R8NY4Ra+hPY5ZPwUAdRWDHfTJ9K3CCUCHQs= X-Received: by 2002:a81:6d13:0:b0:56d:1f62:7793 with SMTP id i19-20020a816d13000000b0056d1f627793mr576569ywc.46.1689810851759; Wed, 19 Jul 2023 16:54:11 -0700 (PDT) MIME-Version: 1.0 From: Matheus Branco Borella Date: Wed, 19 Jul 2023 20:54:00 -0300 Message-ID: Subject: Disabling warnings for certain operations To: gdb@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: When a call to `target_search_memory` is made, GDB will print a warning that the memory could not be read if `simple_search_memory` is used by the target in the current inferior. While this behavior is perfectly sensible from the point of view of a user triggering the call from the GDB command line directly, that same call is also triggered by calling `gdb.Inferior.search_memory` from Python, meaning the warning in that case will be printed even if the user has no direct involvement with the call. This becomes a usability problem when Python routines like Pwndbg's search command have to scan over memory and end up hitting ranges that `target_search_memory` fails to read, and, while the search routine itself can gracefully handle that case, a string of warnings gets printed, regardless. Here is an example: ``` pwndbg> search aasdqw Searching for value: 'aasdqw' warning: Unable to access 16000 bytes of target memory at 0x7ffff7147d05, halting search. warning: Unable to access 16005 bytes of target memory at 0x7ffff7348000, halting search. warning: Unable to access 16005 bytes of target memory at 0x7ffff75b9000, halting search. warning: Unable to access 16000 bytes of target memory at 0x7ffff79a8d05, halting search. warning: Unable to access 16005 bytes of target memory at 0x7ffff7bd0000, halting search. ``` As a workaround, I've hacked around GDB a bit, and added an option in `target.c` (set through `set print-default-memory-search-warnings off`) to suppress the warning message when `simple_search_memory` is called from `default_search_memory`. Ideally, I'd like to submit some form of achieving this as a patch, but the current solution feels hacky and rough. Is there a better way to do this? Or some way to query whether a range can be read ahead of time so that calling `gdb.Inferior.search_memory` may be skipped for those ranges, avoiding the path that would trigger the warning altogether?