-
Notifications
You must be signed in to change notification settings - Fork 31
Add memory visualization #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
db69711
1c9443e
5375886
1f8a139
587dcaf
976db23
4c952ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Copyright (c) 2015 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause | ||
| */ | ||
|
|
||
| .canvas-container { | ||
| width: 100%; | ||
| height: 100%; | ||
| overflow: scroll; | ||
|
|
||
| &::-webkit-scrollbar, | ||
| &::-webkit-scrollbar-corner { | ||
| width: 10px; | ||
| height: 0px; // Needed, don't remove | ||
| } | ||
|
|
||
| &::-webkit-scrollbar-thumb { | ||
| background: $gray-500; | ||
| border-radius: 5px; | ||
| border: 3px solid white; | ||
| } | ||
| &::-webkit-scrollbar-thumb:hover { | ||
| background: $gray-700; | ||
| } | ||
|
|
||
| canvas { | ||
| border: 1px solid white; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* | ||
| * Copyright (c) 2015 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause | ||
| */ | ||
|
|
||
| .section-info-view { | ||
| padding-top: 4px; | ||
| font-size: 12px; | ||
| min-width: 155px; | ||
| .fields { | ||
| padding-top: 12px; | ||
| border-bottom: 1px solid $gray-200; | ||
| } | ||
| div:last-child { | ||
| border: none; | ||
| } | ||
| p { | ||
| text-align: left !important; | ||
| padding-top: 0 !important; | ||
| color: $gray-900 !important; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import { | |
| } from 'pc-nrfconnect-shared'; | ||
|
|
||
| import { | ||
| elfParse, | ||
| fileParse, | ||
| filesEmpty, | ||
| mcubootFileKnown, | ||
|
|
@@ -239,6 +240,35 @@ const parseHexFile = | |
| dispatch(updateTargetWritable()); | ||
| }; | ||
|
|
||
| const parseElf = (filePath: string) => async (dispatch: TDispatch) => { | ||
| const stats = await new Promise<Stats>((resolve, reject) => { | ||
| stat(filePath, (statsError, result) => { | ||
| if (statsError) { | ||
| logger.error( | ||
| `Could not open Elf file: ${describeError(statsError)}` | ||
| ); | ||
| dispatch( | ||
| ErrorDialogActions.showDialog(describeError(statsError)) | ||
| ); | ||
| removeMruFile(filePath); | ||
| return reject(); | ||
| } | ||
| return resolve(result); | ||
| }); | ||
| }); | ||
|
|
||
| logger.info('Checking Elf file: ', filePath); | ||
| logger.info('File was last modified at ', stats.mtime.toLocaleString()); | ||
| addMruFile(filePath); | ||
| // License for elfy can be found at https://github.com/indutny/elfy | ||
| /* eslint-disable global-require */ | ||
| const elfy = require('elfy'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a reason for using an inline require instead of a global import statement. |
||
| const fs = require('fs'); | ||
| const fileData = fs.readFileSync(filePath); | ||
| const elf = elfy.parse(fileData); | ||
| dispatch(elfParse(elf)); | ||
| }; | ||
|
|
||
| export const openFile = | ||
| (...params: string[]) => | ||
| async (dispatch: TDispatch): Promise<unknown> => { | ||
|
|
@@ -256,22 +286,28 @@ export const openFile = | |
| dispatch(updateTargetWritable()); | ||
| return dispatch(openFile(...params.slice(1))); | ||
| } | ||
| if (filePath.toLowerCase().endsWith('.elf')) { | ||
| dispatch(filesEmpty()); | ||
| await dispatch(parseElf(filePath)); | ||
| return dispatch(openFile(...params.slice(1))); | ||
| } | ||
| if ( | ||
| filePath.toLowerCase().endsWith('.hex') || | ||
| filePath.toLowerCase().endsWith('.ihex') | ||
| ) { | ||
| dispatch(filesEmpty()); | ||
|
jesper2k marked this conversation as resolved.
|
||
| await dispatch(parseHexFile(filePath)); | ||
| return dispatch(openFile(...params.slice(1))); | ||
| } | ||
| }; | ||
|
|
||
| export const openFileDialog = () => (dispatch: TDispatch) => { | ||
| const dialogOptions = { | ||
| title: 'Select a HEX / ZIP file', | ||
| title: 'Select a HEX / ZIP / ELF file', | ||
| filters: [ | ||
| { | ||
| name: 'HEX / ZIP files', | ||
| extensions: ['hex', 'iHex', 'zip'], | ||
| name: 'HEX / ZIP / ELF files', | ||
| extensions: ['hex', 'iHex', 'zip', 'elf'], | ||
| }, | ||
| ], | ||
| properties: ['openFile', 'multiSelections'], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| import React from 'react'; | ||
| import { useSelector } from 'react-redux'; | ||
|
|
||
| import { getLoaded, getZipFilePath } from '../reducers/fileReducer'; | ||
| import { getElf, getLoaded, getZipFilePath } from '../reducers/fileReducer'; | ||
| import { getDeviceInfo, getSerialNumber } from '../reducers/targetReducer'; | ||
| import useOpenFileFromArgs from '../useOpenFileFromArgs'; | ||
| import { DeviceDefinition } from '../util/devices'; | ||
|
|
@@ -38,6 +38,7 @@ const AppMainView = () => { | |
| const zipFilePath = useSelector(getZipFilePath); | ||
| const serialNumber = useSelector(getSerialNumber); | ||
| const deviceInfo = useSelector(getDeviceInfo); | ||
| const elf = useSelector(getElf); | ||
|
|
||
| useOpenFileFromArgs(); | ||
|
|
||
|
|
@@ -47,17 +48,18 @@ const AppMainView = () => { | |
| <div className="memory-box-container"> | ||
| <MemoryBoxView | ||
| title="File memory layout" | ||
| description="Drag & drop HEX/ZIP files here" | ||
| iconName="mdi mdi-folder-open" | ||
| description="Drag & drop HEX/ZIP/ELF files here" | ||
| iconName="mdi mdi-file-outline" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason for changing the title and icon?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would think it's more intuitive that you're looking at an elf-file if there's a file icon + extension, than if you just see a directory/folder icon. But the title change should be reverted, thanks for catching that.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it is right now it changes the default behaviour so that mdi-file-outline is shown also for all other states (like no files or other file types).
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1337
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will work on this so it works with hex and zip files too |
||
| isHolder={!hasFileContent(loaded) && !zipFilePath} | ||
| containsVisualization={elf !== undefined} | ||
| /> | ||
| <MemoryBoxView | ||
| title={ | ||
| getTargetTitle(serialNumber, deviceInfo) || | ||
| 'Device memory layout' | ||
| } | ||
| description="Connect a device to display memory contents" | ||
| iconName="appicon-chip" | ||
| iconName="mdi appicon-chip" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is mdi added here for some kind of layout css?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| isHolder={!serialNumber} | ||
| isTarget={!!serialNumber} | ||
| /> | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.