More envsetup.sh cleanup -- move these to standalone scripts
Bug: 340648588 Test: Run them Change-Id: I11d086bcaa2f9eb52f7c556d94666321010b75fa
This commit is contained in:
parent
d636ea12bf
commit
ded5d2de15
17 changed files with 468 additions and 7 deletions
48
bin/core
Executable file
48
bin/core
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# core - send SIGV and pull the core for process
|
||||
# $1 = PID of process (e.g., $(pid mediaserver))
|
||||
#
|
||||
# NOTE: coredump_setup must be called once per boot for core dumps to be
|
||||
# enabled globally.
|
||||
|
||||
set -e
|
||||
|
||||
PID=$1;
|
||||
|
||||
if [ -z "$PID" ]; then
|
||||
printf "Expecting a PID!\n";
|
||||
exit 1
|
||||
fi;
|
||||
|
||||
CORENAME=core.$PID;
|
||||
COREPATH=/cores/$CORENAME;
|
||||
SIG=SEGV;
|
||||
|
||||
coredump_enable $1;
|
||||
|
||||
done=0;
|
||||
while [ $(adb shell "[ -d /proc/$PID ] && echo -n yes") ]; do
|
||||
printf "\tSending SIG%s to %d...\n" $SIG $PID;
|
||||
adb shell kill -$SIG $PID;
|
||||
sleep 1;
|
||||
done;
|
||||
|
||||
adb shell "while [ ! -f $COREPATH ] ; do echo waiting for $COREPATH to be generated; sleep 1; done"
|
||||
echo "Done: core is under $COREPATH on device.";
|
||||
|
||||
|
32
bin/coredump_enable
Executable file
32
bin/coredump_enable
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# coredump_enable - enable core dumps for the specified process
|
||||
# $1 = PID of process (e.g., $(pid mediaserver))
|
||||
#
|
||||
# NOTE: coredump_setup must have been called as well for a core
|
||||
# dump to actually be generated.
|
||||
|
||||
set -e
|
||||
|
||||
PID=$1;
|
||||
if [ -z "$PID" ]; then
|
||||
printf "Expecting a PID!\n";
|
||||
exit 1
|
||||
fi;
|
||||
echo "Setting core limit for $PID to infinite...";
|
||||
adb shell /system/bin/ulimit -P $PID -c unlimited
|
||||
|
45
bin/coredump_setup
Executable file
45
bin/coredump_setup
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# coredump_setup - enable core dumps globally for any process
|
||||
# that has the core-file-size limit set correctly
|
||||
#
|
||||
# NOTE: You must call also coredump_enable for a specific process
|
||||
# if its core-file-size limit is not set already.
|
||||
# NOTE: Core dumps are written to ramdisk; they will not survive a reboot!
|
||||
|
||||
set -e
|
||||
|
||||
echo "Getting root...";
|
||||
adb root;
|
||||
adb wait-for-device;
|
||||
|
||||
echo "Remounting root partition read-write...";
|
||||
adb shell mount -w -o remount -t rootfs rootfs;
|
||||
sleep 1;
|
||||
adb wait-for-device;
|
||||
adb shell mkdir -p /cores;
|
||||
adb shell mount -t tmpfs tmpfs /cores;
|
||||
adb shell chmod 0777 /cores;
|
||||
|
||||
echo "Granting SELinux permission to dump in /cores...";
|
||||
adb shell restorecon -R /cores;
|
||||
|
||||
echo "Set core pattern.";
|
||||
adb shell 'echo /cores/core.%p > /proc/sys/kernel/core_pattern';
|
||||
|
||||
echo "Done."
|
||||
|
33
bin/getlastscreenshot
Executable file
33
bin/getlastscreenshot
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# coredump_enable - enable core dumps for the specified process
|
||||
# $1 = PID of process (e.g., $(pid mediaserver))
|
||||
#
|
||||
# NOTE: coredump_setup must have been called as well for a core
|
||||
# dump to actually be generated.
|
||||
|
||||
set -e
|
||||
|
||||
screenshot_path=$(getscreenshotpath)
|
||||
screenshot=`adb ${adbOptions} ls ${screenshot_path} | grep Screenshot_[0-9-]*.*\.png | sort -rk 3 | cut -d " " -f 4 | head -n 1`
|
||||
if [ "$screenshot" = "" ]; then
|
||||
echo "No screenshots found."
|
||||
exit 1
|
||||
fi
|
||||
echo "${screenshot}"
|
||||
adb ${adbOptions} pull ${screenshot_path}/${screenshot}
|
||||
|
18
bin/getprebuilt
Executable file
18
bin/getprebuilt
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
get_abs_build_var ANDROID_PREBUILTS
|
||||
|
26
bin/getscreenshotpath
Executable file
26
bin/getscreenshotpath
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# coredump_enable - enable core dumps for the specified process
|
||||
# $1 = PID of process (e.g., $(pid mediaserver))
|
||||
#
|
||||
# NOTE: coredump_setup must have been called as well for a core
|
||||
# dump to actually be generated.
|
||||
|
||||
set -e
|
||||
|
||||
echo "$(getsdcardpath)/Pictures/Screenshots"
|
||||
|
26
bin/getsdcardpath
Executable file
26
bin/getsdcardpath
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# coredump_enable - enable core dumps for the specified process
|
||||
# $1 = PID of process (e.g., $(pid mediaserver))
|
||||
#
|
||||
# NOTE: coredump_setup must have been called as well for a core
|
||||
# dump to actually be generated.
|
||||
|
||||
set -e
|
||||
|
||||
adb ${adbOptions} shell echo -n \$\{EXTERNAL_STORAGE\}
|
||||
|
18
bin/gettargetarch
Executable file
18
bin/gettargetarch
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
get_build_var TARGET_ARCH
|
||||
|
16
bin/hmm
16
bin/hmm
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2022 The Android Open Source Project
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -14,6 +14,9 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Common script utilities
|
||||
source $(cd $(dirname $BASH_SOURCE) &> /dev/null && pwd)/../../make/shell_utils.sh
|
||||
|
||||
cat <<EOF
|
||||
|
||||
Run "m help" for help with the build system itself.
|
||||
|
@ -56,7 +59,6 @@ Invoke ". build/envsetup.sh" from your shell to add the following functions to y
|
|||
- godir: Go to the directory containing a file.
|
||||
- allmod: List all modules.
|
||||
- gomod: Go to the directory containing a module.
|
||||
- bmod: Get the Bazel label of a Soong module if it is converted with bp2build.
|
||||
- pathmod: Get the directory containing a module.
|
||||
- outmod: Gets the location of a module's installed outputs with a certain extension.
|
||||
- dirmods: Gets the modules defined in a given directory.
|
||||
|
@ -68,12 +70,12 @@ Environment options:
|
|||
- SANITIZE_HOST: Set to 'address' to use ASAN for all host modules.
|
||||
- ANDROID_QUIET_BUILD: set to 'true' to display only the essential messages.
|
||||
|
||||
Look at build/make/envsetup for more functions:
|
||||
Look at the source to view more functions. The complete list is:
|
||||
EOF
|
||||
local T=$(gettop)
|
||||
local A=""
|
||||
local i
|
||||
for i in `(cat $T/build/envsetup.sh | sed -n "/^[[:blank:]]*function /s/function \([a-z]*\).*/\1/p" | sort | uniq`; do
|
||||
T=$(gettop)
|
||||
A=""
|
||||
for i in `cat $T/build/envsetup.sh | sed -n "/^[[:blank:]]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
|
||||
A="$A $i"
|
||||
done
|
||||
echo $A
|
||||
|
||||
|
|
32
bin/is64bit
Executable file
32
bin/is64bit
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Read the ELF header from /proc/$PID/exe to determine if the process is
|
||||
# 64-bit.
|
||||
|
||||
set -e
|
||||
|
||||
local PID="$1"
|
||||
if [ "$PID" ] ; then
|
||||
if [[ "$(adb shell cat /proc/$PID/exe | xxd -l 1 -s 4 -p)" -eq "02" ]] ; then
|
||||
echo "64"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
|
26
bin/isviewserverstarted
Executable file
26
bin/isviewserverstarted
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# coredump_enable - enable core dumps for the specified process
|
||||
# $1 = PID of process (e.g., $(pid mediaserver))
|
||||
#
|
||||
# NOTE: coredump_setup must have been called as well for a core
|
||||
# dump to actually be generated.
|
||||
|
||||
set -e
|
||||
|
||||
adb shell service call window 3
|
||||
|
26
bin/key_back
Executable file
26
bin/key_back
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# coredump_enable - enable core dumps for the specified process
|
||||
# $1 = PID of process (e.g., $(pid mediaserver))
|
||||
#
|
||||
# NOTE: coredump_setup must have been called as well for a core
|
||||
# dump to actually be generated.
|
||||
|
||||
set -e
|
||||
|
||||
adb shell input keyevent 4
|
||||
|
26
bin/key_home
Executable file
26
bin/key_home
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# coredump_enable - enable core dumps for the specified process
|
||||
# $1 = PID of process (e.g., $(pid mediaserver))
|
||||
#
|
||||
# NOTE: coredump_setup must have been called as well for a core
|
||||
# dump to actually be generated.
|
||||
|
||||
set -e
|
||||
|
||||
adb shell input keyevent 3
|
||||
|
26
bin/key_menu
Executable file
26
bin/key_menu
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# coredump_enable - enable core dumps for the specified process
|
||||
# $1 = PID of process (e.g., $(pid mediaserver))
|
||||
#
|
||||
# NOTE: coredump_setup must have been called as well for a core
|
||||
# dump to actually be generated.
|
||||
|
||||
set -e
|
||||
|
||||
adb shell input keyevent 82
|
||||
|
30
bin/startviewserver
Executable file
30
bin/startviewserver
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# coredump_enable - enable core dumps for the specified process
|
||||
# $1 = PID of process (e.g., $(pid mediaserver))
|
||||
#
|
||||
# NOTE: coredump_setup must have been called as well for a core
|
||||
# dump to actually be generated.
|
||||
|
||||
set -e
|
||||
|
||||
port=4939
|
||||
if [ $# -gt 0 ]; then
|
||||
port=$1
|
||||
fi
|
||||
adb shell service call window 1 i32 $port
|
||||
|
26
bin/stopviewserver
Executable file
26
bin/stopviewserver
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# coredump_enable - enable core dumps for the specified process
|
||||
# $1 = PID of process (e.g., $(pid mediaserver))
|
||||
#
|
||||
# NOTE: coredump_setup must have been called as well for a core
|
||||
# dump to actually be generated.
|
||||
|
||||
set -e
|
||||
|
||||
adb shell service call window 2
|
||||
|
21
bin/systemstack
Executable file
21
bin/systemstack
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2024 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# systemstack - dump the current stack trace of all threads in the system process
|
||||
# to the usual ANR traces file
|
||||
|
||||
stacks system_server
|
||||
|
Loading…
Reference in a new issue