diff options
| author | Po Lu | 2023-01-19 22:19:06 +0800 |
|---|---|---|
| committer | Po Lu | 2023-01-19 22:19:06 +0800 |
| commit | a496509cedb17109d0e6297a74e2ff8ed526333c (patch) | |
| tree | 46f3db2be263de7074675a5188796e25f21d4888 /java/debug.sh | |
| parent | 6253e7e74249c7cdfa86723f0b91a1d207cb143e (diff) | |
| download | emacs-a496509cedb17109d0e6297a74e2ff8ed526333c.tar.gz emacs-a496509cedb17109d0e6297a74e2ff8ed526333c.zip | |
Update Android port
* .gitignore: Add new files.
* INSTALL.android: Explain how to build Emacs for ancient
versions of Android.
* admin/merge-gnulib (GNULIB_MODULES): Add getdelim.
* build-aux/config.guess (timestamp, version):
* build-aux/config.sub (timestamp, version): Autoupdate.
* configure.ac (BUILD_DETAILS, ANDROID_MIN_SDK):
(ANDROID_STUBIFY): Allow specifying CFLAGS via ANDROID_CFLAGS.
Add new configure tests for Android API version when not
explicitly specified.
* doc/emacs/android.texi (Android): Add reference to ``Other
Input Devices''.
(Android File System): Remove restrictions on directory-files on
the assets directory.
* doc/emacs/emacs.texi (Top): Add Other Input Devices to menu.
* doc/emacs/input.texi (Other Input Devices): New node.
* doc/lispref/commands.texi (Touchscreen Events): Document
changes to touchscreen input events.
* doc/lispref/frames.texi (Pop-Up Menus): Likewise.
* etc/NEWS: Announce changes.
* java/Makefile.in: Use lib-src/asset-directory-tool to generate
an `directory-tree' file placed in /assets.
* java/debug.sh: Large adjustments to support Android 2.2 and
later.
* java/org/gnu/emacs/EmacsContextMenu.java (inflateMenuItems):
* java/org/gnu/emacs/EmacsCopyArea.java (perform):
* java/org/gnu/emacs/EmacsDialog.java (toAlertDialog):
* java/org/gnu/emacs/EmacsDrawLine.java (perform):
* java/org/gnu/emacs/EmacsDrawRectangle.java (perform):
* java/org/gnu/emacs/EmacsDrawable.java (EmacsDrawable):
* java/org/gnu/emacs/EmacsFillPolygon.java (perform):
* java/org/gnu/emacs/EmacsFillRectangle.java (perform):
* java/org/gnu/emacs/EmacsGC.java (EmacsGC):
* java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap):
(destroyHandle):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java (draw): Avoid
redundant canvas saves and restores.
* java/org/gnu/emacs/EmacsService.java (run):
* java/org/gnu/emacs/EmacsView.java (EmacsView):
(handleDirtyBitmap):
* java/org/gnu/emacs/EmacsWindow.java (changeWindowBackground)
(EmacsWindow): Make compatible with Android 2.2 and later.
* lib-src/Makefile.in (DONT_INSTALL): Add asset-directory-tool
on Android.:(asset-directory-tool{EXEEXT}): New target.
* lib-src/asset-directory-tool.c (struct directory_tree, xmalloc)
(main_1, main_2, main): New file.
* lib, m4: Merge from gnulib. This will be reverted before
merging to master.
* lisp/button.el (button-map):
(push-button):
* lisp/frame.el (display-popup-menus-p): Improve touchscreen
support.
* lisp/subr.el (event-start):
(event-end): Handle touchscreen events.
* lisp/touch-screen.el (touch-screen-handle-timeout):
(touch-screen-handle-point-update):
(touch-screen-handle-point-up):
(touch-screen-track-tap):
(touch-screen-track-drag):
(touch-screen-drag-mode-line-1):
(touch-screen-drag-mode-line): New functions.
([mode-line touchscreen-begin]):
([bottom-divider touchscreen-begin]): Bind new events.
* lisp/wid-edit.el (widget-event-point):
(widget-keymap):
(widget-event-start):
(widget-button--check-and-call-button):
(widget-button-click): Improve touchscreen support.
* src/alloc.c (make_lisp_symbol): Avoid ICE on Android NDK GCC.
(mark_pinned_symbols): Likewise.
* src/android.c (struct android_emacs_window): New struct.
(window_class): New variable.
(android_run_select_thread): Add workaround for Android platform
bug.
(android_extract_long, android_scan_directory_tree): New
functions.
(android_file_access_p): Use those functions instead.
(android_init_emacs_window): New function.
(android_init_emacs_gc_class): Update signature of `markDirty'.
(android_change_gc, android_set_clip_rectangles): Tell the GC
whether or not clip rects were dirtied.
(android_swap_buffers): Do not look up method every time.
(struct android_dir): Adjust for new directory tree lookup.
(android_opendir, android_readdir, android_closedir): Likewise.
(android_four_corners_bilinear): Fix coding style.
(android_ftruncate): New function.
* src/android.h: Update prototypes. Replace ftruncate with
android_ftruncate when necessary.
* src/androidterm.c (handle_one_android_event): Pacify GCC. Fix
touch screen tool bar bug.
* src/emacs.c (using_utf8): Fix compilation error.
* src/fileio.c (Ffile_system_info): Return Qnil when fsusage.o
is not built.
* src/filelock.c (BOOT_TIME_FILE): Fix definition for Android.
* src/frame.c (Fx_parse_geometry): Fix uninitialized variable
uses.
* src/keyboard.c (lispy_function_keys): Fix `back'.
* src/menu.c (x_popup_menu_1): Handle touch screen events.
(Fx_popup_menu): Document changes.
* src/sfnt.c (main): Improve tests.
* src/sfntfont-android.c (sfntfont_android_put_glyphs): Fix
minor problem.
(init_sfntfont_android): Check for
HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL.
* src/sfntfont.c (struct sfnt_font_desc): New fields `adstyle'
and `languages'.
(sfnt_parse_style): Append tokens to adstyle.
(sfnt_parse_languages): New function.
(sfnt_enum_font_1): Parse supported languages and adstyle.
(sfntfont_list_1): Handle new fields.
(sfntfont_text_extents): Fix uninitialized variable use.
(syms_of_sfntfont, mark_sfntfont): Adjust accordingly.
Diffstat (limited to 'java/debug.sh')
| -rwxr-xr-x | java/debug.sh | 155 |
1 files changed, 99 insertions, 56 deletions
diff --git a/java/debug.sh b/java/debug.sh index aa80aeeebcd..7008664c049 100755 --- a/java/debug.sh +++ b/java/debug.sh | |||
| @@ -93,7 +93,7 @@ while [ $# -gt 0 ]; do | |||
| 93 | shift | 93 | shift |
| 94 | done | 94 | done |
| 95 | 95 | ||
| 96 | if [ -z $devices ]; then | 96 | if [ -z "$devices" ]; then |
| 97 | echo "No devices are available." | 97 | echo "No devices are available." |
| 98 | exit 1 | 98 | exit 1 |
| 99 | fi | 99 | fi |
| @@ -117,25 +117,43 @@ if [ -z $app_data_dir ]; then | |||
| 117 | echo "Is it installed?" | 117 | echo "Is it installed?" |
| 118 | fi | 118 | fi |
| 119 | 119 | ||
| 120 | echo "Found application data directory at $app_data_dir..." | 120 | echo "Found application data directory at" "$app_data_dir" |
| 121 | 121 | ||
| 122 | # Find which PIDs are associated with org.gnu.emacs | 122 | # Generate an awk script to extract PIDs from Android ps output. It |
| 123 | package_uid=`adb -s $device shell run-as $package id -u` | 123 | # is enough to run `ps' as the package user on newer versions of |
| 124 | 124 | # Android, but that doesn't work on Android 2.3. | |
| 125 | if [ -z $package_uid ]; then | 125 | cat << EOF > tmp.awk |
| 126 | echo "Failed to obtain UID of packages named $package" | 126 | BEGIN { |
| 127 | exit 1 | 127 | pid = 0; |
| 128 | fi | 128 | pid_column = 2; |
| 129 | 129 | } | |
| 130 | # First, run ps -u $package_uid -o PID,CMD to fetch the list of | 130 | |
| 131 | # process IDs. | 131 | { |
| 132 | package_pids=`adb -s $device shell run-as $package ps -u $package_uid -o PID,CMD` | 132 | # Remove any trailing carriage return from the input line. |
| 133 | 133 | gsub ("\r", "", \$NF) | |
| 134 | # Next, remove lines matching "ps" itself. | 134 | |
| 135 | package_pids=`awk -- '{ | 135 | # If this is line 1, figure out which column contains the PID. |
| 136 | if (!match ($0, /(PID|ps)/)) | 136 | if (NR == 1) |
| 137 | print $1 | 137 | { |
| 138 | }' <<< $package_pids` | 138 | for (n = 1; n <= NF; ++n) |
| 139 | { | ||
| 140 | if (\$n == "PID") | ||
| 141 | pid_column=n; | ||
| 142 | } | ||
| 143 | } | ||
| 144 | else if (\$NF == "$package") | ||
| 145 | print \$pid_column | ||
| 146 | } | ||
| 147 | EOF | ||
| 148 | |||
| 149 | # Make sure that file disappears once this script exits. | ||
| 150 | trap "rm -f $(pwd)/tmp.awk" 0 | ||
| 151 | |||
| 152 | # First, run ps to fetch the list of process IDs. | ||
| 153 | package_pids=`adb -s $device shell ps` | ||
| 154 | |||
| 155 | # Next, extract the list of PIDs currently running. | ||
| 156 | package_pids=`awk -f tmp.awk <<< $package_pids` | ||
| 139 | 157 | ||
| 140 | if [ "$attach_existing" != "yes" ]; then | 158 | if [ "$attach_existing" != "yes" ]; then |
| 141 | # Finally, kill each existing process. | 159 | # Finally, kill each existing process. |
| @@ -149,19 +167,20 @@ if [ "$attach_existing" != "yes" ]; then | |||
| 149 | echo "Starting activity $activity and attaching debugger" | 167 | echo "Starting activity $activity and attaching debugger" |
| 150 | 168 | ||
| 151 | # Exit if the activity could not be started. | 169 | # Exit if the activity could not be started. |
| 152 | adb -s $device shell am start -D "$package/$activity" | 170 | adb -s $device shell am start -D -n "$package/$activity" |
| 153 | if [ ! $? ]; then | 171 | if [ ! $? ]; then |
| 154 | exit 1; | 172 | exit 1; |
| 155 | fi | 173 | fi |
| 156 | 174 | ||
| 175 | # Sleep for a bit. Otherwise, the process may not have started | ||
| 176 | # yet. | ||
| 177 | sleep 1 | ||
| 178 | |||
| 157 | # Now look for processes matching the package again. | 179 | # Now look for processes matching the package again. |
| 158 | package_pids=`adb -s $device shell run-as $package ps -u $package_uid -o PID,CMD` | 180 | package_pids=`adb -s $device shell ps` |
| 159 | 181 | ||
| 160 | # Next, remove lines matching "ps" itself. | 182 | # Next, remove lines matching "ps" itself. |
| 161 | package_pids=`awk -- '{ | 183 | package_pids=`awk -f tmp.awk <<< $package_pids` |
| 162 | if (!match ($0, /(PID|ps)/)) | ||
| 163 | print $1 | ||
| 164 | }' <<< $package_pids` | ||
| 165 | fi | 184 | fi |
| 166 | 185 | ||
| 167 | pid=$package_pids | 186 | pid=$package_pids |
| @@ -170,10 +189,10 @@ num_pids=`wc -w <<< "$package_pids"` | |||
| 170 | if [ $num_pids -gt 1 ]; then | 189 | if [ $num_pids -gt 1 ]; then |
| 171 | echo "More than one process was started:" | 190 | echo "More than one process was started:" |
| 172 | echo "" | 191 | echo "" |
| 173 | adb -s $device shell run-as $package ps -u $package_uid | awk -- '{ | 192 | adb -s $device shell run-as $package ps | awk -- "{ |
| 174 | if (!match ($0, /ps/)) | 193 | if (!match (\$0, /ps/) && match (\$0, /$package/)) |
| 175 | print $0 | 194 | print \$0 |
| 176 | }' | 195 | }" |
| 177 | echo "" | 196 | echo "" |
| 178 | printf "Which one do you want to attach to? " | 197 | printf "Which one do you want to attach to? " |
| 179 | read pid | 198 | read pid |
| @@ -182,10 +201,12 @@ elif [ -z $package_pids ]; then | |||
| 182 | exit 1 | 201 | exit 1 |
| 183 | fi | 202 | fi |
| 184 | 203 | ||
| 185 | # This isn't necessary when attaching gdb to an existing process. | 204 | # If either --jdb was specified or debug.sh is not connecting to an |
| 205 | # existing process, then store a suitable JDB invocation in | ||
| 206 | # jdb_command. GDB will then run JDB to unblock the application from | ||
| 207 | # the wait dialog after startup. | ||
| 208 | |||
| 186 | if [ "$jdb" = "yes" ] || [ "$attach_existing" != yes ]; then | 209 | if [ "$jdb" = "yes" ] || [ "$attach_existing" != yes ]; then |
| 187 | # Start JDB to make the wait dialog disappear. | ||
| 188 | echo "Attaching JDB to unblock the application." | ||
| 189 | adb -s $device forward --remove-all | 210 | adb -s $device forward --remove-all |
| 190 | adb -s $device forward "tcp:$jdb_port" "jdwp:$pid" | 211 | adb -s $device forward "tcp:$jdb_port" "jdwp:$pid" |
| 191 | 212 | ||
| @@ -203,20 +224,42 @@ if [ "$jdb" = "yes" ] || [ "$attach_existing" != yes ]; then | |||
| 203 | $jdb_command | 224 | $jdb_command |
| 204 | exit 1 | 225 | exit 1 |
| 205 | fi | 226 | fi |
| 227 | fi | ||
| 206 | 228 | ||
| 207 | exec 4<> /tmp/file-descriptor-stamp | 229 | if [ -n "$jdb_command" ]; then |
| 230 | echo "Starting JDB to unblock application." | ||
| 208 | 231 | ||
| 209 | # Now run JDB with IO redirected to file descriptor 4 in a subprocess. | 232 | # Start JDB to unblock the application. |
| 210 | $jdb_command <&4 >&4 & | 233 | coproc JDB { $jdb_command; } |
| 211 | 234 | ||
| 212 | character= | 235 | # Tell JDB to first suspend all threads. |
| 213 | # Next, wait until the prompt is found. | 236 | echo "suspend" >&${JDB[1]} |
| 214 | while read -n1 -u 4 character; do | 237 | |
| 215 | if [ "$character" = ">" ]; then | 238 | # Tell JDB to print a magic string once the program is |
| 216 | echo "JDB attached successfully" | 239 | # initialized. |
| 217 | break; | 240 | echo "print \"__verify_jdb_has_started__\"" >&${JDB[1]} |
| 241 | |||
| 242 | # Now wait for JDB to give the string back. | ||
| 243 | line= | ||
| 244 | while :; do | ||
| 245 | read -u ${JDB[0]} line | ||
| 246 | if [ ! $? ]; then | ||
| 247 | echo "Failed to read JDB output" | ||
| 248 | exit 1 | ||
| 218 | fi | 249 | fi |
| 250 | |||
| 251 | case "$line" in | ||
| 252 | *__verify_jdb_has_started__*) | ||
| 253 | # Android only polls for a Java debugger every 200ms, so | ||
| 254 | # the debugger must be connected for at least that long. | ||
| 255 | echo "Pausing 1 second for the program to continue." | ||
| 256 | sleep 1 | ||
| 257 | break | ||
| 258 | ;; | ||
| 259 | esac | ||
| 219 | done | 260 | done |
| 261 | |||
| 262 | # Note that JDB does not exit until GDB is fully attached! | ||
| 220 | fi | 263 | fi |
| 221 | 264 | ||
| 222 | # See if gdbserver has to be uploaded | 265 | # See if gdbserver has to be uploaded |
| @@ -234,18 +277,19 @@ fi | |||
| 234 | 277 | ||
| 235 | echo "Attaching gdbserver to $pid on $device..." | 278 | echo "Attaching gdbserver to $pid on $device..." |
| 236 | exec 5<> /tmp/file-descriptor-stamp | 279 | exec 5<> /tmp/file-descriptor-stamp |
| 280 | rm -f /tmp/file-descriptor-stamp | ||
| 237 | 281 | ||
| 238 | if [ -z "$gdbserver" ]; then | 282 | if [ -z "$gdbserver" ]; then |
| 239 | adb -s $device shell run-as $package $gdbserver_bin --once \ | 283 | adb -s $device shell run-as $package $gdbserver_bin --once \ |
| 240 | "+debug.$package_uid.socket" --attach $pid >&5 & | 284 | "+debug.$package.socket" --attach $pid >&5 & |
| 241 | gdb_socket="localfilesystem:$app_data_dir/debug.$package_uid.socket" | 285 | gdb_socket="localfilesystem:$app_data_dir/debug.$package.socket" |
| 242 | else | 286 | else |
| 243 | # Normally the program cannot access $gdbserver_bin when it is | 287 | # Normally the program cannot access $gdbserver_bin when it is |
| 244 | # placed in /data/local/tmp. | 288 | # placed in /data/local/tmp. |
| 245 | adb -s $device shell $gdbserver_bin --once \ | 289 | adb -s $device shell $gdbserver_bin --once \ |
| 246 | "+/data/local/tmp/debug.$package_uid.socket" \ | 290 | "+/data/local/tmp/debug.$package.socket" \ |
| 247 | --attach $pid >&5 & | 291 | --attach $pid >&5 & |
| 248 | gdb_socket="localfilesystem:/data/local/tmp/debug.$package_uid.socket" | 292 | gdb_socket="localfilesystem:/data/local/tmp/debug.$package.socket" |
| 249 | fi | 293 | fi |
| 250 | 294 | ||
| 251 | # Wait until gdbserver successfully runs. | 295 | # Wait until gdbserver successfully runs. |
| @@ -256,7 +300,7 @@ while read -u 5 line; do | |||
| 256 | break; | 300 | break; |
| 257 | ;; | 301 | ;; |
| 258 | *error* | *Error* | failed ) | 302 | *error* | *Error* | failed ) |
| 259 | echo $line | 303 | echo "GDB error:" $line |
| 260 | exit 1 | 304 | exit 1 |
| 261 | ;; | 305 | ;; |
| 262 | * ) | 306 | * ) |
| @@ -264,19 +308,18 @@ while read -u 5 line; do | |||
| 264 | esac | 308 | esac |
| 265 | done | 309 | done |
| 266 | 310 | ||
| 267 | if [ "$attach_existing" != "yes" ]; then | 311 | # Now that GDB is attached, tell the Java debugger to resume execution |
| 268 | # Send EOF to JDB to make it go away. This will also cause | 312 | # and then exit. |
| 269 | # Android to allow Emacs to continue executing. | 313 | |
| 270 | echo "Making JDB go away..." | 314 | if [ -n "$jdb_command" ]; then |
| 271 | echo "exit" >&4 | 315 | echo "resume" >&${JDB[1]} |
| 272 | read -u 4 line | 316 | echo "exit" >&${JDB[1]} |
| 273 | echo "JDB has gone away with $line" | ||
| 274 | fi | 317 | fi |
| 275 | 318 | ||
| 276 | # Forward the gdb server port here. | 319 | # Forward the gdb server port here. |
| 277 | adb -s $device forward "tcp:$gdb_port" $gdb_socket | 320 | adb -s $device forward "tcp:$gdb_port" $gdb_socket |
| 278 | if [ ! $? ]; then | 321 | if [ ! $? ]; then |
| 279 | echo "Failed to forward $app_data_dir/debug.$package_uid.socket" | 322 | echo "Failed to forward $app_data_dir/debug.$package.socket" |
| 280 | echo "to $gdb_port! Perhaps you need to specify a different port" | 323 | echo "to $gdb_port! Perhaps you need to specify a different port" |
| 281 | echo "with --port?" | 324 | echo "with --port?" |
| 282 | exit 1; | 325 | exit 1; |
| @@ -284,4 +327,4 @@ fi | |||
| 284 | 327 | ||
| 285 | # Finally, start gdb with any extra arguments needed. | 328 | # Finally, start gdb with any extra arguments needed. |
| 286 | cd "$oldpwd" | 329 | cd "$oldpwd" |
| 287 | gdb --eval-command "" --eval-command "target remote localhost:$gdb_port" $gdbargs | 330 | gdb --eval-command "target remote localhost:$gdb_port" $gdbargs |