Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2024-01-05 12:37:08 -05:00
commit a9aedc10f5
7 changed files with 89 additions and 22 deletions

View File

@ -18,14 +18,17 @@
@echo off @echo off
if exist "%GHIDRA_HOME%\ghidra\.git\" ( if exist "%GHIDRA_HOME%\ghidra\.git\" (
set PYTHONPATH=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-agent-dbgeng\build\pypkg\src;%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src;%PYTHONPATH% set PYTHONPATH=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-agent-dbgeng\build\pypkg\src;%PYTHONPATH%
set PYTHONPATH=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src;%PYTHONPATH%
) else if exist "%GHIDRA_HOME%\.git\" ( ) else if exist "%GHIDRA_HOME%\.git\" (
set PYTHONPATH=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-dbgeng\build\pypkg\src;%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src;%PYTHONPATH% set PYTHONPATH=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-dbgeng\build\pypkg\src;%PYTHONPATH%
set PYTHONPATH=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src;%PYTHONPATH%
) else ( ) else (
set PYTHONPATH=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-dbgeng\pypkg\src;%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\pypkg\src;%PYTHONPATH% set PYTHONPATH=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-dbgeng\pypkg\src;%PYTHONPATH%
set PYTHONPATH=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\pypkg\src;%PYTHONPATH%
) )
echo PYTHONPATH is %PYTHONPATH% echo PYTHONPATH is %PYTHONPATH%
echo bat OPT_TARGET_IMG is [%OPT_TARGET_IMG%] echo OPT_TARGET_IMG is [%OPT_TARGET_IMG%]
"%OPT_PYTHON_EXE%" -i ..\support\local-dbgeng.py "%OPT_PYTHON_EXE%" -i ..\support\local-dbgeng.py

View File

@ -33,12 +33,15 @@
if [ -d ${GHIDRA_HOME}/ghidra/.git ] if [ -d ${GHIDRA_HOME}/ghidra/.git ]
then then
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
elif [ -d ${GHIDRA_HOME}/.git ] elif [ -d ${GHIDRA_HOME}/.git ]
then then
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
else else
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/pypkg/src:$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/pypkg/src:$PYTHONPATH
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
fi fi
target_image="$1" target_image="$1"

View File

@ -86,8 +86,8 @@ public class ThreadedTerminal extends DefaultTerminal {
} }
protected void pump() { protected void pump() {
try { while (!closed) {
while (!closed) { try {
if (-1 == in.read(buffer) || closed) { if (-1 == in.read(buffer) || closed) {
return; return;
} }
@ -98,10 +98,15 @@ public class ThreadedTerminal extends DefaultTerminal {
} }
buffer.clear(); buffer.clear();
} }
} catch (IOException e) {
catch (IOException e) { Msg.error(this, "Console input closed unexpectedly: " + e);
Msg.error(this, "Console input closed unexpectedly: " + e); closed = true;
closed = true; return;
}
catch (Exception e) {
Msg.error(this, "Unexpected error processing terminal input", e);
continue;
}
} }
} }

View File

@ -43,6 +43,49 @@ public class VtParser {
this.handler = handler; this.handler = handler;
} }
protected static ByteBuffer copyDoubledCapacity(ByteBuffer oldBuf) {
ByteBuffer newBuf = ByteBuffer.allocate(oldBuf.capacity() * 2);
oldBuf.flip();
newBuf.put(oldBuf);
return newBuf;
}
/**
* Append a byte to {@link #csiParam}, resizing if necessary
*
* @param b the byte
*/
protected void putCsiParamByte(byte b) {
if (!csiParam.hasRemaining()) {
csiParam = copyDoubledCapacity(csiParam);
}
csiParam.put(b);
}
/**
* Append a byte to {@link #csiInter}, resizing if necessary
*
* @param b the byte
*/
protected void putCsiInterByte(byte b) {
if (!csiInter.hasRemaining()) {
csiInter = copyDoubledCapacity(csiInter);
}
csiInter.put(b);
}
/**
* Append a byte to {@link #oscParam}, resizing if necessary
*
* @param b the byte
*/
protected void putOscParamByte(byte b) {
if (!oscParam.hasRemaining()) {
oscParam = copyDoubledCapacity(oscParam);
}
oscParam.put(b);
}
/** /**
* Create a copy of the CSI buffers, reconstructed as they were in the original stream. * Create a copy of the CSI buffers, reconstructed as they were in the original stream.
* *

View File

@ -226,11 +226,11 @@ public enum VtState {
@Override @Override
protected VtState handleNext(byte b, VtParser parser, VtHandler handler) { protected VtState handleNext(byte b, VtParser parser, VtHandler handler) {
if (0x30 <= b && b <= 0x3f) { if (0x30 <= b && b <= 0x3f) {
parser.csiParam.put(b); parser.putCsiParamByte(b);
return CSI_PARAM; return CSI_PARAM;
} }
if (0x20 <= b && b <= 0x2f) { if (0x20 <= b && b <= 0x2f) {
parser.csiInter.put(b); parser.putCsiInterByte(b);
return CSI_INTER; return CSI_INTER;
} }
if (0x40 <= b && b <= 0x7e) { if (0x40 <= b && b <= 0x7e) {
@ -249,7 +249,7 @@ public enum VtState {
@Override @Override
protected VtState handleNext(byte b, VtParser parser, VtHandler handler) { protected VtState handleNext(byte b, VtParser parser, VtHandler handler) {
if (0x20 <= b && b <= 0x2f) { if (0x20 <= b && b <= 0x2f) {
parser.csiInter.put(b); parser.putCsiInterByte(b);
return CSI_INTER; return CSI_INTER;
} }
if (0x40 <= b && b <= 0x7e) { if (0x40 <= b && b <= 0x7e) {
@ -269,7 +269,7 @@ public enum VtState {
protected VtState handleNext(byte b, VtParser parser, VtHandler handler) { protected VtState handleNext(byte b, VtParser parser, VtHandler handler) {
// For whatever reason, Windows includes the null terminator in titles // For whatever reason, Windows includes the null terminator in titles
if (0x20 <= b && b <= 0x7f || b == 0) { if (0x20 <= b && b <= 0x7f || b == 0) {
parser.oscParam.put(b); parser.putOscParamByte(b);
return OSC_PARAM; return OSC_PARAM;
} }
if (b == 0x07) { if (b == 0x07) {

View File

@ -333,10 +333,10 @@ macro Store(addr, value) {
# #
macro pageCAddr(addr, shift, page, offset) { macro pageCAddr(addr, shift, page, offset) {
addr = (page << shift) | offset; addr = addr | ((page << shift) | offset);
} }
macro pagePAddr(addr, shift, page, offset) { macro pagePAddr(addr, shift, page, offset) {
addr = (zext(page) << shift) | offset; addr = addr | ((zext(page) << shift) | offset);
} }
@if defined(HCS12X) @if defined(HCS12X)
@ -400,7 +400,7 @@ page: imm8 is imm8 { export *[const]:1 imm8; }
#PageDest: dest is imm16p=0xd & imm16 & imm16pv ; imm8 [ dest = ($(MAXFLASHPage) << 16) | imm16; ] { export *:1 dest; } #PageDest: dest is imm16p=0xd & imm16 & imm16pv ; imm8 [ dest = ($(MAXFLASHPage) << 16) | imm16; ] { export *:1 dest; }
#PageDest: dest is imm16p=0xe & imm16 & imm16pv ; imm8 [ dest = ($(MAXFLASHPage) << 16) | imm16; ] { export *:1 dest; } #PageDest: dest is imm16p=0xe & imm16 & imm16pv ; imm8 [ dest = ($(MAXFLASHPage) << 16) | imm16; ] { export *:1 dest; }
#PageDest: dest is imm16p=0xf & imm16 & imm16pv ; imm8 [ dest = ($(MAXFLASHPage) << 16) | imm16; ] { export *:1 dest; } #PageDest: dest is imm16p=0xf & imm16 & imm16pv ; imm8 [ dest = ($(MAXFLASHPage) << 16) | imm16; ] { export *:1 dest; }
PageDest: opr16a is opr16a; page { export opr16a; } PageDest: opr16a is opr16a; page { export opr16a; }
@else @else
@ -2084,7 +2084,6 @@ CallDest: PageDest, imm8 is (imm16; imm8) & PageDest {
local ppage_tmp:1 = PPAGE; local ppage_tmp:1 = PPAGE;
Push1( PPAGE ); Push1( PPAGE );
build CallDest; build CallDest;
local dest:$(SIZE) = CallDest; local dest:$(SIZE) = CallDest;

View File

@ -27,5 +27,19 @@ task buildPyPackage(type: Exec) {
outputs.dir(dist) outputs.dir(dist)
workingDir { "build/pypkg" } workingDir { "build/pypkg" }
commandLine "python", "-m", "build" commandLine "python3", "-m", "build"
}
// At the moment, any module with a python package also distributes it.
// We can separate this into `distributePythonPackage` later, if necessary.
rootProject.assembleDistribution {
def p = this.project
def zipPath = getZipPath(p)
from (p.assemblePyPackage) {
exclude '**/*.pyc'
exclude '**/*.pyo'
exclude '**/__pycache__/**'
into { zipPath + "/pypkg" }
}
} }