Skip to content

Commit 5b596c0

Browse files
committed
new: add 'visualize-jumps' when disasm code
1 parent f24b450 commit 5b596c0

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

src/EIDEProjectExplorer.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ import {
8888
genGithubHash, md5, toArray, newMarkdownString, newFileTooltipString, FileTooltipInfo, escapeXml,
8989
readGithubRepoTxtFile, downloadFile, notifyReloadWindow, formatPath, execInternalCommand,
9090
copyAndMakeObjectKeysToLowerCase,
91-
sortPaths
91+
sortPaths,
92+
getGccBinutilsVersion,
93+
compareVersion
9294
} from './utility';
9395
import { concatSystemEnvPath, DeleteDir, exeSuffix, kill, osType, DeleteAllChildren } from './Platform';
9496
import { KeilARMOption, KeilC51Option, KeilParser, KeilRteDependence } from './KeilXmlParser';
@@ -5010,6 +5012,11 @@ export class ProjectExplorer implements CustomConfigurationProvider {
50105012
exeFile = File.fromArray([prj.getToolchain().getToolchainDir().path, 'bin', `${toolPrefix}objdump${exeSuffix()}`]);
50115013
if (!exeFile.IsFile()) { throw Error(`Not found '${exeFile.name}' !`) }
50125014
cmds = ['-S', '-l', elfPath, '>', dasmFile.path];
5015+
// https://interrupt.memfault.com/blog/gnu-binutils#new-feature-visualize-jumps
5016+
const binutilsVer = getGccBinutilsVersion(exeFile.dir, toolPrefix, 'objdump');
5017+
if (binutilsVer && compareVersion(binutilsVer, '2.34') > 0) {
5018+
cmds = ['--visualize-jumps'].concat(cmds);
5019+
}
50135020
}
50145021
else if (toolchainName.startsWith('AC')) { // armcc
50155022
exeFile = File.fromArray([prj.getToolchain().getToolchainDir().path, 'bin', `fromelf${exeSuffix()}`]);
@@ -5124,6 +5131,11 @@ export class ProjectExplorer implements CustomConfigurationProvider {
51245131
exeFile = File.fromArray([activePrj.getToolchain().getToolchainDir().path, 'bin', `${toolPrefix}objdump${exeSuffix()}`]);
51255132
if (!exeFile.IsFile()) { throw Error(`Not found '${exeFile.name}' !`) }
51265133
cmds = ['-S', '-l', objPath, '>', tmpFile.path];
5134+
// https://interrupt.memfault.com/blog/gnu-binutils#new-feature-visualize-jumps
5135+
const binutilsVer = getGccBinutilsVersion(exeFile.dir, toolPrefix, 'objdump');
5136+
if (binutilsVer && compareVersion(binutilsVer, '2.34') > 0) {
5137+
cmds = ['--visualize-jumps'].concat(cmds);
5138+
}
51275139
}
51285140
else if (toolchainName.startsWith('AC')) { // armcc
51295141
exeFile = File.fromArray([activePrj.getToolchain().getToolchainDir().path, 'bin', `fromelf${exeSuffix()}`]);

src/utility.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,31 @@ import { ExeCmd } from '../lib/node-utility/Executable';
4242
import { GlobalEvent } from './GlobalEvents';
4343
import { SettingManager } from './SettingManager';
4444

45+
export function getGccBinutilsVersion(gccBinDirPath: string, toolprefix?: string, toolname?: string): string | undefined {
46+
47+
// example output:
48+
// GNU objdump (GNU Arm Embedded Toolchain 10-2020-q4-major) 2.35.1.20201028
49+
// GNU readelf (GNU Tools for Arm Embedded Processors 8-2019-q3-update) 2.32.0.20190703
50+
51+
const exeName = toolname || 'objdump';
52+
53+
try {
54+
const lines = child_process.execFileSync(`${toolprefix || ''}${exeName}`, ['-v'], { cwd: gccBinDirPath, encoding: 'ascii' }).split(/\r\n|\n/);
55+
for (const line of lines) {
56+
if (line.trim().startsWith(`GNU ${exeName}`)) {
57+
const m = /(\d+\.\d+\.\d+)(?:\.\d+)*$/.exec(line);
58+
if (m && m.length > 1) {
59+
return m[1].trim();
60+
}
61+
}
62+
}
63+
} catch (error) {
64+
GlobalEvent.emit('msg', ExceptionToMessage(error, 'Hidden'));
65+
}
66+
67+
return undefined;
68+
}
69+
4570
export function sortPaths(pathList: string[], sep?: string): string[] {
4671

4772
let plist: string[][] = pathList.map(p => p.split(/\\|\//));

0 commit comments

Comments
 (0)