Page MenuHomeFreeBSD

Add RISC-V support for truss(1)
ClosedPublic

Authored by lwhsu on Jan 19 2017, 6:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 20, 9:16 PM
Unknown Object (File)
Feb 14 2024, 3:06 PM
Unknown Object (File)
Jan 16 2024, 2:50 PM
Unknown Object (File)
Dec 27 2023, 3:50 PM
Unknown Object (File)
Dec 24 2023, 7:37 PM
Unknown Object (File)
Dec 22 2023, 5:48 PM
Unknown Object (File)
Dec 20 2023, 4:42 AM
Unknown Object (File)
Dec 20 2023, 12:44 AM
Subscribers

Details

Summary

Add RISC-V support for truss(1)

While here, extract NARGREG as a definition.

Test Plan

I've tested this with several commands under /bin, compared with outputs from
amd64 and all seems reasonable. Is there any further tests suggested?

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

lwhsu retitled this revision from to Add RISC-V support for truss(1).
lwhsu updated this object.
lwhsu edited the test plan for this revision. (Show Details)
lwhsu added reviewers: br, jhb.
usr.bin/truss/riscv64-freebsd.c
66 ↗(On Diff #24207)

I think we have 8 argument registers in total: a[0] to a[7]

usr.bin/truss/riscv64-freebsd.c
66 ↗(On Diff #24207)

That's right, which is copied in line 74-75.
I was referencing https://svnweb.freebsd.org/base/head/sys/riscv/riscv/trap.c?revision=308731&view=markup#l102 and I guess this line should be:

syscall_num = regs.t[0];

right?

Correct syscall_num source.

Replace one more '8' to NARGREG

usr.bin/truss/riscv64-freebsd.c
66 ↗(On Diff #24207)

yes according to lib/libc/riscv/SYS.h we have set syscall number to t0

usr.bin/truss/riscv64-freebsd.c
49 ↗(On Diff #24224)

sort lines by length:

struct current_syscall *cs;
u_int i, reg, syscall_num;
struct reg regs;
lwpid_t tid;

76 ↗(On Diff #24224)

leave empty line before return

94 ↗(On Diff #24224)

leave empty line before return

usr.bin/truss/riscv64-freebsd.c
49 ↗(On Diff #24224)

What does the length here mean? line length?
Although it's not kernel code, but I think it's ok to follow style(9):
"When declaring variables in functions declare them sorted by size, then in alphabetical order;"
Is there any standard I missed?

Style:

  • dash after the star in copyright header
  • leave empty line before return
usr.bin/truss/riscv64-freebsd.c
49 ↗(On Diff #24224)

so I think ordering by size means "order it by line length". Am I wrong ?

usr.bin/truss/riscv64-freebsd.c
49 ↗(On Diff #24224)

I guess it means the size of variables resident in the memory. The example after that section in style(9) looks like that. Could you check it?

Aside from the minor style nits, this looks fine to me.

usr.bin/truss/riscv64-freebsd.c
49 ↗(On Diff #24224)

Yes, it means by the size of the variable in memory. I think your best bet here is to just match whatever style is used in the other MD truss backends. (I think they don't have the blank line before return, etc.) They are generally consistent with each other so I think it's best to match those.

usr.bin/truss/riscv64-freebsd.c
49 ↗(On Diff #24224)

@br , how do you think if we keep this order and remove the blank lines before return? I referenced what is in aarch64-freebsd.c .

usr.bin/truss/riscv64-freebsd.c
49 ↗(On Diff #24224)

OK lets keep that order used in other files.

Lets add empty line before return to all the arches by the same or separate commit?

usr.bin/truss/riscv64-freebsd.c
49 ↗(On Diff #24224)

I don't have a strong opinion of this, but if we are going to add empty lines, probably should do in a separate commit since it is a white space change.

BTW, I did not find "an empty line before return", there is only "values in return statements should be enclosed in parentheses." so I don't know if it's good to do such change on all other files.

@jhb , how do you think?

Aside from the minor style nits, this looks fine to me.

(Sorry last comment was a misfire due to Safari confusion)

usr.bin/truss/riscv64-freebsd.c
49 ↗(On Diff #24224)

For now I would say just match the existing files. I'm not sure if I've seen a consistent preference within FreeBSD for or against blank lines before return().

lwhsu edited edge metadata.

remove empty line before return

br edited edge metadata.
This revision is now accepted and ready to land.Jan 23 2017, 9:51 AM
This revision was automatically updated to reflect the committed changes.