mirror of
https://github.com/pestctrl/emacs-config.git
synced 2026-02-16 08:14:15 +00:00
Some refactoring
This commit is contained in:
parent
e08f2460a5
commit
db66ca381a
1 changed files with 35 additions and 27 deletions
|
|
@ -25,6 +25,29 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'org)
|
(require 'org)
|
||||||
|
|
||||||
|
(defclass debugger-stacktrace-data ()
|
||||||
|
((file-name :initarg :file-name :type string)
|
||||||
|
(line-number :initarg :line-number :type number)
|
||||||
|
(func-name :initarg :func-name :type string)
|
||||||
|
(stack-number :initarg :stack-number :type number)))
|
||||||
|
|
||||||
|
(defun stacktrace-to-org-table (stacktrace)
|
||||||
|
(save-excursion
|
||||||
|
(beginning-of-buffer)
|
||||||
|
(insert "|-\n|#|Function Name|Link|\n|-\n")
|
||||||
|
(dolist (stack-entry stacktrace)
|
||||||
|
(insert (format "|%s|%s|%s|\n"
|
||||||
|
(slot-value stack-entry 'stack-number)
|
||||||
|
(slot-value stack-entry 'func-name)
|
||||||
|
(let ((fname (slot-value stack-entry 'file-name)))
|
||||||
|
(format "[[%s:%d][%s]]"
|
||||||
|
fname
|
||||||
|
(slot-value stack-entry 'line-number)
|
||||||
|
(file-name-nondirectory fname))))))
|
||||||
|
(insert "|-")
|
||||||
|
(org-table-align)
|
||||||
|
(org-table-sort-lines nil ?N)))
|
||||||
|
|
||||||
(defun gdb-stacktrace-to-org-table ()
|
(defun gdb-stacktrace-to-org-table ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((regexp (rx (and line-start
|
(let ((regexp (rx (and line-start
|
||||||
|
|
@ -52,35 +75,20 @@
|
||||||
(group
|
(group
|
||||||
(+ digit))
|
(+ digit))
|
||||||
line-end
|
line-end
|
||||||
))))
|
)))
|
||||||
(beginning-of-buffer)
|
stacktrace)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
(beginning-of-buffer)
|
||||||
(while (re-search-forward regexp nil 'noerror)
|
(while (re-search-forward regexp nil 'noerror)
|
||||||
(replace-match
|
(push
|
||||||
(let ((path (match-string 3)))
|
(make-instance 'debugger-stacktrace-data
|
||||||
(save-match-data
|
:stack-number (string-to-number (match-string 1))
|
||||||
(format "|\\1|\\2|%s:\\4|[[\\3::\\4][Link]]|"
|
:func-name (match-string 2)
|
||||||
(cond ((string-match (rx (and "/scratch/benson/_repos-work/tools"
|
:file-name (match-string 3)
|
||||||
(* digit)
|
:line-number (string-to-number (match-string 4)))
|
||||||
"/llvm_cgt/llvm-project/"
|
stacktrace))
|
||||||
(group
|
(erase-buffer))
|
||||||
(+ nonl))))
|
(stacktrace-to-org-table stacktrace)))
|
||||||
path)
|
|
||||||
(format "$LLVM_PROJECT/%s" (match-string 1 path)))
|
|
||||||
((string-match (rx (and "/scratch/benson/_repos-work/tools"
|
|
||||||
(* digit)
|
|
||||||
"/"
|
|
||||||
(group
|
|
||||||
(+ nonl))))
|
|
||||||
path)
|
|
||||||
(format "$SANDBOX/%s" (match-string 1 path)))
|
|
||||||
(t path))))))))
|
|
||||||
(org-table-sort-lines nil ?N)
|
|
||||||
(save-excursion
|
|
||||||
(insert "|-\n|#|Function Name|File & Line Number|Link|\n|-\n")
|
|
||||||
(end-of-buffer)
|
|
||||||
(insert "\n|-"))
|
|
||||||
(org-table-align)))
|
|
||||||
|
|
||||||
(defun lldb-filename-to-org-link (filename)
|
(defun lldb-filename-to-org-link (filename)
|
||||||
(setq filename
|
(setq filename
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue