From patchwork Sun Feb 25 20:47:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 40034 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C8D4C54E52 for ; Sun, 25 Feb 2024 20:48:03 +0000 (UTC) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mx.groups.io with SMTP id smtpd.web11.5941.1708894073276137725 for ; Sun, 25 Feb 2024 12:47:53 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KMTbA3kE; spf=pass (domain: gmail.com, ip: 209.85.221.45, mailfrom: adrian.freihofer@gmail.com) Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-33d18931a94so2005154f8f.1 for ; Sun, 25 Feb 2024 12:47:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708894071; x=1709498871; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HKYnobjTqVgV5A7AI+LY6O9D/vzLr7HcWNARYV6UPpo=; b=KMTbA3kECWh6Z0XdHRNT5S6a234Hilpn4MwpqlgR7Ww0jBH8yXjqYu4IH9vAwpK54a jX/LOnvskScPhDoKGGgFvILFSdOWbZAH/PprbDiiciCH8VycUKhMKdRjGSQ6MbHIN7Sh k1tHYdUZehhzC3bgdPKb3NOTCnN1cHzzJNeZZJV1oWRyBxR7AFi30XfvKNgPukoaWuts YBoC4vSi7mP9h0qWq3nzG6nqc1vdaOoYEm7BTgolPVe694md0yTmBNZJBOzYmNitonRi OFYdNkNk2g0SnrQw1S6GKQIHm6jggXVXgM5qMwJCHKKH5Yxrj03Qk0yaZeVwE/V3Xgl8 sqJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708894071; x=1709498871; 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=HKYnobjTqVgV5A7AI+LY6O9D/vzLr7HcWNARYV6UPpo=; b=HacHcDFN/EwqtgLn/Zmy10+QK2mkwTEc9iBtjHFTQRoEqAsn4rGdp/MVwilsra8OmC eJJFe6tZ0KiI0QkvEDK5QHRr27iDAunzAg9Tf/Dw9szrsAs4QAme9ORcHkNn1BQ3xM4x rPLWtM4f6mhGxXjVPnSubiS0Df74b5np3ashvhvd3qWODDtDu+cCjt+ZS5yRgno3IWcp WHVVTG2WyTFCqwvO5wqMeBnOkPU02MxyHIAolo5ikftNXLx6toAwb6j7mOUy32tKOpb+ jYay40ANLaWjl9pZNF06Uu/tHgBe0DD5wvgU5RQK3zkuWYsjdUQyJ+XOXAgfd1owlevr Q3QA== X-Gm-Message-State: AOJu0YwXiSUvWbEU4PpKg5NIXPZiAGH1Cyooq7WSNLhllGkwiwU4DOw/ dU+7lvc6ix3MShbP69XMLE/NQcXU2MUAoqc6EiNI3LWDXkQ8B8IWuaHmCHrX X-Google-Smtp-Source: AGHT+IGAgWplJmCQhx/DlB0G8Bw3FqAiV9AAmYZeNaiLdNCXLpL0AIXGpRJkhHLLKncOF1DL4cyB5Q== X-Received: by 2002:adf:e649:0:b0:33d:1467:f06d with SMTP id b9-20020adfe649000000b0033d1467f06dmr3940371wrn.24.1708894071501; Sun, 25 Feb 2024 12:47:51 -0800 (PST) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id dq2-20020a0560000cc200b0033b483d1abcsm6005989wrb.53.2024.02.25.12.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 12:47:51 -0800 (PST) From: Adrian Freihofer X-Google-Original-From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 1/4] devtool: ide-sdk launch.json per recipe only Date: Sun, 25 Feb 2024 21:47:00 +0100 Message-ID: <20240225204741.650070-2-adrian.freihofer@siemens.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240225204741.650070-1-adrian.freihofer@siemens.com> References: <20240225204741.650070-1-adrian.freihofer@siemens.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sun, 25 Feb 2024 20:48:03 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/196147 If multiple recipes are processed at once, the launch.json and the tasks.json of the second recipe contains also the configurations for the binaries of the first recipe. Example: devtool ide-sdk powertop cmake-example oe-selftest-image generated a launch and a tasks configuration for the cmake-example recipe which also offers debugging the powertop binary. Signed-off-by: Adrian Freihofer --- scripts/lib/devtool/ide_plugins/ide_code.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/lib/devtool/ide_plugins/ide_code.py b/scripts/lib/devtool/ide_plugins/ide_code.py index d5e3a4f4215..d58d0bdc539 100644 --- a/scripts/lib/devtool/ide_plugins/ide_code.py +++ b/scripts/lib/devtool/ide_plugins/ide_code.py @@ -255,8 +255,10 @@ class IdeVSCode(IdeBase): def vscode_launch(self, modified_recipe): """GDB Launch configuration for binaries (elf files)""" - configurations = [self.vscode_launch_bin_dbg( - gdb_cross_config) for gdb_cross_config in self.gdb_cross_configs] + configurations = [] + for gdb_cross_config in self.gdb_cross_configs: + if gdb_cross_config.modified_recipe is modified_recipe: + configurations.append(self.vscode_launch_bin_dbg(gdb_cross_config)) launch_dict = { "version": "0.2.0", "configurations": configurations @@ -280,6 +282,8 @@ class IdeVSCode(IdeBase): ] } for gdb_cross_config in self.gdb_cross_configs: + if gdb_cross_config.modified_recipe is not modified_recipe: + continue tasks_dict['tasks'].append( { "label": gdb_cross_config.id_pretty, @@ -394,6 +398,8 @@ class IdeVSCode(IdeBase): } if modified_recipe.gdb_cross: for gdb_cross_config in self.gdb_cross_configs: + if gdb_cross_config.modified_recipe is not modified_recipe: + continue tasks_dict['tasks'].append( { "label": gdb_cross_config.id_pretty, From patchwork Sun Feb 25 20:47:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 40036 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73664C54E51 for ; Sun, 25 Feb 2024 20:48:03 +0000 (UTC) Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by mx.groups.io with SMTP id smtpd.web11.5942.1708894073972112854 for ; Sun, 25 Feb 2024 12:47:54 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TjLf04yG; spf=pass (domain: gmail.com, ip: 209.85.128.53, mailfrom: adrian.freihofer@gmail.com) Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-412a4378151so3064395e9.1 for ; Sun, 25 Feb 2024 12:47:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708894072; x=1709498872; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GMduACdAe5MS2CLrgwBpMwG5rsygi0htGVwHAvgeYPs=; b=TjLf04yGaSeENS/am7/5KcYXTNOBVf/6zgsRl6hQyFcayhQZfcQAGfrs5OzusGMF9P da+4i2lYtDSr/HUdmNcAKkxISzSTD2AtvhhGn6KBfrqNlJCtuXVsIq3Dblh/X1WbReVQ 5986OjDNG09tK5gxId2vbgey6FWrJ3RbY4KToNTwPrMuqEa5hxxNsHMw76pOXsvf5wS9 PX88nEDdYbR3XP+L1/xSR4EjmUqPQc5bHNFesNkz3C5XqXY5n62lgmzNRNEEqqtAirik fL6eAxXSkf6bFc6G1F7c03rzis3iCvH9v2MVCS5cxc+BzBXmKT3WwRy3dRBN1UXD4zyi zKBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708894072; x=1709498872; 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=GMduACdAe5MS2CLrgwBpMwG5rsygi0htGVwHAvgeYPs=; b=rRETc8veCP+blnt+ObbjOxUoMMSqicS+bEzwt04g5PzvWkPIY1U6biAE89wn7zxTgH qFi59K7bnBp3We2DxabEmYl2YJokt4s/+wcQn50s/IaRGm4KMzNvzwmnisbBW7zXcYwH VWkTaJ4rIY2bIF7kqmDndFmWPKvwVzslpwIt4L8X2H0gfGM7lJ7fGaDuxZ501bpyRGli PlqBF4VZeAQRUB+h62LaiD73Dq1rAWFWswEwtsV5fjtTV49ko7YeiFtrKHi7jlmNg9ul qIVLyv3T4cMCFzC+dFT/9PD6x2PcEcFVSnZu77ifxBpB9y1keyeQo+RZlH1Hx4glpSnu tGdw== X-Gm-Message-State: AOJu0YymWzwcjibeBumtftORwvOqMHPWK5VQ5fT0rQQKO2+Nx6Ikbpo9 zjAlB9ZDlXhyyBr537MTJgA9BKNHdv67HNOHqV1N4iZAKlKCsIsYKrYArJnW X-Google-Smtp-Source: AGHT+IH9Qk24BWMwCz1HexJ7dusfdGYe1VTrVuL1qmBCll9SVJLaR7R84/4DkYA089UcLOH4c1ogVg== X-Received: by 2002:adf:dd81:0:b0:33d:22f4:179b with SMTP id x1-20020adfdd81000000b0033d22f4179bmr3266807wrl.21.1708894072239; Sun, 25 Feb 2024 12:47:52 -0800 (PST) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id dq2-20020a0560000cc200b0033b483d1abcsm6005989wrb.53.2024.02.25.12.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 12:47:51 -0800 (PST) From: Adrian Freihofer X-Google-Original-From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Enguerrand de Ribaucourt Subject: [PATCH 2/4] devtool: ide-sdk source mapping for vscode Date: Sun, 25 Feb 2024 21:47:01 +0100 Message-ID: <20240225204741.650070-3-adrian.freihofer@siemens.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240225204741.650070-1-adrian.freihofer@siemens.com> References: <20240225204741.650070-1-adrian.freihofer@siemens.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sun, 25 Feb 2024 20:48:03 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/196148 From: Enguerrand de Ribaucourt When launching the debug configuration, the source files from the debug rootfs were openened in the editor instead of the local workspace files. We add an exception to properly map them to the file being developed and compiled by the IDE integration. This also more closely matches what the user would expect compared to native development. This is also true for the devtool fallback mode. Signed-off-by: Enguerrand de Ribaucourt --- scripts/lib/devtool/ide_plugins/ide_code.py | 1 + scripts/lib/devtool/ide_sdk.py | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/lib/devtool/ide_plugins/ide_code.py b/scripts/lib/devtool/ide_plugins/ide_code.py index d58d0bdc539..09f0bb2a07e 100644 --- a/scripts/lib/devtool/ide_plugins/ide_code.py +++ b/scripts/lib/devtool/ide_plugins/ide_code.py @@ -242,6 +242,7 @@ class IdeVSCode(IdeBase): if gdb_cross_config.image_recipe.rootfs_dbg: launch_config['additionalSOLibSearchPath'] = modified_recipe.solib_search_path_str( gdb_cross_config.image_recipe) + src_file_map[os.path.join("/usr/src/debug", modified_recipe.pn, modified_recipe.pv)] = "${workspaceFolder}" src_file_map["/usr/src/debug"] = os.path.join( gdb_cross_config.image_recipe.rootfs_dbg, "usr", "src", "debug") else: diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py index 3bfeb5a3fce..289bbbf47c2 100755 --- a/scripts/lib/devtool/ide_sdk.py +++ b/scripts/lib/devtool/ide_sdk.py @@ -357,6 +357,7 @@ class RecipeModified: 'PACKAGE_DEBUG_SPLIT_STYLE') self.path = recipe_d.getVar('PATH') self.pn = recipe_d.getVar('PN') + self.pv = recipe_d.getVar('PV') self.recipe_sysroot = os.path.realpath( recipe_d.getVar('RECIPE_SYSROOT')) self.recipe_sysroot_native = os.path.realpath( From patchwork Sun Feb 25 20:47:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 40035 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6486DC54E41 for ; Sun, 25 Feb 2024 20:48:03 +0000 (UTC) Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by mx.groups.io with SMTP id smtpd.web10.6009.1708894075025664263 for ; Sun, 25 Feb 2024 12:47:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Iq77Jf07; spf=pass (domain: gmail.com, ip: 209.85.128.42, mailfrom: adrian.freihofer@gmail.com) Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-412a590d9b6so738725e9.0 for ; Sun, 25 Feb 2024 12:47:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708894073; x=1709498873; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eM1I+EwtrRptgZ6sjA/jer/bbg7erQRVasvvbhV9khU=; b=Iq77Jf07M9GPNiVOX0ODvW71dvrYqzNgeUKwC2wx8zh14uokuq+nPg809qc32Uid7k BYHwmR9Nh3RN7w/QHRRwFoFlmYCNjp9iy5KrmkYKRw998TF5Gu1TbPReU40gwOe/QPUw 76j23q6e9SJ73ue2WBNkWn55P27lsbbcS9YujecJC7XRjM30uMth9mlSt2lt4/QswtGR AXD9nANKrifMtFndCXouISQ0GCul3PY1VCBg648+H195lJK8rd+0yfwglWoGr7BQ1/ys Z6ttPFH6VkBleWAJ2llYwmILXG0eKEO34ilRgargniwS51SLQSvQhUyxScNq/UlNKpP2 vRnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708894073; x=1709498873; 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=eM1I+EwtrRptgZ6sjA/jer/bbg7erQRVasvvbhV9khU=; b=xJqh5Uu5UNJCgN3VFnJ/9q+DEU5Wg+i+ZWddJAsoZ+iECjFdIXupSXZSUHms0uyHPB FAcxf4XoQHisnv5N1qUU+haHvP2xeyi5arKr0o3mnIIHuOlowE4WQtLKvYPUWIfxVHsX iCo9EyPDMwOZdt5zE3JUYST1C20W+ca2pM12Di+OS8NJrvtkGHwAJfMMxahmNaCsBRKc U0Dp23nG8MwNzvVUu06WMZLqYupOdApgI8oT0DHHfZkjgVZ6r8eLSX2z3dI11Ps3u3D1 So998bw3N7h1Tdc4YawYbg1Tp+EDTIkDLFfV4tzcKJi8I9MzgOhCyAc9zrlKZO2XxdQj 2NhA== X-Gm-Message-State: AOJu0YwBnYzZtrjszvPVDGT9eCM2BRQOH7m6KRtx2PUBM8MSTcfKKlrV 7stvh9dNhPnuSTjTwdFTctpE1ZQrOL1ef8Wh0acmJhW5UTijFyDUgNjaynmk X-Google-Smtp-Source: AGHT+IFn7A6S+T3PHI4RvHcx2Z2GNo9crMVK2H/TqYxjIPtCdnrXfYTDzulN0LasukosnCsmcwxe0Q== X-Received: by 2002:a05:600c:5188:b0:412:9e3f:6632 with SMTP id fa8-20020a05600c518800b004129e3f6632mr2716952wmb.23.1708894072966; Sun, 25 Feb 2024 12:47:52 -0800 (PST) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id dq2-20020a0560000cc200b0033b483d1abcsm6005989wrb.53.2024.02.25.12.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 12:47:52 -0800 (PST) From: Adrian Freihofer X-Google-Original-From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 3/4] devtool: ide-sdk prefer sources from workspace Date: Sun, 25 Feb 2024 21:47:02 +0100 Message-ID: <20240225204741.650070-4-adrian.freihofer@siemens.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240225204741.650070-1-adrian.freihofer@siemens.com> References: <20240225204741.650070-1-adrian.freihofer@siemens.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sun, 25 Feb 2024 20:48:03 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/196149 Improve the previous commit: - log an error if some assumptions are not true - Use TARGET_DBGSRC_DIR variable - Do the same for ide none Why the additional source mapping is required: For example the cmake-example recipe refers to sources like this: ./recipe-sysroot-native/usr/bin/x86_64-poky-linux/x86_64-poky-linux-readelf \ -wi image/usr/bin/cmake-example | grep -B1 DW_AT_comp_dir ... <560> DW_AT_name : (indirect line string, offset: 0x1da): /usr/src/debug/cmake-example/1.0/oe-local-files/cpp-example.cpp ... Another example is powertop: ./recipe-sysroot-native/usr/bin/x86_64-poky-linux/x86_64-poky-linux-readelf \ -wi image/usr/sbin/powertop | grep -B1 DW_AT_comp_dir ... <561> DW_AT_name : (indirect line string, offset: 0x1da): /usr/src/debug/powertop/2.15/src/devlist.cpp ... For recipes with local files this works. The oe-local-files folder is not available in the rootfs-dbg and therefore the sources are first found in the workspace folder. GDB searches for source files in various places: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Source-Path.html However, for the powertop example the sources opened in the editor are from the rootfs-dbg instead of from the workspace. Bitbake calls the compiler with -fmacro-prefix-map=${S}=${TARGET_DBGSRC_DIR} where TARGET_DBGSRC_DIR defaults to "/usr/src/debug/${PN}/${PV}". A source map which maps the recipe specific path from TARGET_DBGSRC_DIR to the workspace fixes this. The already existing source map for /usr/src/debug applies for all other recipes. It finds the sources (read only) in the rootfs-dbg folder. Signed-off-by: Adrian Freihofer --- scripts/lib/devtool/ide_plugins/__init__.py | 19 +++++++++++++++++-- scripts/lib/devtool/ide_plugins/ide_code.py | 16 +++++++++++++--- scripts/lib/devtool/ide_sdk.py | 3 ++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/scripts/lib/devtool/ide_plugins/__init__.py b/scripts/lib/devtool/ide_plugins/__init__.py index 02707bfc37b..19c2f61c5fd 100644 --- a/scripts/lib/devtool/ide_plugins/__init__.py +++ b/scripts/lib/devtool/ide_plugins/__init__.py @@ -134,8 +134,23 @@ class GdbCrossConfig: if self.image_recipe.rootfs_dbg: gdbinit_lines.append( 'set solib-search-path "' + self.modified_recipe.solib_search_path_str(self.image_recipe) + '"') - gdbinit_lines.append('set substitute-path "/usr/src/debug" "' + os.path.join( - self.image_recipe.rootfs_dbg, 'usr', 'src', 'debug') + '"') + # First: Search for sources of this recipe in the workspace folder + if self.modified_recipe.pn in self.modified_recipe.target_dbgsrc_dir: + gdbinit_lines.append('set substitute-path "%s" "%s"' % + (self.modified_recipe.target_dbgsrc_dir, self.modified_recipe.real_srctree)) + else: + logger.error( + "TARGET_DBGSRC_DIR must contain the recipe name PN.") + # Second: Search for sources of other recipes in the rootfs-dbg + if self.modified_recipe.target_dbgsrc_dir.startswith("/usr/src/debug"): + gdbinit_lines.append('set substitute-path "/usr/src/debug" "%s"' % os.path.join( + self.image_recipe.rootfs_dbg, "usr", "src", "debug")) + else: + logger.error( + "TARGET_DBGSRC_DIR must start with /usr/src/debug.") + else: + logger.warning( + "Cannot setup debug symbols configuration for GDB. IMAGE_GEN_DEBUGFS is not enabled.") gdbinit_lines.append( '%s %s:%d' % (remote_cmd, self.gdb_cross.host, self.gdbserver_port)) gdbinit_lines.append('set remote exec-file ' + self.binary) diff --git a/scripts/lib/devtool/ide_plugins/ide_code.py b/scripts/lib/devtool/ide_plugins/ide_code.py index 09f0bb2a07e..a62b93224ee 100644 --- a/scripts/lib/devtool/ide_plugins/ide_code.py +++ b/scripts/lib/devtool/ide_plugins/ide_code.py @@ -242,9 +242,19 @@ class IdeVSCode(IdeBase): if gdb_cross_config.image_recipe.rootfs_dbg: launch_config['additionalSOLibSearchPath'] = modified_recipe.solib_search_path_str( gdb_cross_config.image_recipe) - src_file_map[os.path.join("/usr/src/debug", modified_recipe.pn, modified_recipe.pv)] = "${workspaceFolder}" - src_file_map["/usr/src/debug"] = os.path.join( - gdb_cross_config.image_recipe.rootfs_dbg, "usr", "src", "debug") + # First: Search for sources of this recipe in the workspace folder + if modified_recipe.pn in modified_recipe.target_dbgsrc_dir: + src_file_map[modified_recipe.target_dbgsrc_dir] = "${workspaceFolder}" + else: + logger.error( + "TARGET_DBGSRC_DIR must contain the recipe name PN.") + # Second: Search for sources of other recipes in the rootfs-dbg + if modified_recipe.target_dbgsrc_dir.startswith("/usr/src/debug"): + src_file_map["/usr/src/debug"] = os.path.join( + gdb_cross_config.image_recipe.rootfs_dbg, "usr", "src", "debug") + else: + logger.error( + "TARGET_DBGSRC_DIR must start with /usr/src/debug.") else: logger.warning( "Cannot setup debug symbols configuration for GDB. IMAGE_GEN_DEBUGFS is not enabled.") diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py index 289bbbf47c2..7807b322b31 100755 --- a/scripts/lib/devtool/ide_sdk.py +++ b/scripts/lib/devtool/ide_sdk.py @@ -301,6 +301,7 @@ class RecipeModified: self.staging_incdir = None self.strip_cmd = None self.target_arch = None + self.target_dbgsrc_dir = None self.topdir = None self.workdir = None self.recipe_id = None @@ -357,7 +358,6 @@ class RecipeModified: 'PACKAGE_DEBUG_SPLIT_STYLE') self.path = recipe_d.getVar('PATH') self.pn = recipe_d.getVar('PN') - self.pv = recipe_d.getVar('PV') self.recipe_sysroot = os.path.realpath( recipe_d.getVar('RECIPE_SYSROOT')) self.recipe_sysroot_native = os.path.realpath( @@ -368,6 +368,7 @@ class RecipeModified: recipe_d.getVar('STAGING_INCDIR')) self.strip_cmd = recipe_d.getVar('STRIP') self.target_arch = recipe_d.getVar('TARGET_ARCH') + self.target_dbgsrc_dir = recipe_d.getVar('TARGET_DBGSRC_DIR') self.topdir = recipe_d.getVar('TOPDIR') self.workdir = os.path.realpath(recipe_d.getVar('WORKDIR')) From patchwork Sun Feb 25 20:47:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Freihofer X-Patchwork-Id: 40033 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5551CC54E49 for ; Sun, 25 Feb 2024 20:48:03 +0000 (UTC) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by mx.groups.io with SMTP id smtpd.web10.6010.1708894075431101356 for ; Sun, 25 Feb 2024 12:47:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WQUNo32X; spf=pass (domain: gmail.com, ip: 209.85.128.46, mailfrom: adrian.freihofer@gmail.com) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-412a5a54adaso652275e9.1 for ; Sun, 25 Feb 2024 12:47:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708894073; x=1709498873; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nee2FO1FvOYlCNm8NNiPOoTv0ihY+IO1AgVNzpstOq4=; b=WQUNo32XHob6Nx7gHCL2syxx712YC3doQaBOjYFnikgvrQ+cw1lwAr5kJ02LSCYM3+ SS+Jh5sM5NedJtl9q4hZJHlobQW4UJ18R/CiybTiB0/Lt8cS/XgmpNnV/PQhY7fNSDcb ipTJrx8/4b2qVZJrKMcKC3ev5unYOGq6nvUremjOn6KhbO36ddkODZW9UWp6Ood4a2UQ y/Yda/wI6tyD/cJCdquuk5iOL46n4OtSgFjh5oy/wH6Z2hSrpTJFRc473L7AxB16yLz9 5isK8O9qMSpNFbB6dM2c+X7eFKjieAXQallSCYro1KWL8DSRWGKNB+lZ+NrmBmIbLwgo wx1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708894073; x=1709498873; 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=nee2FO1FvOYlCNm8NNiPOoTv0ihY+IO1AgVNzpstOq4=; b=oooONAmtTYaET1eDAPVk4gNgYoq7JylTXabgpFIezn4uDsvbmxIV3nIGdha6PTLqpY G6yP+NnJTONEf5nLxf2M9sqlBBaU2sqeKyiWjVXLOQ6cBGfAkE8xRSuIuebOaX9AlGi0 wdkmQi9/JD5d5uuR39masga0152Tylqoh/V+MX238+J7eYxDVecpZmDQdo0Iiw9V7lQJ 1cnSoPFEmhLOlM2j/VHo4FjDDBa/fXaZWAsUxOAVwe663+bG45vY1M0PCI4ubpHIcySy Yf3jmaBGiobjoPCCH06fomdt72ymuNC/s2ygTHrbqx3ERoa9hXja82qpWtq4bHYKhesd pM/Q== X-Gm-Message-State: AOJu0Yz05WIO+Y4IN4WdzzO74QHbqBmcmlXedG6vKZolrhoPoD+Sb3/L NuTILYmM+nRL5XXoqw3F74kmLWpICq/jnCDL0N+sl6dhA7qEKJQbNR/btH0e X-Google-Smtp-Source: AGHT+IHl7W7+qL1ZOJyFCZKrumLyp2jkgTDJKuM3UDRIl67tNKR7E7SfPmjdio/eHisWR0SjKGZt8Q== X-Received: by 2002:a5d:4e85:0:b0:33d:87f0:1475 with SMTP id e5-20020a5d4e85000000b0033d87f01475mr3447449wru.62.1708894073604; Sun, 25 Feb 2024 12:47:53 -0800 (PST) Received: from wsadrian16.fritz.box ([2a02:169:59a6:0:55c4:f628:91f3:4287]) by smtp.gmail.com with ESMTPSA id dq2-20020a0560000cc200b0033b483d1abcsm6005989wrb.53.2024.02.25.12.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 12:47:53 -0800 (PST) From: Adrian Freihofer X-Google-Original-From: Adrian Freihofer To: openembedded-core@lists.openembedded.org Cc: Adrian Freihofer Subject: [PATCH 4/4] oe-selftest devtool: ide-sdk tests Date: Sun, 25 Feb 2024 21:47:03 +0100 Message-ID: <20240225204741.650070-5-adrian.freihofer@siemens.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240225204741.650070-1-adrian.freihofer@siemens.com> References: <20240225204741.650070-1-adrian.freihofer@siemens.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sun, 25 Feb 2024 20:48:03 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/196150 Improve the GDB related tests. Verify GDB finds the correct source files. Signed-off-by: Adrian Freihofer --- meta/lib/oeqa/selftest/cases/devtool.py | 42 +++++++++++++++++++------ 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py index d37848bdefc..ecff3a9ebdf 100644 --- a/meta/lib/oeqa/selftest/cases/devtool.py +++ b/meta/lib/oeqa/selftest/cases/devtool.py @@ -2544,6 +2544,10 @@ class DevtoolIdeSdkTests(DevtoolBase): self.assertEqual(status, 0, msg="%s failed: %s" % (ptest_cmd, output)) self.assertIn("PASS: cpp-example-lib", output) + # Verify remote debugging works + self._gdb_cross_debugging( + qemu, recipe_name, example_exe, MAGIC_STRING_ORIG) + # Replace the Magic String in the code, compile and deploy to Qemu cpp_example_lib_hpp = os.path.join(tempdir, 'cpp-example-lib.hpp') with open(cpp_example_lib_hpp, 'r') as file: @@ -2565,6 +2569,10 @@ class DevtoolIdeSdkTests(DevtoolBase): self.assertEqual(status, 0, msg="%s failed: %s" % (ptest_cmd, output)) self.assertIn("PASS: cpp-example-lib", output) + # Verify remote debugging works wit the modified magic string + self._gdb_cross_debugging( + qemu, recipe_name, example_exe, MAGIC_STRING_NEW) + def _gdb_cross(self): """Verify gdb-cross is provided by devtool ide-sdk""" target_arch = self.td["TARGET_ARCH"] @@ -2578,13 +2586,22 @@ class DevtoolIdeSdkTests(DevtoolBase): self.assertEqual(r.status, 0) self.assertIn("GNU gdb", r.output) - def _gdb_cross_debugging(self, qemu, recipe_name, example_exe): + def _gdb_cross_debugging(self, qemu, recipe_name, example_exe, magic_string): """Verify gdb-cross is working Test remote debugging: break main run continue + break CppExample::print_json() + continue + print CppExample::test_string.compare("cpp-example-lib Magic: 123456789") + $1 = 0 + print CppExample::test_string.compare("cpp-example-lib Magic: 123456789aaa") + $2 = -3 + list cpp-example-lib.hpp:13,13 + 13 inline static const std::string test_string = "cpp-example-lib Magic: 123456789"; + continue """ sshargs = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' gdbserver_script = os.path.join(self._workspace_scripts_dir( @@ -2609,10 +2626,21 @@ class DevtoolIdeSdkTests(DevtoolBase): self.assertIn("gdbserver", r.output) # Test remote debugging works - r = runCmd( - gdb_script + " --batch -ex 'break main' --ex 'run' -ex 'continue'") + gdb_batch_cmd = " --batch -ex 'break main' -ex 'run'" + gdb_batch_cmd += " -ex 'break CppExample::print_json()' -ex 'continue'" + gdb_batch_cmd += " -ex 'print CppExample::test_string.compare(\"cpp-example-lib %s\")'" % magic_string + gdb_batch_cmd += " -ex 'print CppExample::test_string.compare(\"cpp-example-lib %saaa\")'" % magic_string + gdb_batch_cmd += " -ex 'list cpp-example-lib.hpp:13,13'" + gdb_batch_cmd += " -ex 'continue'" + r = runCmd(gdb_script + gdb_batch_cmd) + self.logger.debug("%s %s returned: %s", gdb_script, + gdb_batch_cmd, r.output) self.assertEqual(r.status, 0) self.assertIn("Breakpoint 1, main", r.output) + self.assertIn("$1 = 0", r.output) # test.string.compare equal + self.assertIn("$2 = -3", r.output) # test.string.compare longer + self.assertIn( + 'inline static const std::string test_string = "cpp-example-lib %s";' % magic_string, r.output) self.assertIn("exited normally", r.output) # Stop the gdbserver @@ -2689,14 +2717,12 @@ class DevtoolIdeSdkTests(DevtoolBase): bitbake_sdk_cmd = 'devtool ide-sdk %s %s -t root@%s -c --ide=none' % ( recipe_name, testimage, qemu.ip) runCmd(bitbake_sdk_cmd) + self._gdb_cross() self._verify_cmake_preset(tempdir) self._devtool_ide_sdk_qemu(tempdir, qemu, recipe_name, example_exe) # Verify the oe-scripts sym-link is valid self.assertEqual(self._workspace_scripts_dir( recipe_name), self._sources_scripts_dir(tempdir)) - # Verify GDB is working after devtool ide-sdk - self._gdb_cross() - self._gdb_cross_debugging(qemu, recipe_name, example_exe) # meson-example recipe recipe_name = "meson-example" @@ -2707,13 +2733,11 @@ class DevtoolIdeSdkTests(DevtoolBase): bitbake_sdk_cmd = 'devtool ide-sdk %s %s -t root@%s -c --ide=none' % ( recipe_name, testimage, qemu.ip) runCmd(bitbake_sdk_cmd) + self._gdb_cross() self._devtool_ide_sdk_qemu(tempdir, qemu, recipe_name, example_exe) # Verify the oe-scripts sym-link is valid self.assertEqual(self._workspace_scripts_dir( recipe_name), self._sources_scripts_dir(tempdir)) - # Verify GDB is working after devtool ide-sdk - self._gdb_cross() - self._gdb_cross_debugging(qemu, recipe_name, example_exe) def test_devtool_ide_sdk_code_cmake(self): """Verify a cmake recipe works with ide=code mode"""