@@ -740,6 +740,44 @@ to the length of `bdx-disassembly-stack'."
740740 :lighter " bdx"
741741 :keymap bdx-disassembly-mode-map)
742742
743+
744+ ; ; Find definition
745+
746+ (defun bdx-find-definition (symbol-plist )
747+ " Find file containing definition of SYMBOL-PLIST and go to definition line.
748+ The return value is a cons (FILE . LINE)."
749+ (interactive (list (bdx-query " Find definition: "
750+ :require-match t )))
751+ (pcase-let (((map :name :demangled :path :section ) symbol-plist))
752+ (let ((command
753+ (apply #'bdx--command " find-definition"
754+ (append (list " -n" " 1" )
755+ (list
756+ (and name (format " fullname:\" %s \" " name))
757+ (and demangled
758+ (format " demangled:\" %s \" " demangled))
759+ (and path (format " path:\" %s \" " path))
760+ (and section
761+ (format " section:\" %s \" " section))))))
762+ file line sym)
763+ (with-temp-buffer
764+ (apply #'call-process (car command)
765+ nil (current-buffer ) nil (cdr command))
766+
767+ (goto-char (point-min ))
768+ (if (looking-at " ^\\ (.*\\ ):\\ ([0-9]+\\ ): \\ (.*\\ )" )
769+ (setq file (match-string 1 )
770+ line (string-to-number (match-string 2 ))
771+ sym (match-string 3 ))
772+ (error " No definition found " )))
773+ (when (equal sym name)
774+ (with-current-buffer (find-file-noselect file)
775+ (goto-char (point-min ))
776+ (forward-line (1- line))
777+ (pop-to-buffer (current-buffer ))
778+ (pulse-momentary-highlight-one-line )
779+ (cons file line))))))
780+
743781
744782; ; Graphs
745783
0 commit comments