mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 13:37:27 +08:00
Add a tool to locate global variables
This commit is contained in:
parent
9fd3f35c9a
commit
f465760d1f
19
build_tools/find_globals.fish
Executable file
19
build_tools/find_globals.fish
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env fish
|
||||
|
||||
# Finds global variables by parsing the output of 'nm'
|
||||
# for object files in this directory.
|
||||
# This was written for macOS nm.
|
||||
|
||||
set total_globals 0
|
||||
|
||||
for file in ./**.o
|
||||
set filename (basename $file)
|
||||
for line in (nm -p -P -U $file)
|
||||
# Look in data (dD) and bss (bB) segments.
|
||||
set matches (string match --regex '^([^ ]+) ([dDbB])' -- $line) ; or continue
|
||||
echo $filename (echo $matches[2] | c++filt) $matches[3]
|
||||
set total_globals (math $total_globals + 1)
|
||||
end
|
||||
end
|
||||
|
||||
echo "Total: $total_globals"
|
Loading…
Reference in New Issue
Block a user