Skip to content
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

Add Linux Support #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions Show Instruction Reference.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import sqlite3 as sq
import os
import platform
import sys
from sys import platform as _platform
import inspect
import glob

Expand All @@ -14,13 +17,15 @@
instr = seg.getInstructionAtAddress(adr)

# not sure why but stringForArchitecture returns <unknown> for arm/v7 (id 4)
if instr.getArchitecture() == 4:
# seg.isThumbAtAddress() ?doc.is64Bits() ?
if instr.getArchitecture() == 4: # 32-bit processor
arch = "arm/v7"
elif instr.getArchitecture() == 5:
elif instr.getArchitecture() == 5: # 64-bit processor
arch = "arm/v8"
else:
arch = instr.stringForArchitecture(instr.getArchitecture())
arch = instr.stringForArchitecture(instr.getArchitecture()) # Auto-Detect processor

doc.log("ArchID: %s" % instr.getArchitecture())
doc.log("Architecture: %s" % arch)
doc.log("instruction: " + instr.getInstructionString())
doc.log("instruction length: %d" % instr.getInstructionLength())
Expand All @@ -44,7 +49,11 @@ def __init__(self, mnem, arch):
self.title = "Instruction Reference"
self.destroying = False

self.base_path = os.path.abspath(os.path.expanduser("~/Library/Application Support/Hopper/Scripts"))
posix_os = platform.system()
if posix_os == "Linux" or _platform == "linux" or _platform == "linux2":
self.base_path = os.path.abspath(os.path.expanduser("~/GNUstep/Library/ApplicationSupport/Hopper/Scripts"))
if posix_os == "Darwin" or _platform == "darwin":
self.base_path = os.path.abspath(os.path.expanduser("~/Library/Application Support/Hopper/Scripts"))

self.archs = self.findManuals()

Expand All @@ -71,7 +80,7 @@ def loadArchitecture(self, name):
name = name.lower()
if name == "x86_64" or name == "x86" or name == "i386":
name = "x86-64"
elif name.startswith("arm"):
elif name.startswith("arm") or name == "aarch64":
name = "arm"

self.arch = name
Expand Down