diff options
| author | Paul Eggert | 2012-07-26 01:12:03 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-07-26 01:12:03 -0700 |
| commit | 1781b9e935bea6cf2905e612da94b70028b25733 (patch) | |
| tree | c03ca850b6186d9cb0370f541b2561167512106b /src | |
| parent | 3628596ac2be344eb034e22e579a0690571fa8a9 (diff) | |
| download | emacs-1781b9e935bea6cf2905e612da94b70028b25733.tar.gz emacs-1781b9e935bea6cf2905e612da94b70028b25733.zip | |
Simplify export of symbols to GDB; fix related .gdbinit bugs.
* etc/emacs-buffer.gdb ($tagmask, $valmask): Remove.
(ygetptr): Adjust to recent changes in lisp.h and emacs.c,
by using VALMASK instead of $valmask, CHECK_LISP_OBJECT_TYPE
instead of gdb_use_union, and DATA_SEG_BITS instead of
gdb_data_seg_bits. Also, use $ptr.i rather than $ptr.u.val.
* src/.gdbinit (xgetptr, xgetint, xgettype): Don't use "set $bugfix =
$bugfix.i", as this doesn't work (with GDB 7.4.1, anyway).
(xgetptr, xgetint, xgettype, xcoding, xcharset, xprintbytestr):
Adjust to changes in lisp.h and emacs.c, by using
CHECK_LISP_OBJECT_TYPE rather than gdb_use_struct, VALMASK instead
of $valmask, DATA_SEG_BITS instead of gdb_data_seg_bits,
INTTYPEBITS instead of gdb_gctypebits - 1, USE_LSB_TAG instead of
gdb_use_lsb, (1 << GCTYPEBITS) - 1 instead of $tagmask, VALBITS
instead of gdb_valbits.
(xvectype, xvector, xpr, xprintstr, xbacktrace): Similarly, use
PSEUDOVECTOR_FLAG instead of PVEC_FLAG, and ARRAY_MARK_FLAG
instead of gdb_array_mark_flag.
(xboolvector): Get size from $->size, not $->header.size.
Use BOOL_VECTOR_BITS_PER_CHAR rather than mystery constants.
(xreload, hook-run, hookpost-run): Remove.
* src/emacs.c: Include <verify.h>.
(gdb_use_lsb, gdb_use_struct, gdb_valbits, gdb_gctypebits)
(gdb_data_seg_bits, PVEC_FLAG, gdb_array_mark_flag, gdb_pvec_type):
Remove.
(gdb_CHECK_LISP_OBJECT_TYPE, gdb_DATA_SEG_BITS, gdb_GCTYPEBITS)
(gdb_USE_LSB_TAG): New enum constants.
(CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS, GCTYPEBITS, USE_LSB_TAG):
Also define these as enum constants, so they're visible to GDB.
(ARRAY_MARK_FLAG_VAL, PSEUDOVECTOR_FLAG_VAL, VALMASK_VAL): New macros.
(ARRAY_MARK_FLAG, PSEUDOVECTOR_FLAG, VALMASK): Also define these
as constants, so they're visible to GDB.
* src/lisp.h (VALBITS, INTTYPEBITS, FIXNUM_BITS, PSEUDOVECTOR_SIZE_BITS)
(PSEUDOVECTOR_SIZE_MASK, PVEC_TYPE_MASK, BOOL_VECTOR_BITS_PER_CHAR):
Now enum constants, not macros, so they're visible to GDB.
(CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS): Default to 0, as this is
more convenient now. All uses changed.
(VALMASK) [USE_LSB_TAG]: Also define in this case.
* src/mem-limits.h (EXCEEDS_LISP_PTR): Adjust to DATA_SEG_BITS change.
Diffstat (limited to 'src')
| -rw-r--r-- | src/.gdbinit | 69 | ||||
| -rw-r--r-- | src/ChangeLog | 37 | ||||
| -rw-r--r-- | src/emacs.c | 74 | ||||
| -rw-r--r-- | src/lisp.h | 30 | ||||
| -rw-r--r-- | src/mem-limits.h | 2 |
5 files changed, 127 insertions, 85 deletions
diff --git a/src/.gdbinit b/src/.gdbinit index 379a14b2ea5..c044b404f9b 100644 --- a/src/.gdbinit +++ b/src/.gdbinit | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | # Boston, MA 02110-1301, USA. | 18 | # Boston, MA 02110-1301, USA. |
| 19 | 19 | ||
| 20 | # Force loading of symbols, enough to give us gdb_valbits etc. | 20 | # Force loading of symbols, enough to give us VALBITS etc. |
| 21 | set main | 21 | set main |
| 22 | # With some compilers, we need this to give us struct Lisp_Symbol etc.: | 22 | # With some compilers, we need this to give us struct Lisp_Symbol etc.: |
| 23 | set Fmake_symbol | 23 | set Fmake_symbol |
| @@ -43,32 +43,21 @@ handle SIGUSR2 noprint pass | |||
| 43 | # debugging. | 43 | # debugging. |
| 44 | handle SIGALRM ignore | 44 | handle SIGALRM ignore |
| 45 | 45 | ||
| 46 | # $valmask and $tagmask are mask values set up by the xreload macro below. | ||
| 47 | |||
| 48 | # Use $bugfix so that the value isn't a constant. | 46 | # Use $bugfix so that the value isn't a constant. |
| 49 | # Using a constant runs into GDB bugs sometimes. | 47 | # Using a constant runs into GDB bugs sometimes. |
| 50 | define xgetptr | 48 | define xgetptr |
| 51 | set $bugfix = $arg0 | 49 | set $bugfix = CHECK_LISP_OBJECT_TYPE ? $arg0.i : $arg0 |
| 52 | if gdb_use_struct | 50 | set $ptr = ($bugfix & VALMASK) | DATA_SEG_BITS |
| 53 | set $bugfix = $bugfix.i | ||
| 54 | end | ||
| 55 | set $ptr = $bugfix & $valmask | gdb_data_seg_bits | ||
| 56 | end | 51 | end |
| 57 | 52 | ||
| 58 | define xgetint | 53 | define xgetint |
| 59 | set $bugfix = $arg0 | 54 | set $bugfix = CHECK_LISP_OBJECT_TYPE ? $arg0.i : $arg0 |
| 60 | if gdb_use_struct | 55 | set $int = USE_LSB_TAG ? $bugfix >> INTTYPEBITS : $bugfix << INTTYPEBITS >> INTTYPEBITS |
| 61 | set $bugfix = $bugfix.i | ||
| 62 | end | ||
| 63 | set $int = gdb_use_lsb ? $bugfix >> (gdb_gctypebits - 1) : $bugfix << (gdb_gctypebits - 1) >> (gdb_gctypebits - 1) | ||
| 64 | end | 56 | end |
| 65 | 57 | ||
| 66 | define xgettype | 58 | define xgettype |
| 67 | set $bugfix = $arg0 | 59 | set $bugfix = CHECK_LISP_OBJECT_TYPE ? $arg0.i : $arg0 |
| 68 | if gdb_use_struct | 60 | set $type = (enum Lisp_Type) (USE_LSB_TAG ? $bugfix & (1 << GCTYPEBITS) - 1 : $bugfix >> VALBITS) |
| 69 | set $bugfix = $bugfix.i | ||
| 70 | end | ||
| 71 | set $type = (enum Lisp_Type) (gdb_use_lsb ? $bugfix & $tagmask : $bugfix >> gdb_valbits) | ||
| 72 | end | 61 | end |
| 73 | 62 | ||
| 74 | # Set up something to print out s-expressions. | 63 | # Set up something to print out s-expressions. |
| @@ -652,7 +641,7 @@ end | |||
| 652 | define xvectype | 641 | define xvectype |
| 653 | xgetptr $ | 642 | xgetptr $ |
| 654 | set $size = ((struct Lisp_Vector *) $ptr)->header.size | 643 | set $size = ((struct Lisp_Vector *) $ptr)->header.size |
| 655 | output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag | 644 | output ($size & PSEUDOVECTOR_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~ARRAY_MARK_FLAG |
| 656 | echo \n | 645 | echo \n |
| 657 | end | 646 | end |
| 658 | document xvectype | 647 | document xvectype |
| @@ -738,7 +727,7 @@ end | |||
| 738 | define xvector | 727 | define xvector |
| 739 | xgetptr $ | 728 | xgetptr $ |
| 740 | print (struct Lisp_Vector *) $ptr | 729 | print (struct Lisp_Vector *) $ptr |
| 741 | output ($->header.size > 50) ? 0 : ($->contents[0])@($->header.size & ~gdb_array_mark_flag) | 730 | output ($->header.size > 50) ? 0 : ($->contents[0])@($->header.size & ~ARRAY_MARK_FLAG) |
| 742 | echo \n | 731 | echo \n |
| 743 | end | 732 | end |
| 744 | document xvector | 733 | document xvector |
| @@ -847,7 +836,7 @@ end | |||
| 847 | define xboolvector | 836 | define xboolvector |
| 848 | xgetptr $ | 837 | xgetptr $ |
| 849 | print (struct Lisp_Bool_Vector *) $ptr | 838 | print (struct Lisp_Bool_Vector *) $ptr |
| 850 | output ($->header.size > 256) ? 0 : ($->data[0])@((($->header.size & ~gdb_array_mark_flag) + 7)/ 8) | 839 | output ($->size > 256) ? 0 : ($->data[0])@(($->size + BOOL_VECTOR_BITS_PER_CHAR - 1)/ BOOL_VECTOR_BITS_PER_CHAR) |
| 851 | echo \n | 840 | echo \n |
| 852 | end | 841 | end |
| 853 | document xboolvector | 842 | document xboolvector |
| @@ -990,7 +979,7 @@ define xpr | |||
| 990 | end | 979 | end |
| 991 | if $type == Lisp_Vectorlike | 980 | if $type == Lisp_Vectorlike |
| 992 | set $size = ((struct Lisp_Vector *) $ptr)->header.size | 981 | set $size = ((struct Lisp_Vector *) $ptr)->header.size |
| 993 | if ($size & PVEC_FLAG) | 982 | if ($size & PSEUDOVECTOR_FLAG) |
| 994 | set $vec = (enum pvec_type) ($size & PVEC_TYPE_MASK) | 983 | set $vec = (enum pvec_type) ($size & PVEC_TYPE_MASK) |
| 995 | if $vec == PVEC_NORMAL_VECTOR | 984 | if $vec == PVEC_NORMAL_VECTOR |
| 996 | xvector | 985 | xvector |
| @@ -1036,7 +1025,7 @@ end | |||
| 1036 | 1025 | ||
| 1037 | define xprintstr | 1026 | define xprintstr |
| 1038 | set $data = (char *) $arg0->data | 1027 | set $data = (char *) $arg0->data |
| 1039 | output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte) | 1028 | output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~ARRAY_MARK_FLAG : $arg0->size_byte) |
| 1040 | end | 1029 | end |
| 1041 | 1030 | ||
| 1042 | define xprintsym | 1031 | define xprintsym |
| @@ -1051,8 +1040,8 @@ document xprintsym | |||
| 1051 | end | 1040 | end |
| 1052 | 1041 | ||
| 1053 | define xcoding | 1042 | define xcoding |
| 1054 | set $tmp = (struct Lisp_Hash_Table *) ((Vcoding_system_hash_table & $valmask) | gdb_data_seg_bits) | 1043 | set $tmp = (struct Lisp_Hash_Table *) ((Vcoding_system_hash_table & VALMASK) | DATA_SEG_BITS) |
| 1055 | set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & $valmask) | gdb_data_seg_bits) | 1044 | set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & VALMASK) | DATA_SEG_BITS) |
| 1056 | set $name = $tmp->contents[$arg0 * 2] | 1045 | set $name = $tmp->contents[$arg0 * 2] |
| 1057 | print $name | 1046 | print $name |
| 1058 | pr | 1047 | pr |
| @@ -1064,8 +1053,8 @@ document xcoding | |||
| 1064 | end | 1053 | end |
| 1065 | 1054 | ||
| 1066 | define xcharset | 1055 | define xcharset |
| 1067 | set $tmp = (struct Lisp_Hash_Table *) ((Vcharset_hash_table & $valmask) | gdb_data_seg_bits) | 1056 | set $tmp = (struct Lisp_Hash_Table *) ((Vcharset_hash_table & VALMASK) | DATA_SEG_BITS) |
| 1068 | set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & $valmask) | gdb_data_seg_bits) | 1057 | set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & VALMASK) | DATA_SEG_BITS) |
| 1069 | p $tmp->contents[charset_table[$arg0].hash_index * 2] | 1058 | p $tmp->contents[charset_table[$arg0].hash_index * 2] |
| 1070 | pr | 1059 | pr |
| 1071 | end | 1060 | end |
| @@ -1126,7 +1115,7 @@ define xbacktrace | |||
| 1126 | if $type == Lisp_Vectorlike | 1115 | if $type == Lisp_Vectorlike |
| 1127 | xgetptr (*$bt->function) | 1116 | xgetptr (*$bt->function) |
| 1128 | set $size = ((struct Lisp_Vector *) $ptr)->header.size | 1117 | set $size = ((struct Lisp_Vector *) $ptr)->header.size |
| 1129 | output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag | 1118 | output ($size & PSEUDOVECTOR_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~ARRAY_MARK_FLAG |
| 1130 | else | 1119 | else |
| 1131 | printf "Lisp type %d", $type | 1120 | printf "Lisp type %d", $type |
| 1132 | end | 1121 | end |
| @@ -1144,7 +1133,7 @@ end | |||
| 1144 | define xprintbytestr | 1133 | define xprintbytestr |
| 1145 | set $data = (char *) $arg0->data | 1134 | set $data = (char *) $arg0->data |
| 1146 | printf "Bytecode: " | 1135 | printf "Bytecode: " |
| 1147 | output/u ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte) | 1136 | output/u ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~ARRAY_MARK_FLAG : $arg0->size_byte) |
| 1148 | end | 1137 | end |
| 1149 | document xprintbytestr | 1138 | document xprintbytestr |
| 1150 | Print a string of byte code. | 1139 | Print a string of byte code. |
| @@ -1188,19 +1177,6 @@ define hookpost-backtrace | |||
| 1188 | end | 1177 | end |
| 1189 | end | 1178 | end |
| 1190 | 1179 | ||
| 1191 | define xreload | ||
| 1192 | set $tagmask = ((1 << gdb_gctypebits) - 1) | ||
| 1193 | set $valmask = gdb_use_lsb ? ~($tagmask) : ((EMACS_INT) 1 << gdb_valbits) - 1 | ||
| 1194 | end | ||
| 1195 | document xreload | ||
| 1196 | When starting Emacs a second time in the same gdb session under | ||
| 1197 | FreeBSD 2.2.5, gdb 4.13, $valmask have lost | ||
| 1198 | their values. (The same happens on current (2000) versions of GNU/Linux | ||
| 1199 | with gdb 5.0.) | ||
| 1200 | This function reloads them. | ||
| 1201 | end | ||
| 1202 | xreload | ||
| 1203 | |||
| 1204 | # Flush display (X only) | 1180 | # Flush display (X only) |
| 1205 | define ff | 1181 | define ff |
| 1206 | set x_flush (0) | 1182 | set x_flush (0) |
| @@ -1211,15 +1187,6 @@ Works only when an inferior emacs is executing. | |||
| 1211 | end | 1187 | end |
| 1212 | 1188 | ||
| 1213 | 1189 | ||
| 1214 | define hook-run | ||
| 1215 | xreload | ||
| 1216 | end | ||
| 1217 | |||
| 1218 | # Call xreload if a new Emacs executable is loaded. | ||
| 1219 | define hookpost-run | ||
| 1220 | xreload | ||
| 1221 | end | ||
| 1222 | |||
| 1223 | set print pretty on | 1190 | set print pretty on |
| 1224 | set print sevenbit-strings | 1191 | set print sevenbit-strings |
| 1225 | 1192 | ||
diff --git a/src/ChangeLog b/src/ChangeLog index 3b85ef30795..71fc1056391 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,40 @@ | |||
| 1 | 2012-07-26 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Simplify export of symbols to GDB; fix related .gdbinit bugs. | ||
| 4 | * .gdbinit (xgetptr, xgetint, xgettype): Don't use "set $bugfix = | ||
| 5 | $bugfix.i", as this doesn't work (with GDB 7.4.1, anyway). | ||
| 6 | (xgetptr, xgetint, xgettype, xcoding, xcharset, xprintbytestr): | ||
| 7 | Adjust to changes in lisp.h and emacs.c, by using | ||
| 8 | CHECK_LISP_OBJECT_TYPE rather than gdb_use_struct, VALMASK instead | ||
| 9 | of $valmask, DATA_SEG_BITS instead of gdb_data_seg_bits, | ||
| 10 | INTTYPEBITS instead of gdb_gctypebits - 1, USE_LSB_TAG instead of | ||
| 11 | gdb_use_lsb, (1 << GCTYPEBITS) - 1 instead of $tagmask, VALBITS | ||
| 12 | instead of gdb_valbits. | ||
| 13 | (xvectype, xvector, xpr, xprintstr, xbacktrace): Similarly, use | ||
| 14 | PSEUDOVECTOR_FLAG instead of PVEC_FLAG, and ARRAY_MARK_FLAG | ||
| 15 | instead of gdb_array_mark_flag. | ||
| 16 | (xboolvector): Get size from $->size, not $->header.size. | ||
| 17 | Use BOOL_VECTOR_BITS_PER_CHAR rather than mystery constants. | ||
| 18 | (xreload, hook-run, hookpost-run): Remove. | ||
| 19 | * emacs.c: Include <verify.h>. | ||
| 20 | (gdb_use_lsb, gdb_use_struct, gdb_valbits, gdb_gctypebits) | ||
| 21 | (gdb_data_seg_bits, PVEC_FLAG, gdb_array_mark_flag, gdb_pvec_type): | ||
| 22 | Remove. | ||
| 23 | (gdb_CHECK_LISP_OBJECT_TYPE, gdb_DATA_SEG_BITS, gdb_GCTYPEBITS) | ||
| 24 | (gdb_USE_LSB_TAG): New enum constants. | ||
| 25 | (CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS, GCTYPEBITS, USE_LSB_TAG): | ||
| 26 | Also define these as enum constants, so they're visible to GDB. | ||
| 27 | (ARRAY_MARK_FLAG_VAL, PSEUDOVECTOR_FLAG_VAL, VALMASK_VAL): New macros. | ||
| 28 | (ARRAY_MARK_FLAG, PSEUDOVECTOR_FLAG, VALMASK): Also define these | ||
| 29 | as constants, so they're visible to GDB. | ||
| 30 | * lisp.h (VALBITS, INTTYPEBITS, FIXNUM_BITS, PSEUDOVECTOR_SIZE_BITS) | ||
| 31 | (PSEUDOVECTOR_SIZE_MASK, PVEC_TYPE_MASK, BOOL_VECTOR_BITS_PER_CHAR): | ||
| 32 | Now enum constants, not macros, so they're visible to GDB. | ||
| 33 | (CHECK_LISP_OBJECT_TYPE, DATA_SEG_BITS): Default to 0, as this is | ||
| 34 | more convenient now. All uses changed. | ||
| 35 | (VALMASK) [USE_LSB_TAG]: Also define in this case. | ||
| 36 | * mem-limits.h (EXCEEDS_LISP_PTR): Adjust to DATA_SEG_BITS change. | ||
| 37 | |||
| 1 | 2012-07-26 Dmitry Antipov <dmantipov@yandex.ru> | 38 | 2012-07-26 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 39 | ||
| 3 | Explicitly free restriction data that are not needed anymore. | 40 | Explicitly free restriction data that are not needed anymore. |
diff --git a/src/emacs.c b/src/emacs.c index 2893b5f205c..c737a41974f 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -29,6 +29,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 29 | #include <setjmp.h> | 29 | #include <setjmp.h> |
| 30 | #include <unistd.h> | 30 | #include <unistd.h> |
| 31 | 31 | ||
| 32 | #include <verify.h> | ||
| 33 | |||
| 32 | #include "lisp.h" | 34 | #include "lisp.h" |
| 33 | 35 | ||
| 34 | #ifdef WINDOWSNT | 36 | #ifdef WINDOWSNT |
| @@ -96,31 +98,6 @@ extern void moncontrol (int mode); | |||
| 96 | static const char emacs_version[] = VERSION; | 98 | static const char emacs_version[] = VERSION; |
| 97 | static const char emacs_copyright[] = "Copyright (C) 2012 Free Software Foundation, Inc."; | 99 | static const char emacs_copyright[] = "Copyright (C) 2012 Free Software Foundation, Inc."; |
| 98 | 100 | ||
| 99 | /* Make these values available in GDB, which doesn't see macros. */ | ||
| 100 | |||
| 101 | #if USE_LSB_TAG | ||
| 102 | int gdb_use_lsb EXTERNALLY_VISIBLE = 1; | ||
| 103 | #else | ||
| 104 | int gdb_use_lsb EXTERNALLY_VISIBLE = 0; | ||
| 105 | #endif | ||
| 106 | #ifndef CHECK_LISP_OBJECT_TYPE | ||
| 107 | int gdb_use_struct EXTERNALLY_VISIBLE = 0; | ||
| 108 | #else | ||
| 109 | int gdb_use_struct EXTERNALLY_VISIBLE = 1; | ||
| 110 | #endif | ||
| 111 | int gdb_valbits EXTERNALLY_VISIBLE = VALBITS; | ||
| 112 | int gdb_gctypebits EXTERNALLY_VISIBLE = GCTYPEBITS; | ||
| 113 | #if defined DATA_SEG_BITS && !USE_LSB_TAG | ||
| 114 | uintptr_t gdb_data_seg_bits EXTERNALLY_VISIBLE = DATA_SEG_BITS; | ||
| 115 | #else | ||
| 116 | uintptr_t gdb_data_seg_bits EXTERNALLY_VISIBLE = 0; | ||
| 117 | #endif | ||
| 118 | ptrdiff_t PVEC_FLAG EXTERNALLY_VISIBLE = PSEUDOVECTOR_FLAG; | ||
| 119 | ptrdiff_t gdb_array_mark_flag EXTERNALLY_VISIBLE = ARRAY_MARK_FLAG; | ||
| 120 | /* GDB might say "No enum type named pvec_type" if we don't have at | ||
| 121 | least one symbol with that type, and then xbacktrace could fail. */ | ||
| 122 | enum pvec_type const gdb_pvec_type EXTERNALLY_VISIBLE = 0; | ||
| 123 | |||
| 124 | /* Empty lisp strings. To avoid having to build any others. */ | 101 | /* Empty lisp strings. To avoid having to build any others. */ |
| 125 | Lisp_Object empty_unibyte_string, empty_multibyte_string; | 102 | Lisp_Object empty_unibyte_string, empty_multibyte_string; |
| 126 | 103 | ||
| @@ -2513,3 +2490,50 @@ libraries; only those already known by Emacs will be loaded. */); | |||
| 2513 | /* Make sure IS_DAEMON starts up as false. */ | 2490 | /* Make sure IS_DAEMON starts up as false. */ |
| 2514 | daemon_pipe[1] = 0; | 2491 | daemon_pipe[1] = 0; |
| 2515 | } | 2492 | } |
| 2493 | |||
| 2494 | /* Make these values available in GDB, which doesn't see macros. | ||
| 2495 | This is last, so that the #undef lines don't mess up later code. */ | ||
| 2496 | |||
| 2497 | enum | ||
| 2498 | { | ||
| 2499 | gdb_CHECK_LISP_OBJECT_TYPE = CHECK_LISP_OBJECT_TYPE, | ||
| 2500 | gdb_DATA_SEG_BITS = DATA_SEG_BITS, | ||
| 2501 | gdb_GCTYPEBITS = GCTYPEBITS, | ||
| 2502 | gdb_USE_LSB_TAG = USE_LSB_TAG | ||
| 2503 | }; | ||
| 2504 | |||
| 2505 | #undef CHECK_LISP_OBJECT_TYPE | ||
| 2506 | #undef DATA_SEG_BITS | ||
| 2507 | #undef GCTYPEBITS | ||
| 2508 | #undef USE_LSB_TAG | ||
| 2509 | |||
| 2510 | enum | ||
| 2511 | { | ||
| 2512 | CHECK_LISP_OBJECT_TYPE = gdb_CHECK_LISP_OBJECT_TYPE, | ||
| 2513 | DATA_SEG_BITS = gdb_DATA_SEG_BITS, | ||
| 2514 | GCTYPEBITS = gdb_GCTYPEBITS, | ||
| 2515 | USE_LSB_TAG = gdb_USE_LSB_TAG | ||
| 2516 | }; | ||
| 2517 | |||
| 2518 | /* These are trickier since they might fall out of int range. Each | ||
| 2519 | symbol X has a corresponding X_VAL symbol, verified to have the | ||
| 2520 | correct value. */ | ||
| 2521 | |||
| 2522 | #define ARRAY_MARK_FLAG_VAL PTRDIFF_MIN | ||
| 2523 | #define PSEUDOVECTOR_FLAG_VAL (PTRDIFF_MAX - PTRDIFF_MAX / 2) | ||
| 2524 | #define VALMASK_VAL (USE_LSB_TAG ? -1 << GCTYPEBITS : VAL_MAX) | ||
| 2525 | |||
| 2526 | verify (ARRAY_MARK_FLAG_VAL == ARRAY_MARK_FLAG); | ||
| 2527 | verify (PSEUDOVECTOR_FLAG_VAL == PSEUDOVECTOR_FLAG); | ||
| 2528 | verify (VALMASK_VAL == VALMASK); | ||
| 2529 | |||
| 2530 | #undef ARRAY_MARK_FLAG | ||
| 2531 | #undef PSEUDOVECTOR_FLAG | ||
| 2532 | #undef VALMASK | ||
| 2533 | |||
| 2534 | ptrdiff_t const EXTERNALLY_VISIBLE | ||
| 2535 | ARRAY_MARK_FLAG = ARRAY_MARK_FLAG_VAL, | ||
| 2536 | PSEUDOVECTOR_FLAG = PSEUDOVECTOR_FLAG_VAL; | ||
| 2537 | |||
| 2538 | EMACS_INT const EXTERNALLY_VISIBLE | ||
| 2539 | VALMASK = VALMASK_VAL; | ||
diff --git a/src/lisp.h b/src/lisp.h index d9305555778..204657f8348 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -155,8 +155,11 @@ extern int suppress_checking EXTERNALLY_VISIBLE; | |||
| 155 | variable VAR of type TYPE with the added requirement that it be | 155 | variable VAR of type TYPE with the added requirement that it be |
| 156 | TYPEBITS-aligned. */ | 156 | TYPEBITS-aligned. */ |
| 157 | 157 | ||
| 158 | /* Number of bits in a Lisp_Obect tag. This can be used in #if. */ | ||
| 158 | #define GCTYPEBITS 3 | 159 | #define GCTYPEBITS 3 |
| 159 | #define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS) | 160 | |
| 161 | /* Number of bits in a Lisp_Object value, not counting the tag. */ | ||
| 162 | enum { VALBITS = BITS_PER_EMACS_INT - GCTYPEBITS }; | ||
| 160 | 163 | ||
| 161 | /* The maximum value that can be stored in a EMACS_INT, assuming all | 164 | /* The maximum value that can be stored in a EMACS_INT, assuming all |
| 162 | bits other than the type bits contribute to a nonnegative signed value. | 165 | bits other than the type bits contribute to a nonnegative signed value. |
| @@ -218,8 +221,8 @@ extern int suppress_checking EXTERNALLY_VISIBLE; | |||
| 218 | 221 | ||
| 219 | /* Lisp integers use 2 tags, to give them one extra bit, thus | 222 | /* Lisp integers use 2 tags, to give them one extra bit, thus |
| 220 | extending their range from, e.g., -2^28..2^28-1 to -2^29..2^29-1. */ | 223 | extending their range from, e.g., -2^28..2^28-1 to -2^29..2^29-1. */ |
| 221 | #define INTTYPEBITS (GCTYPEBITS - 1) | 224 | enum { INTTYPEBITS = GCTYPEBITS - 1 }; |
| 222 | #define FIXNUM_BITS (VALBITS + 1) | 225 | enum { FIXNUM_BITS = VALBITS + 1 }; |
| 223 | #define INTMASK (EMACS_INT_MAX >> (INTTYPEBITS - 1)) | 226 | #define INTMASK (EMACS_INT_MAX >> (INTTYPEBITS - 1)) |
| 224 | #define LISP_INT_TAG Lisp_Int0 | 227 | #define LISP_INT_TAG Lisp_Int0 |
| 225 | #define case_Lisp_Int case Lisp_Int0: case Lisp_Int1 | 228 | #define case_Lisp_Int case Lisp_Int0: case Lisp_Int1 |
| @@ -324,6 +327,7 @@ typedef EMACS_INT Lisp_Object; | |||
| 324 | #define XIL(i) (i) | 327 | #define XIL(i) (i) |
| 325 | #define LISP_MAKE_RVALUE(o) (0+(o)) | 328 | #define LISP_MAKE_RVALUE(o) (0+(o)) |
| 326 | #define LISP_INITIALLY_ZERO 0 | 329 | #define LISP_INITIALLY_ZERO 0 |
| 330 | #define CHECK_LISP_OBJECT_TYPE 0 | ||
| 327 | #endif /* CHECK_LISP_OBJECT_TYPE */ | 331 | #endif /* CHECK_LISP_OBJECT_TYPE */ |
| 328 | 332 | ||
| 329 | /* In the size word of a vector, this bit means the vector has been marked. */ | 333 | /* In the size word of a vector, this bit means the vector has been marked. */ |
| @@ -370,13 +374,22 @@ enum pvec_type | |||
| 370 | only the number of Lisp_Object fields (that need to be traced by the GC). | 374 | only the number of Lisp_Object fields (that need to be traced by the GC). |
| 371 | The distinction is used e.g. by Lisp_Process which places extra | 375 | The distinction is used e.g. by Lisp_Process which places extra |
| 372 | non-Lisp_Object fields at the end of the structure. */ | 376 | non-Lisp_Object fields at the end of the structure. */ |
| 373 | #define PSEUDOVECTOR_SIZE_BITS 16 | 377 | enum |
| 374 | #define PSEUDOVECTOR_SIZE_MASK ((1 << PSEUDOVECTOR_SIZE_BITS) - 1) | 378 | { |
| 375 | #define PVEC_TYPE_MASK (0x0fff << PSEUDOVECTOR_SIZE_BITS) | 379 | PSEUDOVECTOR_SIZE_BITS = 16, |
| 380 | PSEUDOVECTOR_SIZE_MASK = (1 << PSEUDOVECTOR_SIZE_BITS) - 1, | ||
| 381 | PVEC_TYPE_MASK = 0x0fff << PSEUDOVECTOR_SIZE_BITS | ||
| 382 | }; | ||
| 376 | 383 | ||
| 377 | /* Number of bits to put in each character in the internal representation | 384 | /* Number of bits to put in each character in the internal representation |
| 378 | of bool vectors. This should not vary across implementations. */ | 385 | of bool vectors. This should not vary across implementations. */ |
| 379 | #define BOOL_VECTOR_BITS_PER_CHAR 8 | 386 | enum { BOOL_VECTOR_BITS_PER_CHAR = 8 }; |
| 387 | |||
| 388 | /* DATA_SEG_BITS forces extra bits to be or'd in with any pointers | ||
| 389 | which were stored in a Lisp_Object */ | ||
| 390 | #ifndef DATA_SEG_BITS | ||
| 391 | # define DATA_SEG_BITS 0 | ||
| 392 | #endif | ||
| 380 | 393 | ||
| 381 | /* These macros extract various sorts of values from a Lisp_Object. | 394 | /* These macros extract various sorts of values from a Lisp_Object. |
| 382 | For example, if tem is a Lisp_Object whose type is Lisp_Cons, | 395 | For example, if tem is a Lisp_Object whose type is Lisp_Cons, |
| @@ -387,6 +400,7 @@ enum pvec_type | |||
| 387 | 400 | ||
| 388 | #if USE_LSB_TAG | 401 | #if USE_LSB_TAG |
| 389 | 402 | ||
| 403 | #define VALMASK (-1 << GCTYPEBITS) | ||
| 390 | #define TYPEMASK ((1 << GCTYPEBITS) - 1) | 404 | #define TYPEMASK ((1 << GCTYPEBITS) - 1) |
| 391 | #define XTYPE(a) ((enum Lisp_Type) (XLI (a) & TYPEMASK)) | 405 | #define XTYPE(a) ((enum Lisp_Type) (XLI (a) & TYPEMASK)) |
| 392 | #define XINT(a) (XLI (a) >> INTTYPEBITS) | 406 | #define XINT(a) (XLI (a) >> INTTYPEBITS) |
| @@ -421,7 +435,7 @@ enum pvec_type | |||
| 421 | ((var) = XIL ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \ | 435 | ((var) = XIL ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \ |
| 422 | + ((intptr_t) (ptr) & VALMASK))) | 436 | + ((intptr_t) (ptr) & VALMASK))) |
| 423 | 437 | ||
| 424 | #ifdef DATA_SEG_BITS | 438 | #if DATA_SEG_BITS |
| 425 | /* DATA_SEG_BITS forces extra bits to be or'd in with any pointers | 439 | /* DATA_SEG_BITS forces extra bits to be or'd in with any pointers |
| 426 | which were stored in a Lisp_Object */ | 440 | which were stored in a Lisp_Object */ |
| 427 | #define XPNTR(a) ((uintptr_t) ((XLI (a) & VALMASK)) | DATA_SEG_BITS)) | 441 | #define XPNTR(a) ((uintptr_t) ((XLI (a) & VALMASK)) | DATA_SEG_BITS)) |
diff --git a/src/mem-limits.h b/src/mem-limits.h index dbe58dc9156..0376f407217 100644 --- a/src/mem-limits.h +++ b/src/mem-limits.h | |||
| @@ -36,7 +36,7 @@ extern int etext; | |||
| 36 | extern char *start_of_data (void) ATTRIBUTE_CONST; | 36 | extern char *start_of_data (void) ATTRIBUTE_CONST; |
| 37 | #if USE_LSB_TAG || UINTPTR_MAX <= VAL_MAX | 37 | #if USE_LSB_TAG || UINTPTR_MAX <= VAL_MAX |
| 38 | #define EXCEEDS_LISP_PTR(ptr) 0 | 38 | #define EXCEEDS_LISP_PTR(ptr) 0 |
| 39 | #elif defined DATA_SEG_BITS | 39 | #elif DATA_SEG_BITS |
| 40 | #define EXCEEDS_LISP_PTR(ptr) \ | 40 | #define EXCEEDS_LISP_PTR(ptr) \ |
| 41 | (((uintptr_t) (ptr) & ~DATA_SEG_BITS) >> VALBITS) | 41 | (((uintptr_t) (ptr) & ~DATA_SEG_BITS) >> VALBITS) |
| 42 | #else | 42 | #else |