@@ -219,3 +219,52 @@ You can list all known standard descriptor names using::
219219You can print the offset of the descriptors inside the image using::
220220
221221 west bindesc get_offset
222+
223+ Indexing the sources with GNU Global: ``west gtags ``
224+ ****************************************************
225+
226+ .. important :: You must install the ``gtags`` and ``global`` programs provided
227+ by `GNU Global `_ to use this command.
228+
229+ The ``west gtags `` command lets you create a GNU Global tags file for the entire
230+ west workspace::
231+
232+ west gtags
233+
234+ .. _GNU Global : https://www.gnu.org/software/global/
235+
236+ This will create a tags file named ``GTAGS `` in the workspace :ref: `topdir
237+ <west-workspace>` (it will also create other Global-related metadata files
238+ named ``GPATH `` and ``GRTAGS `` in the same place).
239+
240+ You can then run the ``global `` command anywhere inside the
241+ workspace to search for symbol locations using this tags file.
242+
243+ For example, to search for definitions of the ``arch_system_halt() `` function,
244+ starting from the ``zephyr/drivers `` directory::
245+
246+ $ cd zephyr/drivers
247+ $ global -x arch_system_halt
248+ arch_system_halt 65 ../arch/arc/core/fatal.c FUNC_NORETURN void arch_system_halt(unsigned int reason)
249+ arch_system_halt 455 ../arch/arm64/core/fatal.c FUNC_NORETURN void arch_system_halt(unsigned int reason)
250+ arch_system_halt 137 ../arch/nios2/core/fatal.c FUNC_NORETURN void arch_system_halt(unsigned int reason)
251+ arch_system_halt 18 ../arch/posix/core/fatal.c FUNC_NORETURN void arch_system_halt(unsigned int reason)
252+ arch_system_halt 17 ../arch/x86/core/fatal.c FUNC_NORETURN void arch_system_halt(unsigned int reason)
253+ arch_system_halt 126 ../arch/xtensa/core/fatal.c FUNC_NORETURN void arch_system_halt(unsigned int reason)
254+ arch_system_halt 21 ../kernel/fatal.c FUNC_NORETURN __weak void arch_system_halt(unsigned int reason)
255+
256+ This prints the search symbol, the line it is defined on, a relative path to
257+ the file it is defined in, and the line itself, for all places where the symbol
258+ is defined.
259+
260+ Additional tips:
261+
262+ - This can also be useful to search for vendor HAL function definitions.
263+
264+ - See the ``global `` command's manual page for more information on how to use
265+ this tool.
266+
267+ - You should run ``global ``, **not ** ``west global ``. There is no need for a
268+ separate ``west global `` command since ``global `` already searches for the
269+ ``GTAGS `` file starting from your current working directory. This is why you
270+ need to run ``global `` from inside the workspace.
0 commit comments