comparison lisp/progmodes/gud.el @ 62049:471fca8487d3

Replace string-to-int with string-to-number. (gud-find-file): Handle gdb-define-alist.
author Nick Roberts <nickrob@snap.net.nz>
date Tue, 03 May 2005 06:47:18 +0000
parents a095ad7b17e4
children 6cd1d39df919 08185296b491
comparison
equal deleted inserted replaced
62048:55735e23c27d 62049:471fca8487d3
226 (when buf 226 (when buf
227 ;; Copy `gud-minor-mode' to the found buffer to turn on the menu. 227 ;; Copy `gud-minor-mode' to the found buffer to turn on the menu.
228 (with-current-buffer buf 228 (with-current-buffer buf
229 (set (make-local-variable 'gud-minor-mode) minor-mode) 229 (set (make-local-variable 'gud-minor-mode) minor-mode)
230 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map) 230 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)
231 (when (memq gud-minor-mode '(gdbmi gdba))
232 (make-local-variable 'gdb-define-alist)
233 (unless gdb-define-alist (gdb-create-define-alist))
234 (add-hook 'after-save-hook 'gdb-create-define-alist nil t))
231 (make-local-variable 'gud-keep-buffer)) 235 (make-local-variable 'gud-keep-buffer))
232 buf))) 236 buf)))
233 237
234 ;; ====================================================================== 238 ;; ======================================================================
235 ;; command definition 239 ;; command definition
472 (while (string-match gud-gdb-marker-regexp gud-marker-acc) 476 (while (string-match gud-gdb-marker-regexp gud-marker-acc)
473 (setq 477 (setq
474 478
475 ;; Extract the frame position from the marker. 479 ;; Extract the frame position from the marker.
476 gud-last-frame (cons (match-string 1 gud-marker-acc) 480 gud-last-frame (cons (match-string 1 gud-marker-acc)
477 (string-to-int (match-string 2 gud-marker-acc))) 481 (string-to-number (match-string 2 gud-marker-acc)))
478 482
479 ;; Append any text before the marker to the output we're going 483 ;; Append any text before the marker to the output we're going
480 ;; to return - we don't include the marker in this text. 484 ;; to return - we don't include the marker in this text.
481 output (concat output 485 output (concat output
482 (substring gud-marker-acc 0 (match-beginning 0))) 486 (substring gud-marker-acc 0 (match-beginning 0)))
773 ;; System V Release 3.2 uses this format 777 ;; System V Release 3.2 uses this format
774 ((string-match "\\(^\\|\n\\)\\*?\\(0x\\w* in \\)?\\([^:\n]*\\):\\([0-9]*\\):.*\n" 778 ((string-match "\\(^\\|\n\\)\\*?\\(0x\\w* in \\)?\\([^:\n]*\\):\\([0-9]*\\):.*\n"
775 gud-marker-acc start) 779 gud-marker-acc start)
776 (setq gud-last-frame 780 (setq gud-last-frame
777 (cons (match-string 3 gud-marker-acc) 781 (cons (match-string 3 gud-marker-acc)
778 (string-to-int (match-string 4 gud-marker-acc))))) 782 (string-to-number (match-string 4 gud-marker-acc)))))
779 ;; System V Release 4.0 quite often clumps two lines together 783 ;; System V Release 4.0 quite often clumps two lines together
780 ((string-match "^\\(BREAKPOINT\\|STEPPED\\) process [0-9]+ function [^ ]+ in \\(.+\\)\n\\([0-9]+\\):" 784 ((string-match "^\\(BREAKPOINT\\|STEPPED\\) process [0-9]+ function [^ ]+ in \\(.+\\)\n\\([0-9]+\\):"
781 gud-marker-acc start) 785 gud-marker-acc start)
782 (setq gud-sdb-lastfile (match-string 2 gud-marker-acc)) 786 (setq gud-sdb-lastfile (match-string 2 gud-marker-acc))
783 (setq gud-last-frame 787 (setq gud-last-frame
784 (cons gud-sdb-lastfile 788 (cons gud-sdb-lastfile
785 (string-to-int (match-string 3 gud-marker-acc))))) 789 (string-to-number (match-string 3 gud-marker-acc)))))
786 ;; System V Release 4.0 790 ;; System V Release 4.0
787 ((string-match "^\\(BREAKPOINT\\|STEPPED\\) process [0-9]+ function [^ ]+ in \\(.+\\)\n" 791 ((string-match "^\\(BREAKPOINT\\|STEPPED\\) process [0-9]+ function [^ ]+ in \\(.+\\)\n"
788 gud-marker-acc start) 792 gud-marker-acc start)
789 (setq gud-sdb-lastfile (match-string 2 gud-marker-acc))) 793 (setq gud-sdb-lastfile (match-string 2 gud-marker-acc)))
790 ((and gud-sdb-lastfile (string-match "^\\([0-9]+\\):" 794 ((and gud-sdb-lastfile (string-match "^\\([0-9]+\\):"
791 gud-marker-acc start)) 795 gud-marker-acc start))
792 (setq gud-last-frame 796 (setq gud-last-frame
793 (cons gud-sdb-lastfile 797 (cons gud-sdb-lastfile
794 (string-to-int (match-string 1 gud-marker-acc))))) 798 (string-to-number (match-string 1 gud-marker-acc)))))
795 (t 799 (t
796 (setq gud-sdb-lastfile nil))) 800 (setq gud-sdb-lastfile nil)))
797 (setq start (match-end 0))) 801 (setq start (match-end 0)))
798 802
799 ;; Search for the last incomplete line in this chunk 803 ;; Search for the last incomplete line in this chunk
875 (string-match 879 (string-match
876 "signal .* in .* at line \\([0-9]*\\) in file \"\\([^\"]*\\)\"" 880 "signal .* in .* at line \\([0-9]*\\) in file \"\\([^\"]*\\)\""
877 gud-marker-acc start)) 881 gud-marker-acc start))
878 (setq gud-last-frame 882 (setq gud-last-frame
879 (cons (match-string 2 gud-marker-acc) 883 (cons (match-string 2 gud-marker-acc)
880 (string-to-int (match-string 1 gud-marker-acc))) 884 (string-to-number (match-string 1 gud-marker-acc)))
881 start (match-end 0))) 885 start (match-end 0)))
882 886
883 ;; Search for the last incomplete line in this chunk 887 ;; Search for the last incomplete line in this chunk
884 (while (string-match "\n" gud-marker-acc start) 888 (while (string-match "\n" gud-marker-acc start)
885 (setq start (match-end 0))) 889 (setq start (match-end 0)))
922 (setq 926 (setq
923 927
924 ;; Extract the frame position from the marker. 928 ;; Extract the frame position from the marker.
925 gud-last-frame 929 gud-last-frame
926 (cons (match-string 1 gud-marker-acc) 930 (cons (match-string 1 gud-marker-acc)
927 (string-to-int (match-string 2 gud-marker-acc))) 931 (string-to-number (match-string 2 gud-marker-acc)))
928 932
929 ;; Append any text before the marker to the output we're going 933 ;; Append any text before the marker to the output we're going
930 ;; to return - we don't include the marker in this text. 934 ;; to return - we don't include the marker in this text.
931 output (concat output 935 output (concat output
932 (substring gud-marker-acc 0 (match-beginning 0))) 936 (substring gud-marker-acc 0 (match-beginning 0)))
1030 result) 1034 result)
1031 (let ((file (match-string 1 result))) 1035 (let ((file (match-string 1 result)))
1032 (if (file-exists-p file) 1036 (if (file-exists-p file)
1033 (setq gud-last-frame 1037 (setq gud-last-frame
1034 (cons (match-string 1 result) 1038 (cons (match-string 1 result)
1035 (string-to-int (match-string 2 result)))))) 1039 (string-to-number (match-string 2 result))))))
1036 result) 1040 result)
1037 ((string-match ; kluged-up marker as above 1041 ((string-match ; kluged-up marker as above
1038 "\032\032\\([0-9]*\\):\\(.*\\)\n" result) 1042 "\032\032\\([0-9]*\\):\\(.*\\)\n" result)
1039 (let ((file (gud-file-name (match-string 2 result)))) 1043 (let ((file (gud-file-name (match-string 2 result))))
1040 (if (and file (file-exists-p file)) 1044 (if (and file (file-exists-p file))
1041 (setq gud-last-frame 1045 (setq gud-last-frame
1042 (cons file 1046 (cons file
1043 (string-to-int (match-string 1 result)))))) 1047 (string-to-number (match-string 1 result))))))
1044 (setq result (substring result 0 (match-beginning 0)))))) 1048 (setq result (substring result 0 (match-beginning 0))))))
1045 (or result ""))) 1049 (or result "")))
1046 1050
1047 (defvar gud-dgux-p (string-match "-dgux" system-configuration) 1051 (defvar gud-dgux-p (string-match "-dgux" system-configuration)
1048 "Non-nil means to assume the interface approriate for DG/UX dbx. 1052 "Non-nil means to assume the interface approriate for DG/UX dbx.
1075 start) 1079 start)
1076 ;; Process all complete markers in this chunk. 1080 ;; Process all complete markers in this chunk.
1077 (while (string-match re gud-marker-acc start) 1081 (while (string-match re gud-marker-acc start)
1078 (setq gud-last-frame 1082 (setq gud-last-frame
1079 (cons (match-string 4 gud-marker-acc) 1083 (cons (match-string 4 gud-marker-acc)
1080 (string-to-int (match-string 3 gud-marker-acc))) 1084 (string-to-number (match-string 3 gud-marker-acc)))
1081 start (match-end 0))) 1085 start (match-end 0)))
1082 1086
1083 ;; Search for the last incomplete line in this chunk 1087 ;; Search for the last incomplete line in this chunk
1084 (while (string-match "\n" gud-marker-acc start) 1088 (while (string-match "\n" gud-marker-acc start)
1085 (setq start (match-end 0))) 1089 (setq start (match-end 0)))
1194 (if result 1198 (if result
1195 (if (or (string-match "\\([^\n \t:]+\\): [^:]+: \\([0-9]+\\)[: ]" 1199 (if (or (string-match "\\([^\n \t:]+\\): [^:]+: \\([0-9]+\\)[: ]"
1196 result) 1200 result)
1197 (string-match "[^: \t]+:[ \t]+\\([^:]+\\): [^:]+: \\([0-9]+\\):" 1201 (string-match "[^: \t]+:[ \t]+\\([^:]+\\): [^:]+: \\([0-9]+\\):"
1198 result)) 1202 result))
1199 (let ((line (string-to-int (match-string 2 result))) 1203 (let ((line (string-to-number (match-string 2 result)))
1200 (file (gud-file-name (match-string 1 result)))) 1204 (file (gud-file-name (match-string 1 result))))
1201 (if file 1205 (if file
1202 (setq gud-last-frame (cons file line)))))) 1206 (setq gud-last-frame (cons file line))))))
1203 (or result ""))) 1207 (or result "")))
1204 1208
1296 (setq 1300 (setq
1297 1301
1298 ;; Extract the frame position from the marker. 1302 ;; Extract the frame position from the marker.
1299 gud-last-frame 1303 gud-last-frame
1300 (cons (match-string 1 gud-marker-acc) 1304 (cons (match-string 1 gud-marker-acc)
1301 (string-to-int (match-string 3 gud-marker-acc))) 1305 (string-to-number (match-string 3 gud-marker-acc)))
1302 1306
1303 ;; Append any text before the marker to the output we're going 1307 ;; Append any text before the marker to the output we're going
1304 ;; to return - we don't include the marker in this text. 1308 ;; to return - we don't include the marker in this text.
1305 output (concat output 1309 output (concat output
1306 (substring gud-marker-acc 0 (match-beginning 0))) 1310 (substring gud-marker-acc 0 (match-beginning 0)))
1394 1398
1395 ;; Extract the frame position from the marker. 1399 ;; Extract the frame position from the marker.
1396 gud-last-frame 1400 gud-last-frame
1397 (let ((file (match-string gud-pdb-marker-regexp-file-group 1401 (let ((file (match-string gud-pdb-marker-regexp-file-group
1398 gud-marker-acc)) 1402 gud-marker-acc))
1399 (line (string-to-int 1403 (line (string-to-number
1400 (match-string gud-pdb-marker-regexp-line-group 1404 (match-string gud-pdb-marker-regexp-line-group
1401 gud-marker-acc)))) 1405 gud-marker-acc))))
1402 (if (string-equal file "<string>") 1406 (if (string-equal file "<string>")
1403 gud-last-frame 1407 gud-last-frame
1404 (cons file line))) 1408 (cons file line)))
2026 ;; Return the info as a cons of the form: 2030 ;; Return the info as a cons of the form:
2027 ;; 2031 ;;
2028 ;; (<file-name> . <line-number>) . 2032 ;; (<file-name> . <line-number>) .
2029 (if (if (match-beginning 1) 2033 (if (if (match-beginning 1)
2030 (let (n) 2034 (let (n)
2031 (setq n (string-to-int (substring 2035 (setq n (string-to-number (substring
2032 gud-marker-acc 2036 gud-marker-acc
2033 (1+ (match-beginning 1)) 2037 (1+ (match-beginning 1))
2034 (- (match-end 1) 2)))) 2038 (- (match-end 1) 2))))
2035 (if (< n gud-jdb-lowest-stack-level) 2039 (if (< n gud-jdb-lowest-stack-level)
2036 (progn (setq gud-jdb-lowest-stack-level n) t))) 2040 (progn (setq gud-jdb-lowest-stack-level n) t)))
2037 t) 2041 t)
2038 (if (setq file-found 2042 (if (setq file-found
2039 (gud-jdb-find-source (match-string 2 gud-marker-acc))) 2043 (gud-jdb-find-source (match-string 2 gud-marker-acc)))
2040 (setq gud-last-frame 2044 (setq gud-last-frame
2041 (cons file-found 2045 (cons file-found
2042 (string-to-int 2046 (string-to-number
2043 (let 2047 (let
2044 ((numstr (match-string 4 gud-marker-acc))) 2048 ((numstr (match-string 4 gud-marker-acc)))
2045 (if (string-match "[.,]" numstr) 2049 (if (string-match "[.,]" numstr)
2046 (replace-match "" nil nil numstr) 2050 (replace-match "" nil nil numstr)
2047 numstr))))) 2051 numstr)))))
2185 (setq 2189 (setq
2186 2190
2187 ;; Extract the frame position from the marker. 2191 ;; Extract the frame position from the marker.
2188 gud-last-frame 2192 gud-last-frame
2189 (cons (match-string 2 gud-marker-acc) 2193 (cons (match-string 2 gud-marker-acc)
2190 (string-to-int (match-string 4 gud-marker-acc))) 2194 (string-to-number (match-string 4 gud-marker-acc)))
2191 2195
2192 ;; Append any text before the marker to the output we're going 2196 ;; Append any text before the marker to the output we're going
2193 ;; to return - we don't include the marker in this text. 2197 ;; to return - we don't include the marker in this text.
2194 output (concat output 2198 output (concat output
2195 (substring gud-marker-acc 0 (match-beginning 0))) 2199 (substring gud-marker-acc 0 (match-beginning 0)))
2975 (if class-found 2979 (if class-found
2976 (car class-found) 2980 (car class-found)
2977 (message "gud-find-class: class for file %s not found in gud-jdb-class-source-alist!" f) 2981 (message "gud-find-class: class for file %s not found in gud-jdb-class-source-alist!" f)
2978 nil)))) 2982 nil))))
2979 2983
2984
2980 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2985 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2981 ;;; GDB script mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2986 ;;; GDB script mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2982 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2987 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2983 2988
2984 (defvar gdb-script-mode-syntax-table 2989 (defvar gdb-script-mode-syntax-table