universal-ctags / citre

A superior code reading & auto-completion tool with pluggable backends.
GNU General Public License v3.0
320 stars 26 forks source link

"Args out of range" for tags in the Linux Kernel #167

Closed nafiz1001 closed 3 months ago

nafiz1001 commented 5 months ago

Emacs version: GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.18.0, Xaw3d scroll bars)

Reproduction:

(use-package citre :ensure t :config (require 'citre-config))


- clone linux kernel source at commit b555d191561a7f89b8d2108dff687d9bc4284e48 (or master branch)
- run `make tags` in the kernel
- open a c file (e.g. `drivers/firmware/efi/libstub/x86-stub.c`)
- turn on `citre-mode`
- `citre-jump` on `efi_stub_entry` at line 959

I get the error: `Args out of range: "efi_stub_entry    drivers/firmware/efi/libstub/x86-stub.c /^void __noreturn efi_stub_entry(efi_handle_t handle/", 55, 110`

The error seems to happen everywhere :\
masatake commented 4 months ago

I'm using Emacs 29.2. I cannot reproduce this.

I would like to see the backtrace of the error:

Could you do citre-jump after doing M-x toggle-debug-error ?

nafiz1001 commented 4 months ago

My OS info for context

[nafiz@nixos:~]$ uname -ar
Linux nixos 6.1.75 #1-NixOS SMP PREEMPT_DYNAMIC Thu Jan 25 23:27:52 UTC 2024 x86_64 GNU/Linux

After executing toggle-debug-error and citre-jump

Debugger entered--Lisp error: (args-out-of-range "efi_stub_entry\11drivers/firmware/efi/libstub/x86-st..." 55 110)
  citre-readtags--lexer-forward-field-value("efi_stub_entry\11drivers/firmware/efi/libstub/x86-st..." 108 [55 2] t)
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_4>("efi_stub_entry\11drivers/firmware/efi/libstub/x86-st..." #<hash-table eq 2/16 0xbeeb85> [55 2] 108 pattern)
  citre-readtags--parse-line("efi_stub_entry\11drivers/firmware/efi/libstub/x86-st..." #<hash-table eq 5/65 0xae7fd7> (name pattern) (line typeref scope extras) nil (ext-abspath) (ext-kind-full) (kind language input) nil)
  #f(compiled-function (line) #<bytecode -0x1dd6e33e10ee67f6>)("efi_stub_entry\11drivers/firmware/efi/libstub/x86-st...")
  citre-readtags--get-tags("/home/nafiz/projects/linux/tags" #("efi_stub_entry" 0 14 (citre-tags-file "/home/nafiz/projects/linux/tags" citre-file-path "/home/nafiz/projects/linux/drivers/firmware/efi/li..." citre-syntax function citre-bounds (25181 . 25195))) exact nil :filter (not (or (and (not (or (and $input (eq? $input "/home/nafiz/projects/linux/drivers/firmware/efi/li...")) (and $input (eq? $input "drivers/firmware/efi/libstub/x86-stub.c")) (and $input (... $input)))) (or $file (and $extras ((string->regexp "(^|,) ?(fileScope)(,|$)" :case-fold false) $extras)))))) :sorter (<or> (<or> (<> (if (and $extras ((string->regexp "(^|,) ?(reference)(,|$)" :case-fold false) $extras)) 1 -1) (if (and &extras ((string->regexp "(^|,) ?(reference)(,|$)" :case-fold false) &extras)) 1 -1))) (<or> (<> (if (or (and $kind (... $kind)) (and $kind (... $kind))) -1 1) (if (or (and &kind (... &kind)) (and &kind (... &kind))) -1 1))) (<or> (if (and $input &input) (<> $input &input) 0) (if (and $name &name) (<> (length $name) (length &name)) 0) (if (and $name &name) (<> $name &name) 0) (if (and $line $end &line &end) (<> (- &end &line) (- $end $line)) 0))) :require (name ext-abspath pattern) :optional (ext-kind-full line typeref scope extras) :exclude nil :parse-all-fields nil)
  citre-readtags-get-tags("/home/nafiz/projects/linux/tags" #("efi_stub_entry" 0 14 (citre-tags-file "/home/nafiz/projects/linux/tags" citre-file-path "/home/nafiz/projects/linux/drivers/firmware/efi/li..." citre-syntax function citre-bounds (25181 . 25195))) exact nil :filter (not (or (and (not (or (and $input (eq? $input "/home/nafiz/projects/linux/drivers/firmware/efi/li...")) (and $input (eq? $input "drivers/firmware/efi/libstub/x86-stub.c")) (and $input (... $input)))) (or $file (and $extras ((string->regexp "(^|,) ?(fileScope)(,|$)" :case-fold false) $extras)))))) :sorter (<or> (<or> (<> (if (and $extras ((string->regexp "(^|,) ?(reference)(,|$)" :case-fold false) $extras)) 1 -1) (if (and &extras ((string->regexp "(^|,) ?(reference)(,|$)" :case-fold false) &extras)) 1 -1))) (<or> (<> (if (or (and $kind (... $kind)) (and $kind (... $kind))) -1 1) (if (or (and &kind (... &kind)) (and &kind (... &kind))) -1 1))) (<or> (if (and $input &input) (<> $input &input) 0) (if (and $name &name) (<> (length $name) (length &name)) 0) (if (and $name &name) (<> $name &name) 0) (if (and $line $end &line &end) (<> (- &end &line) (- $end $line)) 0))) :require (name ext-abspath pattern) :optional (ext-kind-full line typeref scope extras) :exclude nil :parse-all-fields nil)
  citre-tags-get-tags("/home/nafiz/projects/linux/tags" #("efi_stub_entry" 0 14 (citre-tags-file "/home/nafiz/projects/linux/tags" citre-file-path "/home/nafiz/projects/linux/drivers/firmware/efi/li..." citre-syntax function citre-bounds (25181 . 25195))) exact :filter (not (or (and (not (or (and $input (eq? $input "/home/nafiz/projects/linux/drivers/firmware/efi/li...")) (and $input (eq? $input "drivers/firmware/efi/libstub/x86-stub.c")) (and $input (... $input)))) (or $file (and $extras ((string->regexp "(^|,) ?(fileScope)(,|$)" :case-fold false) $extras)))))) :sorter (<or> (<or> (<> (if (and $extras ((string->regexp "(^|,) ?(reference)(,|$)" :case-fold false) $extras)) 1 -1) (if (and &extras ((string->regexp "(^|,) ?(reference)(,|$)" :case-fold false) &extras)) 1 -1))) (<or> (<> (if (or (and $kind (... $kind)) (and $kind (... $kind))) -1 1) (if (or (and &kind (... &kind)) (and &kind (... &kind))) -1 1))) (<or> (if (and $input &input) (<> $input &input) 0) (if (and $name &name) (<> (length $name) (length &name)) 0) (if (and $name &name) (<> $name &name) 0) (if (and $line $end &line &end) (<> (- &end &line) (- $end $line)) 0))) :require (name ext-abspath pattern) :optional (ext-kind-full line typeref scope extras))
  citre-tags-get-definitions(#("efi_stub_entry" 0 14 (citre-tags-file "/home/nafiz/projects/linux/tags" citre-file-path "/home/nafiz/projects/linux/drivers/firmware/efi/li..." citre-syntax function citre-bounds (25181 . 25195))) "/home/nafiz/projects/linux/tags")
  citre-tags-get-definitions-at-point()
  apply(citre-tags-get-definitions-at-point nil)
  citre--try-func-in-backend-list(get-definitions-func #<hash-table eq 2/5 0xb78de5> (tags global))
  citre-get-backend-and-definitions()
  citre-get-definitions()
  citre-jump()
  funcall-interactively(citre-jump)
  command-execute(citre-jump record)
  execute-extended-command(nil "citre-jump" nil)
  funcall-interactively(execute-extended-command nil "citre-jump" nil)
  command-execute(execute-extended-command)
masatake commented 4 months ago

Sorry to be late.

  citre-readtags--lexer-forward-field-value("efi_stub_entry\11drivers/firmware/efi/libstub/x86-st..." 108 [55 2] t)

108 looks too small.

Could you run the following commands?

$ readtags --version
$ readtags -t /home/nafiz/projects/linux/tags -Ene - efi_stub_entry

I would like to see the output.

nafiz1001 commented 4 months ago

Np.

readtags:

[nafiz@nixos:~/Documents/linux]$ readtags --version
6.0.0

[nafiz@nixos:~/Documents/linux]$ readtags -t /home/nafiz/Documents/linux/tags -Ene - efi_stub_entry
efi_stub_entry  drivers/firmware/efi/libstub/x86-stub.c /^void __noreturn efi_stub_entry(efi_handle_t handle/

[nafiz@nixos:~/Documents/linux]$ 

Emacs:

GNU Emacs 29.2 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version
1.18.0, Xaw3d scroll bars)

Citre:

citre                          20240203.457   installed             Ctags IDE on the True Editor

Linux repo version

~/Documents/linux $ git rev-parse HEAD
5e74df2f8f15eaa1ebbdfc1f6fef27a26d789de8

I generated the tags using make tags (before I installed universal-ctags)

Error:

Debugger entered--Lisp error: (args-out-of-range "efi_stub_entry\11drivers/firmware/efi/libstub/x86-stub.c\11/^void __noreturn efi_stub_entry(efi_handle_t handle/" 55 110)
  citre-readtags--lexer-forward-field-value("efi_stub_entry\11drivers/firmware/efi/libstub/x86-stub.c\11/^void __noreturn efi_stub_entry(efi_handle_t handle/" 108 [55 2] t)
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_4>("efi_stub_entry\11drivers/firmware/efi/libstub/x86-stub.c\11/^void __noreturn efi_stub_entry(efi_handle_t handle/" #<hash-table eq 2/16 0x113998f> [55 2] 108 pattern)
  citre-readtags--parse-line("efi_stub_entry\11drivers/firmware/efi/libstub/x86-stub.c\11/^void __noreturn efi_stub_entry(efi_handle_t handle/" #<hash-table eq 5/65 0x1026971> (name pattern) (line typeref scope extras) nil (ext-abspath) (ext-kind-full) (kind language input) nil)
  #f(compiled-function (line) #<bytecode 0x1322e98a9c5e7b0a>)("efi_stub_entry\11drivers/firmware/efi/libstub/x86-stub.c\11/^void __noreturn efi_stub_entry(efi_handle_t handle/")
  citre-readtags--get-tags("/home/nafiz/Documents/linux/tags" #("efi_stub_entry" 0 14 (citre-tags-file "/home/nafiz/Documents/linux/tags" citre-file-path "/home/nafiz/Documents/linux/drivers/firmware/efi/libstub/x86-stub.c" citre-syntax function citre-bounds (13148 . 13162))) exact nil :filter (not (or (and (not (or (and $input (eq? $input "/home/nafiz/Documents/linux/drivers/firmware/efi/libstub/x86-stub.c")) (and $input (eq? $input "drivers/firmware/efi/libstub/x86-stub.c")) (and $input ((string->regexp "(^|/)..?/x86-stub\\.c$" :case-fold false) $input)))) (or $file (and $extras ((string->regexp "(^|,) ?(fileScope)(,|$)" :case-fold false) $extras)))))) :sorter (<or> (<or> (<> (if (and $extras ((string->regexp "(^|,) ?(reference)(,|$)" :case-fold false) $extras)) 1 -1) (if (and &extras ((string->regexp "(^|,) ?(reference)(,|$)" :case-fold false) &extras)) 1 -1))) (<or> (<> (if (or (and $kind ((string->regexp "^(function|f)$" :case-fold false) $kind)) (and $kind ((string->regexp "^(macro|d)$" :case-fold false) $kind))) -1 1) (if (or (and &kind ((string->regexp "^(function|f)$" :case-fold false) &kind)) (and &kind ((string->regexp "^(macro|d)$" :case-fold false) &kind))) -1 1))) (<or> (if (and $input &input) (<> $input &input) 0) (if (and $name &name) (<> (length $name) (length &name)) 0) (if (and $name &name) (<> $name &name) 0) (if (and $line $end &line &end) (<> (- &end &line) (- $end $line)) 0))) :require (name ext-abspath pattern) :optional (ext-kind-full line typeref scope extras) :exclude nil :parse-all-fields nil)
  citre-readtags-get-tags("/home/nafiz/Documents/linux/tags" #("efi_stub_entry" 0 14 (citre-tags-file "/home/nafiz/Documents/linux/tags" citre-file-path "/home/nafiz/Documents/linux/drivers/firmware/efi/libstub/x86-stub.c" citre-syntax function citre-bounds (13148 . 13162))) exact nil :filter (not (or (and (not (or (and $input (eq? $input "/home/nafiz/Documents/linux/drivers/firmware/efi/libstub/x86-stub.c")) (and $input (eq? $input "drivers/firmware/efi/libstub/x86-stub.c")) (and $input ((string->regexp "(^|/)..?/x86-stub\\.c$" :case-fold false) $input)))) (or $file (and $extras ((string->regexp "(^|,) ?(fileScope)(,|$)" :case-fold false) $extras)))))) :sorter (<or> (<or> (<> (if (and $extras ((string->regexp "(^|,) ?(reference)(,|$)" :case-fold false) $extras)) 1 -1) (if (and &extras ((string->regexp "(^|,) ?(reference)(,|$)" :case-fold false) &extras)) 1 -1))) (<or> (<> (if (or (and $kind ((string->regexp "^(function|f)$" :case-fold false) $kind)) (and $kind ((string->regexp "^(macro|d)$" :case-fold false) $kind))) -1 1) (if (or (and &kind ((string->regexp "^(function|f)$" :case-fold false) &kind)) (and &kind ((string->regexp "^(macro|d)$" :case-fold false) &kind))) -1 1))) (<or> (if (and $input &input) (<> $input &input) 0) (if (and $name &name) (<> (length $name) (length &name)) 0) (if (and $name &name) (<> $name &name) 0) (if (and $line $end &line &end) (<> (- &end &line) (- $end $line)) 0))) :require (name ext-abspath pattern) :optional (ext-kind-full line typeref scope extras) :exclude nil :parse-all-fields nil)
  citre-tags-get-tags("/home/nafiz/Documents/linux/tags" #("efi_stub_entry" 0 14 (citre-tags-file "/home/nafiz/Documents/linux/tags" citre-file-path "/home/nafiz/Documents/linux/drivers/firmware/efi/libstub/x86-stub.c" citre-syntax function citre-bounds (13148 . 13162))) exact :filter (not (or (and (not (or (and $input (eq? $input "/home/nafiz/Documents/linux/drivers/firmware/efi/libstub/x86-stub.c")) (and $input (eq? $input "drivers/firmware/efi/libstub/x86-stub.c")) (and $input ((string->regexp "(^|/)..?/x86-stub\\.c$" :case-fold false) $input)))) (or $file (and $extras ((string->regexp "(^|,) ?(fileScope)(,|$)" :case-fold false) $extras)))))) :sorter (<or> (<or> (<> (if (and $extras ((string->regexp "(^|,) ?(reference)(,|$)" :case-fold false) $extras)) 1 -1) (if (and &extras ((string->regexp "(^|,) ?(reference)(,|$)" :case-fold false) &extras)) 1 -1))) (<or> (<> (if (or (and $kind ((string->regexp "^(function|f)$" :case-fold false) $kind)) (and $kind ((string->regexp "^(macro|d)$" :case-fold false) $kind))) -1 1) (if (or (and &kind ((string->regexp "^(function|f)$" :case-fold false) &kind)) (and &kind ((string->regexp "^(macro|d)$" :case-fold false) &kind))) -1 1))) (<or> (if (and $input &input) (<> $input &input) 0) (if (and $name &name) (<> (length $name) (length &name)) 0) (if (and $name &name) (<> $name &name) 0) (if (and $line $end &line &end) (<> (- &end &line) (- $end $line)) 0))) :require (name ext-abspath pattern) :optional (ext-kind-full line typeref scope extras))
  citre-tags-get-definitions(#("efi_stub_entry" 0 14 (citre-tags-file "/home/nafiz/Documents/linux/tags" citre-file-path "/home/nafiz/Documents/linux/drivers/firmware/efi/libstub/x86-stub.c" citre-syntax function citre-bounds (13148 . 13162))) "/home/nafiz/Documents/linux/tags")
  citre-tags-get-definitions-at-point()
  apply(citre-tags-get-definitions-at-point nil)
  citre--try-func-in-backend-list(get-definitions-func #<hash-table eq 2/5 0xf300b1> (tags global))
  citre-get-backend-and-definitions()
  citre-get-definitions()
  citre-jump()
  funcall-interactively(citre-jump)
  command-execute(citre-jump record)
  execute-extended-command(nil "citre-jump" "citre-j")
  funcall-interactively(execute-extended-command nil "citre-jump" "citre-j")
  command-execute(execute-extended-command)
masatake commented 4 months ago

Thank you. I found this was not an issue of Citre. It is an issue of ctags, readtags, or "make tags".

[nafiz@nixos:~/Documents/linux]$ readtags -t /home/nafiz/Documents/linux/tags -Ene - efi_stub_entry
efi_stub_entry  drivers/firmware/efi/libstub/x86-stub.c /^void __noreturn efi_stub_entry(efi_handle_t handle/

This output is too short. The output is truncated, or the tags file is broken.

What I got is:

readtags -t /home/yamato/var/linux/tags -Ene - efi_stub_entry
efi_stub_entry  drivers/firmware/efi/libstub/x86-stub.c /^void __noreturn efi_stub_entry(efi_handle_t handle,$/;"   kind:f  typeref:typename:void __noreturn    signature:(efi_handle_t handle,efi_system_table_t * sys_table_arg,struct boot_params * boot_params)
efi_stub_entry  drivers/firmware/efi/libstub/x86-stub.c /^void __noreturn efi_stub_entry(efi_handle_t handle,$/;"   kind:p  file:   typeref:typename:void __noreturn    signature:(efi_handle_t handle,efi_system_table_t * sys_table_arg,struct boot_params * boot_params)

What I would like to see next is:

$ grep  '^efi_stub_entry\>' /home/nafiz/Documents/linux/tags

If the output is also too short, this is an issue of ctags or "make tags". If the output is not too short, this is an issue of readtags command.

nafiz1001 commented 4 months ago

Turns out installing universal-ctags before running make tags fixed my problem... Sorry for the time wasted 😅

masatake commented 3 months ago

That's fine. I will close this.