I use the package highline.el that contains the functions highline-highlight-current-line and highline-unhighlight-current-line, allowing light or unlight the current line in a easy way:
This function open file file into gdb-source-window (window where gud show the current line) move to line line and light or unlight the line based in light. So I only need put my code into the hook calling this function:
(defun my-gdb-highline-file-line (file line light) (with-selected-window gdb-source-window (find-file file) (goto-char (point-min)) (forward-line (1- line)) (setq my-gdb-line line) (setq my-gdb-file file) (if light (highline-highlight-current-line) (highline-unhighlight-current-line))))
This hook is called with a parsed MI response, where we can get the actual file and line using bindat-get-field. After this we only need unlight the line when gud is stopped:
(add-hook 'gdb-stopped-hooks '(lambda (arg) (let* ((frame (cdr (nth 2 arg))) (line (bindat-get-field frame 'line)) (file (bindat-get-field frame 'fullname))) (when (and (stringp line) (stringp file)) (when (and my-gdb-file my-gdb-line) (my-gdb-highline-file-line my-gdb-file my-gdb-line nil)) (my-gdb-highline-file-line file (string-to-number line) t)))))
And now we have our missed featued ready to test it!
(defadvice gdb-reset (after my-gdb-reset activate) (my-gdb-highline-file-line my-gdb-file my-gdb-line nil))