Re: client on freebsd over tramp server on archlinux

andrés ramírez <[email protected]> Tue, 20 Oct 2020 21:12:52 +0000
Newsgroups gmane.comp.gnu.global.bugs
Organization bien.comun.org
Message-ID <[email protected]>
I have been trying to get more details about the issue:

I have testing with this source code:
--8<---------------cut here---------------start------------->8---
// cc -o borrame.bin borrame.c
#include <stdio.h>

static void myfunct() {
  printf("test") ;
}

int main(int argc, char *argv[]) {

  myfunct();
}
--8<---------------cut here---------------end--------------->8---

On Arch this is the global --version output:
--8<---------------cut here---------------start------------->8---
global (GNU GLOBAL) 6.6.5
Powered by Berkeley DB 1.85 and SQLite3 3.8.7.1.
Copyright (c) 1996-2019 Tama Communications Corporation
License GPLv3+: GNU GPL version 3 or later <http://www.gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
--8<---------------cut here---------------end--------------->8---

On FreeBSD this is the global --version output:
--8<---------------cut here---------------start------------->8---
global (GNU GLOBAL) 6.6.5
Powered by Berkeley DB 1.85.
Copyright (c) 1996-2019 Tama Communications Corporation
License GPLv3+: GNU GPL version 3 or later <http://www.gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
--8<---------------cut here---------------end--------------->8---

On Arch and on FreeBSD if I try it locally on both boxes it "Works".

This is the file listing of  Arch:
--8<---------------cut here---------------start------------->8---
  /tmp/borrame:
  total used in directory 52 available 987 MiB
  drwxr-xr-x  2 olla users   120 Oct 20 18:46 .
  drwxrwxrwt 14 root root    580 Oct 20 20:47 ..
  -rw-r--r--  1 olla users 16384 Oct 20 18:46 GPATH
  -rw-r--r--  1 olla users 16384 Oct 20 18:46 GRTAGS
  -rw-r--r--  1 olla users 16384 Oct 20 18:46 GTAGS
  -rw-r--r--  1 olla users   148 Oct 20 18:03 borrame.c
--8<---------------cut here---------------end--------------->8---

This is the file listing on FreeBSD:
--8<---------------cut here---------------start------------->8---
  /tmp/borrame:
  total used in directory 52 available 987 MiB
  drwxr-xr-x  2 olla users   120 Oct 20 18:46 .
  drwxrwxrwt 14 root root    580 Oct 20 20:47 ..
  -rw-r--r--  1 olla users 16384 Oct 20 18:46 GPATH
  -rw-r--r--  1 olla users 16384 Oct 20 18:46 GRTAGS
  -rw-r--r--  1 olla users 16384 Oct 20 18:46 GTAGS
  -rw-r--r--  1 olla users   148 Oct 20 18:03 borrame.c
--8<---------------cut here---------------end--------------->8---

If I try global over tramp on both of them {ie emacs runninng on Arch
and being the target FreeBSD}. It fails with:
--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (args-out-of-range #<buffer *GTAGS SELECT* (D)myfunct> 0 1)
  buffer-substring(1 0)
  (message (buffer-substring (point-min) (1- (point-max))))
  (progn (message (buffer-substring (point-min) (1- (point-max)))) (gtags-pop-context))
  (if (not (= 0 status)) (progn (message (buffer-substring (point-min) (1- (point-max)))) (gtags-pop-context)) (goto-char (point-min)) (setq lines (count-lines (point-min) (point-max))) (cond ((= 0 lines) (cond ((char-equal flag-char 80) (message "%s: path not found" tagname)) ((char-equal flag-char 103) (message "%s: pattern not found" tagname)) ((char-equal flag-char 73) (message "%s: token not found" tagname)) ((char-equal flag-char 115) (message "%s: symbol not found" tagname)) (t (message "%s: tag not found" tagname))) (gtags-pop-context) (kill-buffer buffer) (set-buffer save)) ((= 1 lines) (message "Searching %s ... Done" tagname) (gtags-select-it t other-win)) (t (if (null other-win) (switch-to-buffer buffer) (switch-to-buffer-other-window buffer)) (gtags-select-mode))))
  (let (status) (gtags-push-tramp-environment) (cond ((equal gtags-path-style 'absolute) (setq option (concat option "a"))) ((and (not gtags-tramp-active) (equal gtags-path-style 'root)) (let (rootdir) (if gtags-rootdir (setq rootdir gtags-rootdir) (setq rootdir (gtags-get-rootpath))) (if rootdir (cd rootdir))))) (setq status (if (equal flag "C") (call-process gtags-global-command nil t nil option "--encode-path=\" \11\"" context tagname) (call-process gtags-global-command nil t nil option "--encode-path=\" \11\"" tagname))) (gtags-pop-tramp-environment) (if (not (= 0 status)) (progn (message (buffer-substring (point-min) (1- (point-max)))) (gtags-pop-context)) (goto-char (point-min)) (setq lines (count-lines (point-min) (point-max))) (cond ((= 0 lines) (cond ((char-equal flag-char 80) (message "%s: path not found" tagname)) ((char-equal flag-char 103) (message "%s: pattern not found" tagname)) ((char-equal flag-char 73) (message "%s: token not found" tagname)) ((char-equal flag-char 115) (message "%s: symbol not found" tagname)) (t (message "%s: tag not found" tagname))) (gtags-pop-context) (kill-buffer buffer) (set-buffer save)) ((= 1 lines) (message "Searching %s ... Done" tagname) (gtags-select-it t other-win)) (t (if (null other-win) (switch-to-buffer buffer) (switch-to-buffer-other-window buffer)) (gtags-select-mode)))))
  (let (option context save prefix buffer lines flag-char) (setq save (current-buffer)) (setq flag-char (string-to-char flag)) (if (equal flag-char nil) (setq flag-char (string-to-char " "))) (setq option "-x") (if (gtags-ignore-casep) (setq option (concat option "i"))) (if (char-equal flag-char 67) (setq context (concat "--from-here=" (number-to-string (gtags-current-lineno)) ":" (replace-in-string (gtags-buffer-file-name) "\\\\" "/"))) (setq option (concat option flag))) (cond ((char-equal flag-char 67) (setq prefix "(CONTEXT)")) ((char-equal flag-char 80) (setq prefix "(P)")) ((char-equal flag-char 102) (setq prefix "(F)")) ((char-equal flag-char 103) (setq prefix "(GREP)")) ((char-equal flag-char 73) (setq prefix "(IDUTILS)")) ((char-equal flag-char 115) (setq prefix "(S)")) ((char-equal flag-char 114) (setq prefix "(R)")) (t (setq prefix "(D)"))) (if gtags-select-buffer-single (progn (let (now-gtags-buffer-stack now-buffer now-gtags-point-stack now-point) (setq now-gtags-buffer-stack (reverse gtags-buffer-stack)) (setq now-gtags-point-stack (reverse gtags-point-stack)) (setq gtags-buffer-stack nil) (setq gtags-point-stack nil) (while now-gtags-buffer-stack (setq now-buffer (car now-gtags-buffer-stack)) (setq now-point (car now-gtags-point-stack)) (if (and (buffer-name now-buffer) (not ...)) (progn (setq gtags-buffer-stack ...) (setq gtags-point-stack ...))) (setq now-gtags-buffer-stack (cdr now-gtags-buffer-stack)) (setq now-gtags-point-stack (cdr now-gtags-point-stack)))) (let (now-buffer-list now-buffer) (setq now-buffer-list (buffer-list)) (while now-buffer-list (setq now-buffer (car now-buffer-list)) (if (string-match "*GTAGS SELECT*" (buffer-name now-buffer)) (kill-buffer now-buffer)) (setq now-buffer-list (cdr now-buffer-list)))))) (setq buffer (generate-new-buffer (generate-new-buffer-name (concat "*GTAGS SELECT* " prefix tagname)))) (set-buffer buffer) (message "Searching %s ..." tagname) (let (status) (gtags-push-tramp-environment) (cond ((equal gtags-path-style 'absolute) (setq option (concat option "a"))) ((and (not gtags-tramp-active) (equal gtags-path-style 'root)) (let (rootdir) (if gtags-rootdir (setq rootdir gtags-rootdir) (setq rootdir (gtags-get-rootpath))) (if rootdir (cd rootdir))))) (setq status (if (equal flag "C") (call-process gtags-global-command nil t nil option "--encode-path=\" \11\"" context tagname) (call-process gtags-global-command nil t nil option "--encode-path=\" \11\"" tagname))) (gtags-pop-tramp-environment) (if (not (= 0 status)) (progn (message (buffer-substring (point-min) (1- (point-max)))) (gtags-pop-context)) (goto-char (point-min)) (setq lines (count-lines (point-min) (point-max))) (cond ((= 0 lines) (cond ((char-equal flag-char 80) (message "%s: path not found" tagname)) ((char-equal flag-char 103) (message "%s: pattern not found" tagname)) ((char-equal flag-char 73) (message "%s: token not found" tagname)) ((char-equal flag-char 115) (message "%s: symbol not found" tagname)) (t (message "%s: tag not found" tagname))) (gtags-pop-context) (kill-buffer buffer) (set-buffer save)) ((= 1 lines) (message "Searching %s ... Done" tagname) (gtags-select-it t other-win)) (t (if (null other-win) (switch-to-buffer buffer) (switch-to-buffer-other-window buffer)) (gtags-select-mode))))))
  gtags-goto-tag(#("myfunct" 0 7 (fontified t)) "")
  (let (tagname prompt input) (setq tagname (gtags-current-token)) (gtags-push-context) (gtags-goto-tag tagname ""))
  (if askp (call-interactively #'gtags-find-tag) (let (tagname prompt input) (setq tagname (gtags-current-token)) (gtags-push-context) (gtags-goto-tag tagname "")))
  sunshavi/find-tag(nil)
  funcall-interactively(sunshavi/find-tag nil)
  call-interactively(sunshavi/find-tag nil nil)
  command-execute(sunshavi/find-tag)
--8<---------------cut here---------------end--------------->8---

I have also edebug-defun gtags-goto-tag. This is the output:
--8<---------------cut here---------------start------------->8---
Result: ("GTAGSREMOTECWD=/tmp/borrame/" "GTAGSREMOTEUSER=freebsd" "GTAGSREMOTEHOST=192.168.4.114" "GTAGSREMOTESHELL=ssh" "_=/usr/bin/emacs" "MAIL=/var/spool/mail/olla" "DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-h..." "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/..." "LC_COLLATE=C" "XDG_RUNTIME_DIR=/run/user/1001" "MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins" "XDG_SESSION_ID=1" "XDG_VTNR=1" "SHLVL=3" "VISUAL=emacsclient -c -a emacs" "WTK_HOME=/home/olla/downloads/opt_clone/WTK2.5.2" "USER=olla" "TERM=dumb" "XDG_SESSION_CLASS=user" "MAKEFLAGS=-j4" "XTERM_LOCALE=en_US.UTF-8" "LANG=en_US.UTF-8" "HOME=/home/olla" "MOTD_SHOWN=pam" "WINDOWPATH=1" "GNUSTEP_USER_ROOT=/home/olla/GNUstep" "XAUTHORITY=/home/olla/.Xauthority" "XDG_SESSION_TYPE=tty" "LOGNAME=olla" "PWD=/home/olla" "XDG_SEAT=seat0" "EDITOR=emacs" "DISTCC_HOSTS=localhost/4 192.168.4.113/4" "XTERM_SHELL=/bin/bash" "JAVA_HOME=/usr/lib/jvm/default" "XTERM_VERSION=XTerm(361)" "GNOME_DESKTOP_SESSION_ID=dear" "WINDOWID=12582942" "SHELL=/bin/bash")

Result: root

Result: nil

Result: t

Result: nil

Result: nil

Result: nil

Result: ""

Result: nil

Result: "global-client"

Result: "-xi"

Result: #("myfunct" 0 7 (fontified t))

Result: 255 (#o377, #xff)

Result: 255 (#o377, #xff)

Result: 255 (#o377, #xff)

Result: "GTAGSREMOTESHELL=ssh"

Result: 255 (#o377, #xff)
Go-Nonstop...
Args out of range: #<buffer *GTAGS SELECT* (D)myfunct>, 0, 1
--8<---------------cut here---------------end--------------->8---

How Could I try from cli the equivalent to this line? {global-client}:
--8<---------------cut here---------------start------------->8---
(call-process gtags-global-command nil t nil option "--encode-path=\"
\t\"" tagname)
--8<---------------cut here---------------end--------------->8---


Could the error be caused by a version mismatch?. How could I discard It. 

Any tips or ideas on how to nail this issue?

Best Regards