From patchwork Tue Jul 23 06:49:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuan-Ying Lee X-Patchwork-Id: 13739590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE003C3DA49 for ; Tue, 23 Jul 2024 06:49:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DCCD6B00C6; Tue, 23 Jul 2024 02:49:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28D1E6B00C7; Tue, 23 Jul 2024 02:49:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01BA46B00C8; Tue, 23 Jul 2024 02:49:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D64C06B00C6 for ; Tue, 23 Jul 2024 02:49:45 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7A88681D19 for ; Tue, 23 Jul 2024 06:49:45 +0000 (UTC) X-FDA: 82370091930.05.485BEBC Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by imf15.hostedemail.com (Postfix) with ESMTP id 69AD9A000E for ; Tue, 23 Jul 2024 06:49:43 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=canonical.com header.s=20210705 header.b=sAaNEfTP; spf=pass (imf15.hostedemail.com: domain of kuan-ying.lee@canonical.com designates 185.125.188.122 as permitted sender) smtp.mailfrom=kuan-ying.lee@canonical.com; dmarc=pass (policy=none) header.from=canonical.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721717322; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=p8WnU9klM9imNroT/ir5Cxun9HbZF+Zv15lDq/QcnHE=; b=pRMwOlLIinSe1CMu4HaIpJe39P2PAT+Q1hvyvtPKYe2dkDDfle5koXZ7C7YX7U78A+uh1w MfR1IO4ESfgYeb/EPHWchqCSY9SMOBIvAcFZ9GCZ9y8hfbpyrFIc1MCVX1Cq4/GJmT0TKi ol8F8RDEPAz1S2NLgEhGH5mv2KbOL/4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=canonical.com header.s=20210705 header.b=sAaNEfTP; spf=pass (imf15.hostedemail.com: domain of kuan-ying.lee@canonical.com designates 185.125.188.122 as permitted sender) smtp.mailfrom=kuan-ying.lee@canonical.com; dmarc=pass (policy=none) header.from=canonical.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721717322; a=rsa-sha256; cv=none; b=KMeXL1+hV3j1+KeztvEeW2ewPDUSdIPaI0qjbkPdiOUDEN9U8xFzFsRoyr8kzOK/S89HhR Y6OQmJF9rMOaZ1Qf533nMJh1e0n8vHR82lMO3usPwie8a5YR28PjWdNFawRui4alar92lE e8L7ty27hZSFvpRmKMpzEH27DmUWAqA= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id E06B03F69B for ; Tue, 23 Jul 2024 06:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1721717381; bh=p8WnU9klM9imNroT/ir5Cxun9HbZF+Zv15lDq/QcnHE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sAaNEfTPngXFMsXzwBKH8RlOqLk6C6WZjYnTf+8NdUhMJ2uQEiu/+ajmfmWDTu0u8 xAVBHrN3EMpsvLdJnwBYDKJBb7UQcCXkMPst+cIKbJHBOUNqfxxZziTTIYHdebCMqj kFgPWKNUFZr8kx5Uu2fJwb/kVQ+iDSK/RtGn8MFH8015UMsK0n7RE01p/tHmHUHVl7 r6Bsq8clz59+i5Q3AJ8xwVTNAlfPxK8ZOqgUS3JzHhrELNFX+Ny4133PUdtdIUnwuL a6BMvwE0LKFVxfeCi0buQxSXBJ0TFh2MLi6B723NEv2ACJZlREX9ctKl5MfkwTKTtW Wu4LotgoJ2Mvg== Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-2cb576921b6so4526479a91.1 for ; Mon, 22 Jul 2024 23:49:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721717380; x=1722322180; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p8WnU9klM9imNroT/ir5Cxun9HbZF+Zv15lDq/QcnHE=; b=DkXJD/hH3oHRhPlVgs95Amr9MF6rkY2tvEvSunwGvdk+hMBncsv5mh0hpbaLQF0KSK sDQyiuH49bkHoXLWH677qmSgweNGBRrGEZjFoVwyEU9pCHqBqzXdHCX9zMIWGusos5j/ p8qgKhQCzZOyRNcFvyNQe+IlcIEm9X5yswjILN/6JfC8lNvKoLu9Sp64jKUtoKapnWSY 8g8ZsacK7YrhyvPzqoQk0OTnkKwzBjd2RF9at6n0OM7NP6lKUdVaKtRbYpoeqcM0t3WW pvlvGl1/K860Ti0TjpwtVw72gUv6z2BAobhwsaYolevXgqsV4thHPWTUArtjdU1rNjTy HDHw== X-Gm-Message-State: AOJu0YycKrIgeA+gx/4WzoqKMYsYsBpVdEgtbvHN+sZhvs01eS8irDzl 7kZscAyXzc/gGc0tsUPMSJxbImn2j1MV9CCIGHym4+KIgD7KWbQAQb2tLXR2qKQI1Ek5iIAJnNY TrlZ2Ki+69//dpcXy1+8f7yAzPQ7xFc6S5MWwsuwRVkytjOOt/2oK+kwwSOjFdZbk X-Received: by 2002:a17:90a:734b:b0:2c9:90f5:cfca with SMTP id 98e67ed59e1d1-2cd274dabb9mr4925273a91.42.1721717380519; Mon, 22 Jul 2024 23:49:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAsMwdXkeKQBJPyfug9/lQ1wFoE87H0ZOyB6iwoKjmcAasHQ62oHoidxTUkiX05wTzPVeRCA== X-Received: by 2002:a17:90a:734b:b0:2c9:90f5:cfca with SMTP id 98e67ed59e1d1-2cd274dabb9mr4925257a91.42.1721717380184; Mon, 22 Jul 2024 23:49:40 -0700 (PDT) Received: from kylee-ThinkPad-E16-Gen-1.. ([122.147.171.160]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ccf7c5391bsm8354749a91.24.2024.07.22.23.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 23:49:40 -0700 (PDT) From: Kuan-Ying Lee To: kuan-ying.lee@canonical.com, Andrew Morton , Jan Kiszka , Kieran Bingham Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/5] scripts/gdb: Add 'lx-stack_depot_lookup' command. Date: Tue, 23 Jul 2024 14:49:00 +0800 Message-Id: <20240723064902.124154-5-kuan-ying.lee@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723064902.124154-1-kuan-ying.lee@canonical.com> References: <20240723064902.124154-1-kuan-ying.lee@canonical.com> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 69AD9A000E X-Stat-Signature: o1e33t59q3gmy18wny75qn6t5kukdwdm X-Rspam-User: X-H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fmU6RvrKTE15YGPk/OPshgk7H5i5+LeHFDyOG+jx9vCI6CRQIXo3+ZgUuqjyjeF9wAAVxlao77K2JGuwhR4EX3cK/j4qJz/ZeXFNIM0+1XwYCLBCmSIwH8OdDO59anXq2OZ3WurYipLz1zggCSjfqDhD9CmE8E6Cpc/6HKEw9tu59ve9ftvHm26ethX3/c3Ky94VECHDTj0UaHx9/CPCGsn2L1NEz+n2v/lw6NW6SqxNlNu9KQD1/P3VOfCBHYgOuK4js3FTjxSTm7SPi15Jmh4uH7QqebEBArNzGHoXJT+6b3C/38ao8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This command allows users to quickly retrieve a stacktrace using a handle obtained from a memory coredump. Example output: (gdb) lx-stack_depot_lookup 0x00c80300 0xffff8000807965b4 : mov x20, x0 0xffff800081a077d8 : mov x1, x0 0xffff800081a079a0 : cbnz w0, 0xffff800081a07968 0xffff800082f4a3fc : ldr x19, [sp, #16] 0xffff800080a0fb34 : ldp x3, x4, [sp, #96] 0xffff800080a0a550 : ldp x19, x20, [sp, #16] 0xffff8000808e7b40 : mov w5, w0 0xffff800080a0b8ac : mov x23, x0 0xffff800080914a48 : mov x6, x0 0xffff8000809151c4 : ldr x21, [sp, #32] Signed-off-by: Kuan-Ying Lee --- scripts/gdb/linux/stackdepot.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scripts/gdb/linux/stackdepot.py b/scripts/gdb/linux/stackdepot.py index bb3a0f843931..37313a5a51a0 100644 --- a/scripts/gdb/linux/stackdepot.py +++ b/scripts/gdb/linux/stackdepot.py @@ -13,6 +13,13 @@ if constants.LX_CONFIG_STACKDEPOT: stack_record_type = utils.CachedType('struct stack_record') DEPOT_STACK_ALIGN = 4 +def help(): + t = """Usage: lx-stack_depot_lookup [Hex handle value] + Example: + lx-stack_depot_lookup 0x00c80300\n""" + gdb.write("Unrecognized command\n") + raise gdb.GdbError(t) + def stack_depot_fetch(handle): global DEPOT_STACK_ALIGN global stack_record_type @@ -57,3 +64,23 @@ def stack_depot_print(handle): gdb.execute("x /i 0x%x" % (int(entries[i]))) except Exception as e: gdb.write("%s\n" % e) + +class StackDepotLookup(gdb.Command): + """Search backtrace by handle""" + + def __init__(self): + if constants.LX_CONFIG_STACKDEPOT: + super(StackDepotLookup, self).__init__("lx-stack_depot_lookup", gdb.COMMAND_SUPPORT) + + def invoke(self, args, from_tty): + if not constants.LX_CONFIG_STACKDEPOT: + raise gdb.GdbError('CONFIG_STACKDEPOT is not set') + + argv = gdb.string_to_argv(args) + if len(argv) == 1: + handle = int(argv[0], 16) + stack_depot_print(gdb.Value(handle).cast(utils.get_uint_type())) + else: + help() + +StackDepotLookup()