wip
This commit is contained in:
parent
55b5632bb8
commit
29132f5a58
3 changed files with 160 additions and 140 deletions
|
|
@ -2,4 +2,12 @@
|
|||
|
||||
FOLDER=$(dirname "$(realpath $0)")
|
||||
|
||||
"${FOLDER}/venv/bin/collect-runtime-data" --apk "${1}" --device "${2}" --output "${3}/data.json" --dex-dir "${3}"
|
||||
APK="${1}"
|
||||
DEVICE="${2}"
|
||||
OUT_DIR="${3}"
|
||||
|
||||
echo "APK=${APK}"
|
||||
echo "DEVICE=${DEVICE}"
|
||||
echo "OUT_DIR=${OUT_DIR}"
|
||||
|
||||
"${FOLDER}/venv/bin/collect-runtime-data" --apk "${APK}" --device "${DEVICE}" --output "${OUT_DIR}/data.json" --dex-dir "${3}"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import subprocess
|
|||
import threading
|
||||
import argparse
|
||||
|
||||
EMULATORS = [f"root34-{i}" for i in range(20)]
|
||||
EMULATORS = [f"root34-{i}" for i in range(1)]
|
||||
ANDROID_IMG = "system-images;android-34;default;x86_64"
|
||||
|
||||
if "ANDROID_HOME" in os.environ:
|
||||
|
|
@ -105,6 +105,8 @@ def del_emulators():
|
|||
|
||||
def worker(emu: str, apklist: list[str], out_folder: Path, script: Path):
|
||||
console_port, adb_port = get_ports(emu)
|
||||
script_env = os.environ.copy()
|
||||
script_env["ANDROID_HOME"] = str(ANDROID_HOME)
|
||||
while apklist:
|
||||
apk = apklist.pop()
|
||||
folder_name = apk.split("/")[-1].removesuffix(".apk")
|
||||
|
|
@ -127,10 +129,12 @@ def worker(emu: str, apklist: list[str], out_folder: Path, script: Path):
|
|||
f"{console_port},{adb_port}",
|
||||
]
|
||||
)
|
||||
subprocess.run([ADB, "-s", f"emulator-{console_port}", "wait-for-device"])
|
||||
|
||||
# Run script
|
||||
subprocess.run(
|
||||
["bash", str(script), f"emulator-{console_port}", apk, str(out_folder)]
|
||||
["bash", str(script), apk, f"emulator-{console_port}", str(folder)],
|
||||
env=script_env,
|
||||
)
|
||||
|
||||
# stop emulator
|
||||
|
|
|
|||
|
|
@ -341,6 +341,15 @@ def collect_runtime(
|
|||
android_sdk_path: Path | None = None,
|
||||
apk_explorer: None | Callable[[], None] = None,
|
||||
):
|
||||
data_storage: dict[str, Any] = {
|
||||
"invoke_data": [],
|
||||
"class_new_inst_data": [],
|
||||
"cnstr_new_inst_data": [],
|
||||
"dyn_code_load": [],
|
||||
"classloaders": {},
|
||||
"app_info": {},
|
||||
}
|
||||
try:
|
||||
env = dict(os.environ)
|
||||
|
||||
if adb_path is not None:
|
||||
|
|
@ -389,15 +398,6 @@ def collect_runtime(
|
|||
)
|
||||
raise e
|
||||
|
||||
data_storage: dict[str, Any] = {
|
||||
"invoke_data": [],
|
||||
"class_new_inst_data": [],
|
||||
"cnstr_new_inst_data": [],
|
||||
"dyn_code_load": [],
|
||||
"classloaders": {},
|
||||
"app_info": {},
|
||||
}
|
||||
|
||||
script.on(
|
||||
"message",
|
||||
lambda msg, data: on_message(msg, data, data_storage, file_storage),
|
||||
|
|
@ -494,6 +494,14 @@ def collect_runtime(
|
|||
data_storage["apk_cl_id"] = main_class_loader
|
||||
data_storage["exploration_data"] = exploration_data
|
||||
|
||||
except Exception as e:
|
||||
import traceback
|
||||
|
||||
data_storage["error"] = {
|
||||
"msg": str(e),
|
||||
"all": traceback.format_exception(e),
|
||||
}
|
||||
print(traceback.format_exception(e))
|
||||
json.dump(data_storage, output, indent=" ")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue