-
Notifications
You must be signed in to change notification settings - Fork 0
Add stacktrace support #1
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
Draft
bugale
wants to merge
1
commit into
main
Choose a base branch
from
bugale/stack_trace
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| name: Lint | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| lint: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| linter: [ | ||
| {"name": "tests-flake8", "format": "flake8", "cwd": ".", "cmd": "flake8 tests"}, | ||
| {"name": "tests-mypy", "format": "mypy", "cwd": ".", "cmd": "mypy tests"}, | ||
| {"name": "tests-pylint", "format": "pylint-json", "cwd": ".", "cmd": "pylint --load-plugins pylint_pytest $(Get-ChildItem -Filter *.py -Recurse tests)"}, | ||
| {"name": "eslint", "format": "eslint-unix", "cwd": "bugalua", "cmd": "node_modules\\.bin\\eslint.ps1 --format=unix ."}, | ||
| ] | ||
| name: ${{ matrix.linter.name }} | ||
| runs-on: windows-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.x' | ||
| - name: Install Python dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -r tests\dev-requirements.txt | ||
| python -m pip install git+https://github.com/bugale/Bugalintly.git@bugalintly | ||
| - name: Install Node.JS dependencies | ||
| run: | | ||
| cd bugalua | ||
| npm install . | ||
| - name: Lint | ||
| run: | | ||
| cd ${{ matrix.linter.cwd }} | ||
| ${{ matrix.linter.cmd }} > lint.log | ||
| $exitcode = $LASTEXITCODE | ||
| type lint.log | Lintly --log --no-request-changes --no-review-body --base-dir .. --format=${{ matrix.linter.format }} --comment-tag=${{ matrix.linter.name }} | ||
| exit $exitcode | ||
| env: | ||
| LINTLY_API_KEY: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: windows-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.x' | ||
| - name: Install Windows SDK 22621 | ||
| run: | | ||
| Invoke-WebRequest -UseBasicParsing -Uri 'https://go.microsoft.com/fwlink/p/?linkid=2196241' -OutFile 'winsdksetup.exe' | ||
| Start-Process -Wait '.\winsdksetup.exe' '/features OptionId.WindowsDesktopDebuggers /quiet /norestart' | ||
| Remove-Item -Force 'winsdksetup.exe' | ||
| - name: Install Bugalua | ||
| run: | | ||
| .\Install.ps1 | ||
| - name: Install test dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -r tests\requirements.txt | ||
| - name: Test | ||
| run: | | ||
| pytest tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| **\__pycache__ | ||
| **\package-lock.json | ||
| **\node_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "python.linting.enabled": true, | ||
| "python.linting.flake8Enabled": true, | ||
| "python.linting.flake8Args": [], | ||
| "python.linting.mypyEnabled": true, | ||
| "python.linting.mypyArgs": ["--follow-imports=silent"], | ||
| "python.linting.pylintEnabled": true, | ||
| "python.linting.pylintArgs": ["--load-plugins", "pylint_pytest"], | ||
| "python.testing.pytestEnabled": true, | ||
| "eslint.enable": true, | ||
| "files.associations": { | ||
| "*.yaml": "home-assistant" | ||
| }, | ||
| "editor.tabSize": 4, | ||
| "[javascript]": { | ||
| "editor.tabSize": 2 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| param ($windbgPath='C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe') | ||
| (Get-Content $PSScriptRoot\Manifest\config.xml) -Replace [regex]::escape('C:\the\path\to\this\repo'), "$PSScriptRoot" | Set-Content $PSScriptRoot\Manifest\config.xml | ||
| $TempFile = New-TemporaryFile | ||
| ".settings load $PSScriptRoot\Manifest\config.xml`n.settings save`nqq`n" | Out-File -Encoding ASCII $TempFile | ||
| & "$windbgPath" "-c" "$<$TempFile" "C:\Windows\system32\cmd.exe" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <?xml version='1.0' encoding='utf-8'?> | ||
| <ExtensionPackages Version='1.0.0.0' Compression='none'> | ||
| <ExtensionPackage> | ||
| <Name>Bugalua</Name> | ||
| <Version>1.0.0.0</Version> | ||
| <Description>Lua debugging extension</Description> | ||
| <Components> | ||
| <ScriptComponent Name='Bugalua' Type='Engine' File='..\bugalua\bugalua.js' FilePathKind='RepositoryRelative'> | ||
| <FunctionAliases> | ||
| <FunctionAlias Name='lua'> | ||
| <AliasItem> | ||
| <Syntax> | ||
| <![CDATA[!lua <address>]]> | ||
| </Syntax> | ||
| <Description> | ||
| <![CDATA[Lua state inspection.]]> | ||
| </Description> | ||
| </AliasItem> | ||
| </FunctionAlias> | ||
| </FunctionAliases> | ||
| </ScriptComponent> | ||
| </Components> | ||
| </ExtensionPackage> | ||
| </ExtensionPackages> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| 1 | ||
| 1.0.0.0 | ||
| 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <?xml version='1.0' encoding='utf-8'?> | ||
| <Settings Version='1'> | ||
| <Namespace Name='Extensions'> | ||
| <Setting Name='ExtensionRepository' Type='VT_BSTR' Value='Implicit'></Setting> | ||
| <Namespace Name='ExtensionRepositories'> | ||
| <Namespace Name='overgallery'> | ||
| <Setting Name='Id' Type='VT_BSTR' Value='458940FE-5649-40DD-AD18-6AC36215BD86'></Setting> | ||
| <Setting Name='LocalCacheRootFolder' Type='VT_BSTR' Value='C:\work\Bugalua\Manifest'></Setting> | ||
| <Setting Name='IsEnabled' Type='VT_BOOL' Value='true'></Setting> | ||
| </Namespace> | ||
| </Namespace> | ||
| </Namespace> | ||
| </Settings> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| 'use strict'; | ||
|
|
||
| const console = { log: (...args) => host.diagnostics.debugLog(...args, '\n') }; | ||
|
|
||
| function getLuaState(luaAddr) { | ||
| // #region General Types | ||
| const ptrsize = host.currentSession.Attributes.Machine.PointerSize; | ||
| const voidType = { size: 0, name: 'void', from(addr) { return addr; } }; | ||
|
|
||
| function int(size, name, signed = false) { | ||
| return { | ||
| size, | ||
| name, | ||
| from(addr) { return parseInt(host.memory.readMemoryValues(addr, 1, size, signed)[0]); }, | ||
| }; | ||
| } | ||
| const [uint8, uint32] = [int(1, 'uint8'), int(4, 'uint32')]; | ||
| const sizeT = int(ptrsize, 'size_t'); | ||
|
|
||
| function ptr(type) { | ||
| return { | ||
| size: ptrsize, | ||
| name: `${type.name}*`, | ||
| from(addr) { | ||
| return { | ||
| addr: sizeT.from(addr), | ||
| type: type.name, | ||
| get value() { return type.from(sizeT.from(addr)); }, | ||
| toString() { return `[${type.name}* at 0x${addr.toString(16)}]`; }, | ||
| }; | ||
| }, | ||
| }; | ||
| } | ||
| function ptr32(type) { | ||
| return { | ||
| size: 4, | ||
| name: `${type.name}*`, | ||
| from(addr) { | ||
| return { | ||
| addr: uint32.from(addr), | ||
| type: type.name, | ||
| get value() { return type.from(uint32.from(addr)); }, | ||
| toString() { return `[${type.name}* at 0x${addr.toString(16)}]`; }, | ||
| }; | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| function array(type, length) { | ||
| class Array { | ||
| constructor(addr) { | ||
| Object.defineProperties(this, { | ||
| length: { value: length, writable: false }, | ||
| [Symbol.iterator]: { | ||
| value: () => { | ||
| let index = 0; | ||
|
|
||
| return { | ||
| next: () => ({ | ||
| done: index >= this.length, | ||
| value: type.from(addr + (index++) * type.size), | ||
| }), | ||
| }; | ||
| }, | ||
| }, | ||
| }); | ||
| } | ||
| } | ||
| return { size: length * type.size, name: (`${type.name}[${length}]`), from(addr) { return new Array(addr); } }; | ||
| } | ||
|
|
||
| function struct(name, fieldsArr) { | ||
| let offset = 0; | ||
| const fields = []; | ||
| fieldsArr.forEach(([type, fieldName]) => { | ||
| fields.push({ type, fieldName, offset }); | ||
| offset += type.size; | ||
| }); | ||
| class Struct { | ||
| constructor(addr) { | ||
| fields.forEach((field) => { | ||
| Object.defineProperty(this, field.fieldName, { | ||
| get() { | ||
| return field.type.from(addr + field.offset); | ||
| }, | ||
| }); | ||
| }); | ||
| this.toString = () => `[struct ${name} at 0x${addr.toString(16)}]`; | ||
| } | ||
| } | ||
| return { size: offset, name, from(addr) { return new Struct(addr); } }; | ||
| } | ||
|
|
||
| function defer(fn, name) { | ||
|
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. no-unused-vars: 'defer' is defined but never used. Allowed unused vars must match /^exports$/u. (eslint) |
||
| return { get size() { return fn().size; }, name, get from() { return fn().from; } }; | ||
| } | ||
| // #endregion General Types | ||
|
|
||
| // #region LuaJIT 2.0.5 Types | ||
| const MSize = uint32; | ||
| const MRef = ptr32; | ||
| const GCRef = ptr32; | ||
|
|
||
| const luaJit205GCState = struct('GC_State', [ | ||
| [MSize, 'total'], | ||
| [MSize, 'threshold'], | ||
| [uint8, 'currentwhite'], | ||
| [uint8, 'state'], | ||
| [uint8, 'nocdatafin'], | ||
| [uint8, 'unused2'], | ||
| [MSize, 'sweepstr'], | ||
| [GCRef(voidType), 'root'], | ||
| [MRef(voidType), 'sweep'], | ||
| [GCRef(voidType), 'gray'], | ||
| [GCRef(voidType), 'grayagain'], | ||
| [GCRef(voidType), 'weak'], | ||
| [GCRef(voidType), 'mmudata'], | ||
| [MSize, 'stepmul'], | ||
| [MSize, 'debt'], | ||
| [MSize, 'estimate'], | ||
| [MSize, 'pause'], | ||
| ]); | ||
|
|
||
| const luaJit205GlobalState = struct('global_State', [ | ||
| [ptr(GCRef(voidType)), 'strhash'], | ||
| [MSize, 'strmask'], | ||
| [MSize, 'strnum'], | ||
| [ptr(voidType), 'allocf'], | ||
| [ptr(voidType), 'allocd'], | ||
| [luaJit205GCState, 'gc'], | ||
| /* Incomplete */ | ||
| ]); | ||
|
|
||
| const luaJit205LuaState = struct('lua_State', [ | ||
| [GCRef(voidType), 'nextgc'], | ||
| [uint8, 'marked'], | ||
| [uint8, 'gct'], | ||
| [uint8, 'dummy_ffid'], | ||
| [uint8, 'status'], | ||
| [MRef(luaJit205GlobalState), 'glref'], | ||
| /* Incomplete */ | ||
| ]); | ||
| // #endregion LuaJIT 2.0.5 Types | ||
|
|
||
| // #region Frontend | ||
| class SizeBytes { | ||
| constructor(bytes) { | ||
| this.bytes = bytes; | ||
| } | ||
|
|
||
| toString() { | ||
| if (this.bytes <= 512) { | ||
| return `${this.bytes.toLocaleString()} B`; | ||
| } | ||
|
|
||
| const unitsArr = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; | ||
| let number = this.bytes / 1024; | ||
| let units = 0; | ||
| while (number > 512) { | ||
| number /= 1024; | ||
| units += 1; | ||
| } | ||
| return `${number.toFixed(2)} ${unitsArr[units]} (${this.bytes.toLocaleString()} B)`; | ||
| } | ||
| } | ||
|
|
||
| class LuaState { | ||
| constructor(addr) { | ||
| this.L = luaJit205LuaState.from(addr); | ||
| } | ||
|
|
||
| get address() { | ||
| return this.L.addr; | ||
| } | ||
|
|
||
| get MemoryUsage() { | ||
| return new SizeBytes(this.L.glref.value.gc.total); | ||
| } | ||
| } | ||
| // #endregion Frontend | ||
|
|
||
| return new LuaState(luaAddr); | ||
| } | ||
|
|
||
| function initializeScript() { | ||
| return [ | ||
| new host.functionAlias((addr) => getLuaState(addr), 'lua'), | ||
| ]; | ||
| } | ||
|
|
||
| const exports = [ | ||
| console, | ||
| initializeScript, | ||
| ]; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "name": "bugalua", | ||
| "version": "0.0.1", | ||
| "main": "bugalua.js", | ||
| "devDependencies": { | ||
| "eslint": "*", | ||
| "eslint-config-airbnb": "*" | ||
| }, | ||
| "eslintConfig": { | ||
| "extends": [ "airbnb" ], | ||
| "rules": { | ||
| "strict": "off", | ||
| "linebreak-style": "off", | ||
| "max-classes-per-file": "off", | ||
| "no-unused-vars": ["error", { "varsIgnorePattern": "^exports$" }], | ||
| "new-cap": "off", | ||
| "no-plusplus": "off", | ||
| "radix": "off" | ||
| }, | ||
| "globals": { "host": "readonly" } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| [flake8] | ||
| max-line-length = 160 | ||
|
|
||
| [mypy] | ||
| namespace_packages = True | ||
| strict = True | ||
| show_error_codes = True | ||
| show_column_numbers = True | ||
|
|
||
| [mypy-cffi,minidump.*] | ||
| ignore_missing_imports = True | ||
|
|
||
| [tool:pytest] | ||
| log_cli = 1 | ||
| log_cli_level = DEBUG | ||
| filterwarnings = error | ||
|
|
||
| [pylint.config] | ||
| max-line-length = 160 | ||
| output-format = json | ||
| disable = missing-module-docstring,missing-class-docstring,missing-function-docstring,broad-except |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no-unused-vars: 'array' is defined but never used. Allowed unused vars must match /^exports$/u. (eslint)