This is an automated email from the ASF dual-hosted git repository. sjanc pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
commit 87c6c26c5296319cc8ea16443630df96982cec61 Author: Szymon Janc <[email protected]> AuthorDate: Mon Oct 19 17:47:43 2026 +0200 newt/toolchain: Derive nm and addr2line path from objdump.exe If compiler.path.nm or compiler.path.addr2line is not set, the path is derived from compiler.path.objdump, but only if it ends with "objdump". On Windows, "arm-none-eabi-objdump.exe" fell back to "arm-none-eabi-nm". Handle the ".exe" suffix too. Assisted-by: Claude:claude-opus-5-5 --- newt/toolchain/compiler.go | 6 ++++-- newt/toolchain/toolpath_test.go | 47 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/newt/toolchain/compiler.go b/newt/toolchain/compiler.go index f22f671e..067aee5f 100644 --- a/newt/toolchain/compiler.go +++ b/newt/toolchain/compiler.go @@ -157,8 +157,10 @@ func (c *Compiler) GetAddr2linePath() string { // Returns path of binutils tool with given name that belongs to the same // toolchain as objdump, e.g. arm-none-eabi-objdump -> arm-none-eabi-nm. func siblingToolPath(odPath string, tool string) string { - if strings.HasSuffix(odPath, "objdump") { - return strings.TrimSuffix(odPath, "objdump") + tool + for _, ext := range []string{"", ".exe"} { + if strings.HasSuffix(odPath, "objdump"+ext) { + return strings.TrimSuffix(odPath, "objdump"+ext) + tool + ext + } } return "arm-none-eabi-" + tool diff --git a/newt/toolchain/toolpath_test.go b/newt/toolchain/toolpath_test.go new file mode 100644 index 00000000..5e8d451d --- /dev/null +++ b/newt/toolchain/toolpath_test.go @@ -0,0 +1,47 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package toolchain + +import "testing" + +func TestSiblingToolPath(t *testing.T) { + tests := []struct { + odPath string + tool string + exp string + }{ + {"arm-none-eabi-objdump", "nm", "arm-none-eabi-nm"}, + {"/opt/gcc/bin/riscv-none-embed-objdump", "addr2line", + "/opt/gcc/bin/riscv-none-embed-addr2line"}, + {"objdump", "nm", "nm"}, + {"gobjdump", "nm", "gnm"}, + {`C:\gcc\bin\arm-none-eabi-objdump.exe`, "nm", + `C:\gcc\bin\arm-none-eabi-nm.exe`}, + {"", "nm", "arm-none-eabi-nm"}, + } + + for _, tt := range tests { + got := siblingToolPath(tt.odPath, tt.tool) + if got != tt.exp { + t.Errorf("siblingToolPath(%q, %q) = %q, expected %q", + tt.odPath, tt.tool, got, tt.exp) + } + } +}
