Mercurial > hg > xemacs-beta
comparison src/emacs.c @ 410:de805c49cfc1 r21-2-35
Import from CVS: tag r21-2-35
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:19:21 +0200 |
parents | 501cfd01ee6d |
children | 697ef44129c6 |
comparison
equal
deleted
inserted
replaced
409:301b9ebbdf3b | 410:de805c49cfc1 |
---|---|
204 | 204 |
205 #ifdef TOOLTALK | 205 #ifdef TOOLTALK |
206 #include TT_C_H_FILE | 206 #include TT_C_H_FILE |
207 #endif | 207 #endif |
208 | 208 |
209 #if defined (WINDOWSNT) | 209 #if defined (WIN32_NATIVE) |
210 #include <windows.h> | 210 #include "nt.h" |
211 #endif | 211 #endif |
212 | 212 |
213 /* For PATH_EXEC */ | 213 /* For PATH_EXEC */ |
214 #include <paths.h> | 214 #include <paths.h> |
215 | 215 |
524 && code != STATUS_PRIVILEGED_INSTRUCTION | 524 && code != STATUS_PRIVILEGED_INSTRUCTION |
525 && code != STATUS_DATATYPE_MISALIGNMENT) | 525 && code != STATUS_DATATYPE_MISALIGNMENT) |
526 return EXCEPTION_CONTINUE_SEARCH; | 526 return EXCEPTION_CONTINUE_SEARCH; |
527 | 527 |
528 /* I don't know if this filter is still wrapped in the outer __try, but | 528 /* I don't know if this filter is still wrapped in the outer __try, but |
529 it doesn't hurt to have another one. --ben */ | 529 it doesn't hurt to have another one. --ben |
530 And it lets us control more exactly what we really want to do in such | |
531 a situation. */ | |
530 __try | 532 __try |
531 { | 533 { |
532 fatal_error_in_progress++; | 534 fatal_error_in_progress++; |
533 preparing_for_armageddon = 1; | 535 preparing_for_armageddon = 1; |
534 | 536 |
556 Fbacktrace (Qexternal_debugging_output, Qt); | 558 Fbacktrace (Qexternal_debugging_output, Qt); |
557 } | 559 } |
558 } | 560 } |
559 /* VC++ documentation says that | 561 /* VC++ documentation says that |
560 GetExceptionCode() cannot be called inside the filter itself. */ | 562 GetExceptionCode() cannot be called inside the filter itself. */ |
561 __except (mswindows_handle_hardware_exceptions (GetExceptionCode ())) {} | 563 |
564 /* __except (mswindows_handle_hardware_exceptions (GetExceptionCode ())) {} | |
565 | |
566 The line above is original. Unfortunately, when an error is tripped | |
567 inside of the handler (e.g. during Fbacktrace()), and the handler for | |
568 the handler is invoked, it correctly notices that something is amiss | |
569 and it should just return -- but it returns EXCEPTION_CONTINUE_SEARCH, | |
570 which causes the debugger to be invoked debugging the handler code in | |
571 this function -- and WITH THE STACK UNWOUND so that you see main() | |
572 calling mswindows_handle_hardware_exceptions(), calling Fbacktrace(), | |
573 and a crash a couple of frames in -- AND NO SIGN OF THE ORIGINAL CRASH! | |
574 | |
575 There's some real weirdness going on in the stack handling -- unlike | |
576 in Unix, where further crashes just keep adding to the stack, it seems | |
577 that under the structured-exception-handling, the stack can actually | |
578 bounce back and forth between the full stack at the location of the | |
579 exception and the unwound stack at the place where the __try clause was | |
580 established. I don't completely understand it. What I do know is that | |
581 returning EXCEPTION_EXECUTE_HANDLER on nested crash has the effect of | |
582 aborting execution of the handler and going back to the outer filter | |
583 function, which returns EXCEPTION_CONTINUE_SEARCH and everything is | |
584 hunky-dorey -- your debugger sees a crash at the right location with | |
585 the right stack. | |
586 | |
587 I'm leaving in the trickier Unix-like code in the handler; someone who | |
588 understands better than me how the stack works in these handlers could | |
589 fix it up more. As it is, it works pretty well, so I'm not likely to | |
590 touch it more. --ben | |
591 */ | |
592 | |
593 __except (EXCEPTION_EXECUTE_HANDLER) {} | |
594 | |
562 | 595 |
563 /* pretend we didn't handle this, so that the debugger is invoked and/or | 596 /* pretend we didn't handle this, so that the debugger is invoked and/or |
564 the normal GPF box appears. */ | 597 the normal GPF box appears. */ |
565 return EXCEPTION_CONTINUE_SEARCH; | 598 return EXCEPTION_CONTINUE_SEARCH; |
566 } | 599 } |
597 | 630 |
598 for (i = argc - 1; i >= 0; i--) | 631 for (i = argc - 1; i >= 0; i--) |
599 { | 632 { |
600 if (i == 0 || i > skip_args) | 633 if (i == 0 || i > skip_args) |
601 { | 634 { |
602 #ifdef WINDOWSNT | 635 #ifdef WIN32_NATIVE |
603 if (i == 0) | 636 if (i == 0) |
604 { | 637 { |
605 /* Do not trust to what crt0 has stuffed into argv[0] */ | 638 /* Do not trust to what crt0 has stuffed into argv[0] */ |
606 char full_exe_path [MAX_PATH]; | 639 char full_exe_path [MAX_PATH]; |
607 GetModuleFileName (NULL, full_exe_path, MAX_PATH); | 640 GetModuleFileName (NULL, full_exe_path, MAX_PATH); |
693 #ifdef I18N4 | 726 #ifdef I18N4 |
694 /* #### - don't know why I18N4 on SunOS/JLE | 727 /* #### - don't know why I18N4 on SunOS/JLE |
695 can't deal with this. It's a potential | 728 can't deal with this. It's a potential |
696 bug that needs to be looked at. */ | 729 bug that needs to be looked at. */ |
697 # undef RUN_TIME_REMAP | 730 # undef RUN_TIME_REMAP |
698 #endif | |
699 | |
700 #if defined (MULE) && defined (MSDOS) && defined (EMX) | |
701 /* Setup all of files be input/output'ed with binary translation mode. */ | |
702 asm (" .text"); | |
703 asm ("L_setbinmode:"); | |
704 asm (" movl $1, __fmode_bin"); | |
705 asm (" ret"); | |
706 asm (" .stabs \"___CTOR_LIST__\", 23, 0, 0, L_setbinmode"); | |
707 #endif | 731 #endif |
708 | 732 |
709 /* Test whether the next argument in ARGV matches SSTR or a prefix of | 733 /* Test whether the next argument in ARGV matches SSTR or a prefix of |
710 LSTR (at least MINLEN characters). If so, then if VALPTR is non-null | 734 LSTR (at least MINLEN characters). If so, then if VALPTR is non-null |
711 (the argument is supposed to have a value) store in *VALPTR either | 735 (the argument is supposed to have a value) store in *VALPTR either |
825 init_free_hook (); | 849 init_free_hook (); |
826 #endif | 850 #endif |
827 | 851 |
828 sort_args (argc, argv); | 852 sort_args (argc, argv); |
829 | 853 |
830 #if (defined (MSDOS) && defined (EMX)) || defined (WIN32) || defined (_SCO_DS) | 854 #if defined (WIN32_NATIVE) || defined (_SCO_DS) |
831 environ = envp; | 855 environ = envp; |
832 #endif | 856 #endif |
833 | 857 |
834 /* Record (approximately) where the stack begins. */ | 858 /* Record (approximately) where the stack begins. */ |
835 stack_bottom = &stack_bottom_variable; | 859 stack_bottom = &stack_bottom_variable; |
857 #ifndef SYSTEM_MALLOC | 881 #ifndef SYSTEM_MALLOC |
858 if (!initialized) | 882 if (!initialized) |
859 /* Arrange to get warning messages as memory fills up. */ | 883 /* Arrange to get warning messages as memory fills up. */ |
860 memory_warnings (0, malloc_warning); | 884 memory_warnings (0, malloc_warning); |
861 #endif /* not SYSTEM_MALLOC */ | 885 #endif /* not SYSTEM_MALLOC */ |
862 | |
863 #ifdef MSDOS | |
864 /* We do all file input/output as binary files. When we need to translate | |
865 newlines, we do that manually. */ | |
866 _fmode = O_BINARY; | |
867 (stdin) ->_flag &= ~_IOTEXT; | |
868 (stdout)->_flag &= ~_IOTEXT; | |
869 (stderr)->_flag &= ~_IOTEXT; | |
870 #endif /* MSDOS */ | |
871 | 886 |
872 #ifdef SET_EMACS_PRIORITY | 887 #ifdef SET_EMACS_PRIORITY |
873 if (emacs_priority != 0) | 888 if (emacs_priority != 0) |
874 nice (-emacs_priority); | 889 nice (-emacs_priority); |
875 setuid (getuid ()); | 890 setuid (getuid ()); |
1287 syms_of_scrollbar_mswindows (); | 1302 syms_of_scrollbar_mswindows (); |
1288 #endif | 1303 #endif |
1289 #ifdef HAVE_MSW_C_DIRED | 1304 #ifdef HAVE_MSW_C_DIRED |
1290 syms_of_dired_mswindows (); | 1305 syms_of_dired_mswindows (); |
1291 #endif | 1306 #endif |
1292 #ifdef WINDOWSNT | 1307 #ifdef WIN32_NATIVE |
1293 syms_of_ntproc (); | 1308 syms_of_ntproc (); |
1294 #endif | 1309 #endif |
1295 #endif /* HAVE_MS_WINDOWS */ | 1310 #endif /* HAVE_MS_WINDOWS */ |
1296 | 1311 |
1297 #ifdef MULE | 1312 #ifdef MULE |
1340 #ifdef HAVE_LDAP | 1355 #ifdef HAVE_LDAP |
1341 syms_of_eldap (); | 1356 syms_of_eldap (); |
1342 #endif | 1357 #endif |
1343 | 1358 |
1344 #ifdef HAVE_GPM | 1359 #ifdef HAVE_GPM |
1345 syms_of_gpmevent (); | 1360 syms_of_gpmevent (); |
1346 #endif | 1361 #endif |
1347 | 1362 |
1348 #ifdef HAVE_POSTGRESQL | 1363 #ifdef HAVE_POSTGRESQL |
1349 syms_of_postgresql (); | 1364 syms_of_postgresql (); |
1350 #endif | 1365 #endif |
1627 #endif | 1642 #endif |
1628 vars_of_minibuf (); | 1643 vars_of_minibuf (); |
1629 #ifdef HAVE_SHLIB | 1644 #ifdef HAVE_SHLIB |
1630 vars_of_module (); | 1645 vars_of_module (); |
1631 #endif | 1646 #endif |
1632 #ifdef WINDOWSNT | 1647 #ifdef WIN32_NATIVE |
1633 vars_of_nt (); | 1648 vars_of_nt (); |
1634 vars_of_ntproc (); | 1649 vars_of_ntproc (); |
1635 #endif | 1650 #endif |
1636 vars_of_objects (); | 1651 vars_of_objects (); |
1637 vars_of_print (); | 1652 vars_of_print (); |
1745 #ifdef HAVE_POSTGRESQL | 1760 #ifdef HAVE_POSTGRESQL |
1746 vars_of_postgresql(); | 1761 vars_of_postgresql(); |
1747 #endif | 1762 #endif |
1748 | 1763 |
1749 #ifdef HAVE_GPM | 1764 #ifdef HAVE_GPM |
1750 vars_of_gpmevent (); | 1765 vars_of_gpmevent (); |
1751 #endif | 1766 #endif |
1752 | 1767 |
1753 /* Now initialize any specifier variables. We do this later | 1768 /* Now initialize any specifier variables. We do this later |
1754 because it has some dependence on the vars initialized | 1769 because it has some dependence on the vars initialized |
1755 above. | 1770 above. |
2015 to be done both at dump time and at run time. */ | 2030 to be done both at dump time and at run time. */ |
2016 | 2031 |
2017 init_initial_directory(); /* get the directory to use for the | 2032 init_initial_directory(); /* get the directory to use for the |
2018 "*scratch*" buffer, etc. */ | 2033 "*scratch*" buffer, etc. */ |
2019 | 2034 |
2020 #ifdef WINDOWSNT | 2035 #ifdef WIN32_NATIVE |
2021 /* | 2036 /* |
2022 * For Win32, call init_environment() now, so that environment/registry | 2037 * For Win32, call init_environment() now, so that environment/registry |
2023 * variables will be properly entered into Vprocess_environment. | 2038 * variables will be properly entered into Vprocess_environment. |
2024 */ | 2039 */ |
2025 init_environment(); | 2040 init_environment(); |
2030 (exec-directory and so on), and stuff | 2045 (exec-directory and so on), and stuff |
2031 related to subprocesses. This should be | 2046 related to subprocesses. This should be |
2032 first because many of the functions below | 2047 first because many of the functions below |
2033 call egetenv() to get environment variables. */ | 2048 call egetenv() to get environment variables. */ |
2034 init_lread (); /* Set up the Lisp reader. */ | 2049 init_lread (); /* Set up the Lisp reader. */ |
2035 #ifdef MSDOS | |
2036 /* Call early 'cause init_environment needs it. */ | |
2037 init_dosfns (); | |
2038 /* Set defaults for several environment variables. */ | |
2039 init_environment (argc, argv, skip_args); | |
2040 #endif | |
2041 init_cmdargs (argc, argv, skip_args); /* Create list Vcommand_line_args */ | 2050 init_cmdargs (argc, argv, skip_args); /* Create list Vcommand_line_args */ |
2042 init_buffer (); /* Set default directory of *scratch* buffer */ | 2051 init_buffer (); /* Set default directory of *scratch* buffer */ |
2043 | 2052 |
2044 #ifdef WINDOWSNT | 2053 #ifdef WIN32_NATIVE |
2045 init_ntproc(); | 2054 init_ntproc(); |
2046 #endif | 2055 #endif |
2047 | 2056 |
2048 init_redisplay (); /* Determine terminal type. | 2057 init_redisplay (); /* Determine terminal type. |
2049 init_sys_modes uses results */ | 2058 init_sys_modes uses results */ |
2095 | 2104 |
2096 Vinvocation_name = Ffile_name_nondirectory (Vinvocation_directory); | 2105 Vinvocation_name = Ffile_name_nondirectory (Vinvocation_directory); |
2097 Vinvocation_directory = Ffile_name_directory (Vinvocation_directory); | 2106 Vinvocation_directory = Ffile_name_directory (Vinvocation_directory); |
2098 } | 2107 } |
2099 | 2108 |
2100 #if defined(HAVE_SHLIB) && !defined(WINDOWSNT) | 2109 #if defined(HAVE_SHLIB) && !defined(WIN32_NATIVE) |
2101 /* This is Unix only. MS Windows NT has a library call that does | 2110 /* This is Unix only. MS Windows NT has a library call that does |
2102 The Right Thing on that system. Rumor has it, this must be | 2111 The Right Thing on that system. Rumor has it, this must be |
2103 called for GNU dld in temacs and xemacs. */ | 2112 called for GNU dld in temacs and xemacs. */ |
2104 { | 2113 { |
2105 char *buf = (char *)alloca (XSTRING_LENGTH (Vinvocation_directory) | 2114 char *buf = (char *)alloca (XSTRING_LENGTH (Vinvocation_directory) |
2529 is bracketed with both a system specific preprocessor test | 2538 is bracketed with both a system specific preprocessor test |
2530 and a runtime "do you have this problem" test | 2539 and a runtime "do you have this problem" test |
2531 | 2540 |
2532 06/20/96 robertl@dgii.com */ | 2541 06/20/96 robertl@dgii.com */ |
2533 { | 2542 { |
2534 extern char *_environ; | 2543 extern char **_environ; |
2535 if ((unsigned) environ == 0) | 2544 if ((unsigned) environ == 0) |
2536 environ=_environ; | 2545 environ=_environ; |
2537 } | 2546 } |
2538 #endif /* _SCO_DS */ | 2547 #endif /* _SCO_DS */ |
2539 vol_envp = environ; | 2548 vol_envp = environ; |
2637 and even for those that do, it might be cleaner this way. | 2646 and even for those that do, it might be cleaner this way. |
2638 If we're going down, however, we don't do this (might | 2647 If we're going down, however, we don't do this (might |
2639 be too dangerous), and if we get a crash somewhere within | 2648 be too dangerous), and if we get a crash somewhere within |
2640 this loop, we'll still autosave and won't try this again. */ | 2649 this loop, we'll still autosave and won't try this again. */ |
2641 | 2650 |
2642 LIST_LOOP_DELETING(concons, nextcons, Vconsole_list) | 2651 LIST_LOOP_DELETING (concons, nextcons, Vconsole_list) |
2643 { | 2652 { |
2644 /* There is very little point in deleting the stream console. | 2653 /* There is very little point in deleting the stream console. |
2645 It uses stdio, which should flush any buffered output and | 2654 It uses stdio, which should flush any buffered output and |
2646 something can only go wrong. -slb */ | 2655 something can only go wrong. -slb */ |
2647 /* I changed my mind. There's a stupid hack in close to add | 2656 /* I changed my mind. There's a stupid hack in close to add |
2650 delete_console_internal (XCONSOLE (XCAR (concons)), 1, 1, 0); | 2659 delete_console_internal (XCONSOLE (XCAR (concons)), 1, 1, 0); |
2651 } | 2660 } |
2652 } | 2661 } |
2653 | 2662 |
2654 UNGCPRO; | 2663 UNGCPRO; |
2664 | |
2665 #ifdef HAVE_MS_WINDOWS | |
2666 /* If we displayed a message on the console and we're exiting due to | |
2667 init error, then we must allow the user to see this message. */ | |
2668 if (mswindows_message_outputted && INTP (arg) && XINT (arg) != 0) | |
2669 Fmswindows_message_box (build_string ("Initialization error"), | |
2670 Qnil, Qnil); | |
2671 #endif | |
2655 | 2672 |
2656 shut_down_emacs (0, STRINGP (arg) ? arg : Qnil, 0); | 2673 shut_down_emacs (0, STRINGP (arg) ? arg : Qnil, 0); |
2657 | 2674 |
2658 #if defined(GNU_MALLOC) | 2675 #if defined(GNU_MALLOC) |
2659 __free_hook = | 2676 __free_hook = |
2867 memory_warnings (my_edata, malloc_warning); | 2884 memory_warnings (my_edata, malloc_warning); |
2868 #endif | 2885 #endif |
2869 | 2886 |
2870 UNGCPRO; | 2887 UNGCPRO; |
2871 | 2888 |
2872 #if defined (MSDOS) && defined (EMX) | |
2873 { | |
2874 int fd = open ((char *) XSTRING_DATA (intoname), | |
2875 O_WRONLY|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE); | |
2876 if (!fd) { | |
2877 error ("Failure operating on %s", XSTRING_DATA (intoname)); | |
2878 } else { | |
2879 _core (fd); | |
2880 close (fd); | |
2881 } | |
2882 } | |
2883 #else /* not MSDOS and EMX */ | |
2884 { | 2889 { |
2885 char *intoname_ext; | 2890 char *intoname_ext; |
2886 char *symname_ext; | 2891 char *symname_ext; |
2887 | 2892 |
2888 TO_EXTERNAL_FORMAT (LISP_STRING, intoname, | 2893 TO_EXTERNAL_FORMAT (LISP_STRING, intoname, |
2915 #ifdef DOUG_LEA_MALLOC | 2920 #ifdef DOUG_LEA_MALLOC |
2916 free (malloc_state_ptr); | 2921 free (malloc_state_ptr); |
2917 #endif | 2922 #endif |
2918 #endif /* not PDUMP */ | 2923 #endif /* not PDUMP */ |
2919 } | 2924 } |
2920 #endif /* not MSDOS and EMX */ | |
2921 | 2925 |
2922 purify_flag = opurify; | 2926 purify_flag = opurify; |
2923 | 2927 |
2924 return Qnil; | 2928 return Qnil; |
2925 } | 2929 } |
3054 #undef fprintf | 3058 #undef fprintf |
3055 #endif | 3059 #endif |
3056 | 3060 |
3057 #undef abort /* avoid infinite #define loop... */ | 3061 #undef abort /* avoid infinite #define loop... */ |
3058 | 3062 |
3059 #if defined (WINDOWSNT) && defined (DEBUG_XEMACS) | 3063 #if defined (WIN32_NATIVE) && defined (DEBUG_XEMACS) |
3060 #define enter_debugger() DebugBreak () | 3064 #define enter_debugger() DebugBreak () |
3061 #else | 3065 #else |
3062 #define enter_debugger() | 3066 #define enter_debugger() |
3063 #endif | 3067 #endif |
3064 | 3068 |