diff options
| author | Po Lu | 2023-01-14 22:12:16 +0800 |
|---|---|---|
| committer | Po Lu | 2023-01-14 22:12:16 +0800 |
| commit | 2b87ab7b27163fbd7b6b64c5a44e26b0e692c00a (patch) | |
| tree | 3ab31df90bd435009d2d42b636ce3baf33bd2b28 /java/debug.sh | |
| parent | 28a9baccd4c8e997895d3adb3cfce4a11fa29896 (diff) | |
| download | emacs-2b87ab7b27163fbd7b6b64c5a44e26b0e692c00a.tar.gz emacs-2b87ab7b27163fbd7b6b64c5a44e26b0e692c00a.zip | |
Update Android port
* java/Makefile.in (clean): Fix distclean and bootstrap-clean rules.
* java/debug.sh (jdb_port):
(attach_existing):
(num_pids):
(line): Add new options to upload a gdbserver binary to the device.
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity): Make
focusedActivities public.
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu):
New class.
* java/org/gnu/emacs/EmacsDrawRectangle.java (perform): Fix
bounds computation.
* java/org/gnu/emacs/EmacsGC.java (markDirty): Set stroke width
explicitly.
* java/org/gnu/emacs/EmacsService.java (EmacsService)
(getLocationOnScreen, nameKeysym): New functions.
* java/org/gnu/emacs/EmacsView.java (EmacsView): Disable focus
highlight.
(onCreateContextMenu, popupMenu, cancelPopupMenu): New
functions.
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow): Implement a
kind of ``override redirect'' window for tooltips.
* src/android.c (struct android_emacs_service): New method
`name_keysym'.
(android_run_select_thread, android_init_events):
(android_select): Release select thread on semaphores instead of
signals to avoid one nasty race on SIGUSR2 delivery.
(android_init_emacs_service): Initialize new method.
(android_create_window): Handle CW_OVERRIDE_REDIRECT.
(android_move_resize_window, android_map_raised)
(android_translate_coordinates, android_get_keysym_name)
(android_build_string, android_exception_check): New functions.
* src/android.h: Update prototypes.
* src/androidfns.c (android_set_parent_frame, Fx_create_frame)
(unwind_create_tip_frame, android_create_tip_frame)
(android_hide_tip, compute_tip_xy, Fx_show_tip, Fx_hide_tip)
(syms_of_androidfns): Implement tooltips and iconification
reporting.
* src/androidgui.h (enum android_window_value_mask): Add
CWOverrideRedirect.
(struct android_set_window_attributes): Add `override_redirect'.
(ANDROID_IS_MODIFIER_KEY): Recognize Caps Lock.
* src/androidmenu.c (struct android_emacs_context_menu): New
struct.
(android_init_emacs_context_menu, android_unwind_local_frame)
(android_push_local_frame, android_menu_show, init_androidmenu):
New functions.
* src/androidterm.c (handle_one_android_event): Fix NULL pointer
dereference.
(android_fullscreen_hook): Handle fullscreen correctly.
(android_draw_box_rect): Fix top line.
(get_keysym_name): Implement function.
(android_create_terminal): Remove scroll bar stubs and add menu
hook.
* src/androidterm.h: Update prototypes.
* src/emacs.c (android_emacs_init): Initialize androidmenu.c.
* xcompile/Makefile.in: Fix clean rules.
Diffstat (limited to 'java/debug.sh')
| -rwxr-xr-x | java/debug.sh | 110 |
1 files changed, 74 insertions, 36 deletions
diff --git a/java/debug.sh b/java/debug.sh index 3e3e3d9c281..aa80aeeebcd 100755 --- a/java/debug.sh +++ b/java/debug.sh | |||
| @@ -31,6 +31,7 @@ gdb_port=5039 | |||
| 31 | jdb_port=64013 | 31 | jdb_port=64013 |
| 32 | jdb=no | 32 | jdb=no |
| 33 | attach_existing=no | 33 | attach_existing=no |
| 34 | gdbserver= | ||
| 34 | 35 | ||
| 35 | while [ $# -gt 0 ]; do | 36 | while [ $# -gt 0 ]; do |
| 36 | case "$1" in | 37 | case "$1" in |
| @@ -41,6 +42,7 @@ while [ $# -gt 0 ]; do | |||
| 41 | echo "You must specify an argument to --device" | 42 | echo "You must specify an argument to --device" |
| 42 | exit 1 | 43 | exit 1 |
| 43 | fi | 44 | fi |
| 45 | shift | ||
| 44 | ;; | 46 | ;; |
| 45 | "--help" ) | 47 | "--help" ) |
| 46 | echo "Usage: $progname [options] -- [gdb options]" | 48 | echo "Usage: $progname [options] -- [gdb options]" |
| @@ -50,6 +52,7 @@ while [ $# -gt 0 ]; do | |||
| 50 | echo " --jdb-port PORT run the JDB server on a specific port" | 52 | echo " --jdb-port PORT run the JDB server on a specific port" |
| 51 | echo " --jdb run JDB instead of GDB" | 53 | echo " --jdb run JDB instead of GDB" |
| 52 | echo " --attach-existing attach to an existing process" | 54 | echo " --attach-existing attach to an existing process" |
| 55 | echo " --gdbserver BINARY upload and use the specified gdbserver binary" | ||
| 53 | echo " --help print this message" | 56 | echo " --help print this message" |
| 54 | echo "" | 57 | echo "" |
| 55 | echo "Available devices:" | 58 | echo "Available devices:" |
| @@ -62,9 +65,18 @@ while [ $# -gt 0 ]; do | |||
| 62 | "--jdb" ) | 65 | "--jdb" ) |
| 63 | jdb=yes | 66 | jdb=yes |
| 64 | ;; | 67 | ;; |
| 68 | "--gdbserver" ) | ||
| 69 | shift | ||
| 70 | gdbserver=$1 | ||
| 71 | ;; | ||
| 65 | "--port" ) | 72 | "--port" ) |
| 73 | shift | ||
| 66 | gdb_port=$1 | 74 | gdb_port=$1 |
| 67 | ;; | 75 | ;; |
| 76 | "--jdb-port" ) | ||
| 77 | shift | ||
| 78 | jdb_port=$1 | ||
| 79 | ;; | ||
| 68 | "--attach-existing" ) | 80 | "--attach-existing" ) |
| 69 | attach_existing=yes | 81 | attach_existing=yes |
| 70 | ;; | 82 | ;; |
| @@ -170,46 +182,71 @@ elif [ -z $package_pids ]; then | |||
| 170 | exit 1 | 182 | exit 1 |
| 171 | fi | 183 | fi |
| 172 | 184 | ||
| 173 | # Start JDB to make the wait dialog disappear. | 185 | # This isn't necessary when attaching gdb to an existing process. |
| 174 | echo "Attaching JDB to unblock the application." | 186 | if [ "$jdb" = "yes" ] || [ "$attach_existing" != yes ]; then |
| 175 | adb -s $device forward --remove-all | 187 | # Start JDB to make the wait dialog disappear. |
| 176 | adb -s $device forward "tcp:$jdb_port" "jdwp:$pid" | 188 | echo "Attaching JDB to unblock the application." |
| 189 | adb -s $device forward --remove-all | ||
| 190 | adb -s $device forward "tcp:$jdb_port" "jdwp:$pid" | ||
| 177 | 191 | ||
| 178 | if [ ! $? ]; then | 192 | if [ ! $? ]; then |
| 179 | echo "Failed to forward jdwp:$pid to $jdb_port!" | 193 | echo "Failed to forward jdwp:$pid to $jdb_port!" |
| 180 | echo "Perhaps you need to specify a different port with --port?" | 194 | echo "Perhaps you need to specify a different port with --port?" |
| 181 | exit 1; | 195 | exit 1; |
| 182 | fi | 196 | fi |
| 183 | 197 | ||
| 184 | jdb_command="jdb -connect \ | 198 | jdb_command="jdb -connect \ |
| 185 | com.sun.jdi.SocketAttach:hostname=localhost,port=$jdb_port" | 199 | com.sun.jdi.SocketAttach:hostname=localhost,port=$jdb_port" |
| 186 | 200 | ||
| 187 | if [ $jdb = "yes" ]; then | 201 | if [ $jdb = "yes" ]; then |
| 188 | # Just start JDB and then exit | 202 | # Just start JDB and then exit |
| 189 | $jdb_command | 203 | $jdb_command |
| 190 | exit 1 | 204 | exit 1 |
| 191 | fi | 205 | fi |
| 192 | 206 | ||
| 193 | exec 4<> /tmp/file-descriptor-stamp | 207 | exec 4<> /tmp/file-descriptor-stamp |
| 194 | 208 | ||
| 195 | # Now run JDB with IO redirected to file descriptor 4 in a subprocess. | 209 | # Now run JDB with IO redirected to file descriptor 4 in a subprocess. |
| 196 | $jdb_command <&4 >&4 & | 210 | $jdb_command <&4 >&4 & |
| 197 | 211 | ||
| 198 | character= | 212 | character= |
| 199 | # Next, wait until the prompt is found. | 213 | # Next, wait until the prompt is found. |
| 200 | while read -n1 -u 4 character; do | 214 | while read -n1 -u 4 character; do |
| 201 | if [ "$character" = ">" ]; then | 215 | if [ "$character" = ">" ]; then |
| 202 | echo "JDB attached successfully" | 216 | echo "JDB attached successfully" |
| 203 | break; | 217 | break; |
| 204 | fi | 218 | fi |
| 205 | done | 219 | done |
| 220 | fi | ||
| 221 | |||
| 222 | # See if gdbserver has to be uploaded | ||
| 223 | if [ -z "$gdbserver" ]; then | ||
| 224 | gdbserver_bin=/system/bin/gdbserver | ||
| 225 | else | ||
| 226 | gdbserver_bin=/data/local/tmp/gdbserver | ||
| 227 | |||
| 228 | # Upload the specified gdbserver binary to the device. | ||
| 229 | adb -s $device push "$gdbserver" "$gdbserver_bin" | ||
| 230 | adb -s $device shell chmod +x "$gdbserver_bin" | ||
| 231 | fi | ||
| 206 | 232 | ||
| 207 | # Now start gdbserver on the device asynchronously. | 233 | # Now start gdbserver on the device asynchronously. |
| 208 | 234 | ||
| 209 | echo "Attaching gdbserver to $pid on $device..." | 235 | echo "Attaching gdbserver to $pid on $device..." |
| 210 | exec 5<> /tmp/file-descriptor-stamp | 236 | exec 5<> /tmp/file-descriptor-stamp |
| 211 | adb -s $device shell run-as $package /system/bin/gdbserver --once \ | 237 | |
| 212 | "+debug.$package_uid.socket" --attach $pid >&5 & | 238 | if [ -z "$gdbserver" ]; then |
| 239 | adb -s $device shell run-as $package $gdbserver_bin --once \ | ||
| 240 | "+debug.$package_uid.socket" --attach $pid >&5 & | ||
| 241 | gdb_socket="localfilesystem:$app_data_dir/debug.$package_uid.socket" | ||
| 242 | else | ||
| 243 | # Normally the program cannot access $gdbserver_bin when it is | ||
| 244 | # placed in /data/local/tmp. | ||
| 245 | adb -s $device shell $gdbserver_bin --once \ | ||
| 246 | "+/data/local/tmp/debug.$package_uid.socket" \ | ||
| 247 | --attach $pid >&5 & | ||
| 248 | gdb_socket="localfilesystem:/data/local/tmp/debug.$package_uid.socket" | ||
| 249 | fi | ||
| 213 | 250 | ||
| 214 | # Wait until gdbserver successfully runs. | 251 | # Wait until gdbserver successfully runs. |
| 215 | line= | 252 | line= |
| @@ -227,16 +264,17 @@ while read -u 5 line; do | |||
| 227 | esac | 264 | esac |
| 228 | done | 265 | done |
| 229 | 266 | ||
| 230 | # Send EOF to JDB to make it go away. This will also cause Android to | 267 | if [ "$attach_existing" != "yes" ]; then |
| 231 | # allow Emacs to continue executing. | 268 | # Send EOF to JDB to make it go away. This will also cause |
| 232 | echo "Making JDB go away..." | 269 | # Android to allow Emacs to continue executing. |
| 233 | echo "exit" >&4 | 270 | echo "Making JDB go away..." |
| 234 | read -u 4 line | 271 | echo "exit" >&4 |
| 235 | echo "JDB has gone away with $line" | 272 | read -u 4 line |
| 273 | echo "JDB has gone away with $line" | ||
| 274 | fi | ||
| 236 | 275 | ||
| 237 | # Forward the gdb server port here. | 276 | # Forward the gdb server port here. |
| 238 | adb -s $device forward "tcp:$gdb_port" \ | 277 | adb -s $device forward "tcp:$gdb_port" $gdb_socket |
| 239 | "localfilesystem:$app_data_dir/debug.$package_uid.socket" | ||
| 240 | if [ ! $? ]; then | 278 | if [ ! $? ]; then |
| 241 | echo "Failed to forward $app_data_dir/debug.$package_uid.socket" | 279 | echo "Failed to forward $app_data_dir/debug.$package_uid.socket" |
| 242 | echo "to $gdb_port! Perhaps you need to specify a different port" | 280 | echo "to $gdb_port! Perhaps you need to specify a different port" |