mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-04-27 20:38:54 +00:00
nm: change PrintFile param to a synthesized option, reformat #option{}
This commit is contained in:
@@ -23,19 +23,20 @@
|
|||||||
|
|
||||||
-include_lib("lib/include/pdp10_elf36.hrl").
|
-include_lib("lib/include/pdp10_elf36.hrl").
|
||||||
|
|
||||||
-record(options, {
|
-record(options,
|
||||||
print_file_name = false % -A, -o, --print-file-name
|
{ print_file_name = false % -A, -o, --print-file-name
|
||||||
, dynamic = false % -D, --dynamic
|
, dynamic = false % -D, --dynamic
|
||||||
, format = $b % -B, -P, --portability, -f [bsd|sysv|posix], --format=[bsd|sysv|posix]
|
, format = $b % -B, -P, --portability, -f [bsd|sysv|posix], --format=[bsd|sysv|posix]
|
||||||
, extern_only = false % -g, --extern-only
|
, extern_only = false % -g, --extern-only
|
||||||
, numeric_sort = false % -n, -v, --numeric-sort
|
, numeric_sort = false % -n, -v, --numeric-sort
|
||||||
, no_sort = false % -p, --no-sort
|
, no_sort = false % -p, --no-sort
|
||||||
, print_size = false % -S, --print-size
|
, print_size = false % -S, --print-size
|
||||||
, reverse_sort = false % -r, --reverse-sort
|
, reverse_sort = false % -r, --reverse-sort
|
||||||
, radix = $x % -t [dox], --radix=[dox]
|
, radix = $x % -t [dox], --radix=[dox]
|
||||||
, undefined_only = false % -u, --undefined-only
|
, undefined_only = false % -u, --undefined-only
|
||||||
, defined_only = false % --defined-only
|
, defined_only = false % --defined-only
|
||||||
}).
|
, print_file = false % internal, synthesized
|
||||||
|
}).
|
||||||
|
|
||||||
%% Command-line interface ======================================================
|
%% Command-line interface ======================================================
|
||||||
|
|
||||||
@@ -142,30 +143,31 @@ parse_radix(String) ->
|
|||||||
|
|
||||||
%% Nm ==========================================================================
|
%% Nm ==========================================================================
|
||||||
|
|
||||||
nm(Opts, Files0) ->
|
nm(Opts0, Files0) ->
|
||||||
{Files, PrintFile} =
|
{Files, PrintFile} =
|
||||||
case Files0 of
|
case Files0 of
|
||||||
[] -> {["a.out"], false};
|
[] -> {["a.out"], false};
|
||||||
[_] -> {Files0, false};
|
[_] -> {Files0, false};
|
||||||
[_,_|_] -> {Files0, true}
|
[_,_|_] -> {Files0, true}
|
||||||
end,
|
end,
|
||||||
[nm1(Opts, PrintFile, File) || File <- Files],
|
Opts = Opts0#options{print_file = PrintFile},
|
||||||
|
[nm1(Opts, File) || File <- Files],
|
||||||
halt(0).
|
halt(0).
|
||||||
|
|
||||||
nm1(Opts, PrintFile, File) ->
|
nm1(Opts, File) ->
|
||||||
case pdp10_stdio:fopen(File, [read]) of
|
case pdp10_stdio:fopen(File, [read]) of
|
||||||
{ok, FP} ->
|
{ok, FP} ->
|
||||||
nm1(Opts, PrintFile, File, FP),
|
nm1(Opts, File, FP),
|
||||||
pdp10_stdio:fclose(FP);
|
pdp10_stdio:fclose(FP);
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
escript_runtime:fatal("failed to open ~s: ~p\n", [File, Reason])
|
escript_runtime:fatal("failed to open ~s: ~p\n", [File, Reason])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
nm1(Opts, PrintFile, File, FP) ->
|
nm1(Opts, File, FP) ->
|
||||||
Ehdr = read_ehdr(File, FP),
|
Ehdr = read_ehdr(File, FP),
|
||||||
ShTab = read_shtab(File, FP, Ehdr),
|
ShTab = read_shtab(File, FP, Ehdr),
|
||||||
SymTab = read_symtab(File, FP, ShTab),
|
SymTab = read_symtab(File, FP, ShTab),
|
||||||
print_symtab(Opts, PrintFile, File, ShTab, SymTab).
|
print_symtab(Opts, File, ShTab, SymTab).
|
||||||
|
|
||||||
read_ehdr(File, FP) ->
|
read_ehdr(File, FP) ->
|
||||||
case pdp10_elf36:read_Ehdr(FP) of
|
case pdp10_elf36:read_Ehdr(FP) of
|
||||||
@@ -192,8 +194,8 @@ read_symtab(File, FP, ShTab) ->
|
|||||||
[File, error:format(Reason)])
|
[File, error:format(Reason)])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
print_symtab(Opts, PrintFile, File, ShTab, SymTab) ->
|
print_symtab(Opts, File, ShTab, SymTab) ->
|
||||||
case PrintFile of
|
case Opts#options.print_file of
|
||||||
true -> io:format("\n~s:\n", [File]);
|
true -> io:format("\n~s:\n", [File]);
|
||||||
false -> ok
|
false -> ok
|
||||||
end,
|
end,
|
||||||
|
|||||||
Reference in New Issue
Block a user