Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port c commands to newshell #1854

Merged
merged 70 commits into from
Nov 25, 2021
Merged

Port c commands to newshell #1854

merged 70 commits into from
Nov 25, 2021

Conversation

DMaroo
Copy link
Member

@DMaroo DMaroo commented Oct 18, 2021

cv, cV and cg haven't been ported yet

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the documentation and the rizin book with the relevant information (if needed)

Detailed description

To port:

  • cv (implemented in cb)
  • cV (implemented in ca)
  • cg (to be removed)

Test plan

Add tests for new commands. Test coverage for c commands is not very good.

Closing issues

Tracking issue: #1342

librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
if (b) {
memset(b, 0xff, core->blocksize);
rz_io_read_at(core->io, addr, b, core->blocksize);
rz_print_hexdiff(core->print, core->offset, core->block, addr, b, core->blocksize, col);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wargio please take a look at these two functions, since you wrote that.

librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
Copy link
Member

@ret2libc ret2libc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you noticed, it seems this whole file is not very tested... You can see the coverage on https://app.codecov.io/gh/rizinorg/rizin/blob/6da244eca72902c3939f1ecc5a1b566c93e4b415/librz/core/cmd/cmd_cmp.c . I think adding a basic test for each command would be great.

librz/core/cmd_descs/cmd_cmp.yaml Outdated Show resolved Hide resolved
librz/core/cmd_descs/cmd_cmp.yaml Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
@XVilka
Copy link
Member

XVilka commented Oct 26, 2021

[XX] db/cmd/bitmask bitmask cmp data
RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc 'b 16
wx 414243
e scr.null=1
cx 41..43 2>/dev/null
e scr.null=0
?! ?e thats fine
e scr.null=1
cx 41..11 2>/dev/null
e scr.null=0
?! ?e thats wrong
' =
-- stdout
--- expected
+++ actual
@@ -1,1 +1,0 @@
-thats fine

-- exit status: -1
[XX] db/cmd/data cmp data
RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc 'b 16
wx 41
e scr.null=1
cx 41 2>/dev/null
e scr.null=0
?! ?e thats fine
e scr.null=1
cx 11 2>/dev/null
e scr.null=0
?! ?e thats wrong
' =
-- stdout
--- expected
+++ actual
@@ -1,1 +1,0 @@
-thats fine

-- exit status: -1
[XX] db/cmd/cmd_c cmd_c*
RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc 'c* 1234567890' bins/elf/ls
-- stdout
--- expected
+++ actual
@@ -1,11 +1,0 @@
-wx 31 @ 0x00005ae0
-wx 32 @ 0x00005ae1
-wx 33 @ 0x00005ae2
-wx 34 @ 0x00005ae3
-wx 35 @ 0x00005ae4
-wx 36 @ 0x00005ae5
-wx 37 @ 0x00005ae6
-wx 38 @ 0x00005ae7
-wx 39 @ 0x00005ae8
-wx 30 @ 0x00005ae9
-wx 00 @ 0x00005aea

-- stderr
Command 'c*' does not exist.

Also forgotten e part in:

 [XX] db/cmd/regexp "/e /t\wst\d\d\d\s\w\w/i" - oldshell
RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc 'cfg.oldshell=true
w "test123 ab"
w "Test123 ab" @444
?e
e search.in=block
b 777
"/e /t\wst\d\d\d\s\w\w/i"
' malloc://1024
-- stdout
--- expected
+++ actual
@@ -1,3 +1,0 @@
-
-0x00000000 hit0_0 "test123 ab"
-0x000001bc hit0_1 "Test123 ab"

-- stderr
Command 'cfg.oldshell=true' does not exist.

@DMaroo
Copy link
Member Author

DMaroo commented Oct 26, 2021

Thank you for pointing out. However, I will fix the errors once the porting is complete.

 * Add `rz_cmp.h` and `cmp.c`
 * Break `cmd_cmp_disasm` into 2 API functions, one for getting the
   diff, other for printing the diff
 * Refactor `cmd_cmp.c` to use the new cmd API functions
@DMaroo DMaroo changed the title Port c commands to newshell [WIP] Port c commands to newshell Nov 21, 2021
librz/core/cmd/cmd_debug.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_debug.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
@ret2libc
Copy link
Member

@DMaroo I think you messed up with the branch because you ended up including some changes done by @thestr4ng3r and if you look at the diff right now there are also changes from him related to DYLD.

@DMaroo
Copy link
Member Author

DMaroo commented Nov 23, 2021

Yes. My bad. Moving commits from this branch to the dbl PR might have caused it. I'll fix them.

Copy link
Member

@XVilka XVilka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the remaining tests and we are good to go, IMHO:

[XX] db/cmd/data cmp data
RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc 'b 16
wx 41
e scr.null=1
cx 41 2>/dev/null
e scr.null=0
?! ?e thats fine
e scr.null=1
cx 11 2>/dev/null
e scr.null=0
?! ?e thats wrong
' =
-- stdout
--- expected
+++ actual
@@ --1,3 +-1,4 @@
 thats fine
+thats wrong

[XX] db/cmd/bitmask bitmask cmp data
RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc 'b 16
wx 414243
e scr.null=1
cx 41..43 2>/dev/null
e scr.null=0
?! ?e thats fine
e scr.null=1
cx 41..11 2>/dev/null
e scr.null=0
?! ?e thats wrong
' =
-- stdout
--- expected
+++ actual
@@ --1,3 +-1,4 @@
 thats fine
+thats wrong

@DMaroo DMaroo requested a review from ret2libc November 24, 2021 11:44
Copy link
Member

@ret2libc ret2libc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just few minor/last nitpicks.

librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
librz/core/cmd/cmd_cmp.c Outdated Show resolved Hide resolved
@DMaroo DMaroo requested a review from ret2libc November 25, 2021 11:02
Copy link
Member

@ret2libc ret2libc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@DMaroo DMaroo merged commit 0801f7a into dev Nov 25, 2021
@DMaroo DMaroo deleted the c-port branch November 25, 2021 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants