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

Refactor output modes to use enum #950

Closed
wants to merge 12 commits into from
Closed

Refactor output modes to use enum #950

wants to merge 12 commits into from

Conversation

valdaarhun
Copy link
Contributor

@valdaarhun valdaarhun commented Apr 1, 2021

Original PR: #929

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 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

Refactored output modes to use enum. int mode and char mode patterns in the code have been replaced with RzOutputMode enum type.

Refactoring is still in progress.

Test plan

...

Closing issues

closes #489

@XVilka
Copy link
Member

XVilka commented Apr 2, 2021

  1. Wrongly comitted librz/main/rz-ax.c~HEAD
  2. It breaks many tests:

The test breakage happens because you didn't change the places where this function is called so they use the old "modes" which don't match a new parameter.

[XX] db/cmd/cmd_avr avra and avrr msvc x86
RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc 'aar
avra
?e --
avrr
acll
' bins/pe/cpp-msvc-x86.exe
-- stdout
@@ -116,22 +116,5 @@
 
 --
 [Album]
-  (vtable at 0x412164)
-nth name           addr vt_offset type
---------------------------------------
-1   virtual_0  0x40105d 0x0       VIRTUAL
-2   virtual_4  0x4010a7 0x4       VIRTUAL
-
 [InAbsentia: Album]
-  (vtable at 0x4121a4)
-nth name           addr vt_offset type
---------------------------------------
-1   virtual_0  0x401088 0x0       VIRTUAL
-2   virtual_4  0x4010b3 0x4       VIRTUAL
-
 [type_info]
-  (vtable at 0x4121fc)
-nth name           addr vt_offset type
---------------------------------------
-1   virtual_0  0x401136 0x0       VIRTUAL
-

[XX] db/cmd/cmd_acll PR#898
RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc 'aaa
acll
' bins/elf/analysis/classes_Polygon
-- stdout
@@ -1,46 +1,6 @@
 [Polygon]
-  (vtable at 0x3d20)
-nth name          addr vt_offset type
--------------------------------------
-1   Polygon     0x11ea -1        CONSTRUCTOR
-2   Polygon1    0x121e -1        DEFAULT
-3   Poly        0x122e -1        DEFAULT
-4   ~Polygon    0x123e -1        DESTRUCTOR
-5   set_values  0x14b6 -1        DEFAULT
-6   area        0x14e0 0x0       VIRTUAL
-7   sides       0x14f4 0x8       VIRTUAL
-
 [Rectangle: Polygon]
-  (vtable at 0x3d00)
-nth name          addr vt_offset type
--------------------------------------
-1   area        0x1508 0x0       VIRTUAL
-2   sides       0x1528 0x8       VIRTUAL
-3   Rectangle   0x1578 -1        CONSTRUCTOR
-4   ~Rectangle  0x15a6 -1        DESTRUCTOR
-
 [Triangle: Polygon]
-  (vtable at 0x3ce0)
-nth name         addr vt_offset type
-------------------------------------
-1   area       0x153c 0x0       VIRTUAL
-2   sides      0x1564 0x8       VIRTUAL
-3   Triangle   0x15d4 -1        CONSTRUCTOR
-4   ~Triangle  0x1602 -1        DESTRUCTOR
-
 [std::basic_ostream_char__std::char_traits_char_____std::endl_char__std]
-nth name                   addr vt_offset type
-----------------------------------------------
-1   char_traits<char> >  0x3fd0 -1        DEFAULT
-
 [std::ios_base::Init]
-nth name     addr vt_offset type
---------------------------------
-1   Init   0x3fb0 -1        DEFAULT
-2   ~Init  0x3ff8 -1        DEFAULT
-
 [std::ostream]
-nth name          addr vt_offset type
--------------------------------------
-1   operator<<  0x3fb8 -1        DEFAULT
-


-- stderr
Warning: run rizin with -e io.cache=true to fix relocations in disassembly
[ ] Analyze all flags starting with sym. and entry0 (aa)
[
[x] Analyze all flags starting with sym. and entry0 (aa)

[XX] db/cmd/cmd_acll acll list class detailed
RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc 'aaa
acll
' bins/elf/analysis/elf-virtualtable
-- stdout
@@ -1,45 +1,7 @@
 [A]
-  (vtable at 0x400d28)
-nth name            addr vt_offset type
----------------------------------------
-1   greet       0x400ac8 0x0       VIRTUAL
-2   printValue  0x400af4 0x8       VIRTUAL
-3   A           0x400b36 -1        CONSTRUCTOR
-
 [B: A]
-  (vtable at 0x400d08)
-nth name                addr vt_offset type
--------------------------------------------
-1   B               0x400b4e -1        CONSTRUCTOR
-2   printValue      0x400b82 0x8       VIRTUAL
-3   method.A.greet  0x400ac8 0x0       VIRTUAL
-
 [C: A]
-  (vtable at 0x400ce8)
-nth name                addr vt_offset type
--------------------------------------------
-1   C               0x400bc4 -1        CONSTRUCTOR
-2   printValue      0x400bf8 0x8       VIRTUAL
-3   method.A.greet  0x400ac8 0x0       VIRTUAL
-
 [std::basic_ostream_char__std::char_traits_char_____std::endl_char__std]
-nth name                     addr vt_offset type
-------------------------------------------------
-1   char_traits<char> >  0x6012a8 -1        DEFAULT
-
 [std::basic_ostream_char__std::char_traits_char_____std::operator____std]
-nth name                     addr vt_offset type
-------------------------------------------------
-1   char_traits<char> >  0x601298 -1        DEFAULT
-
 [std::ios_base::Init]
-nth name       addr vt_offset type
-----------------------------------
-1   Init   0x601278 -1        DEFAULT
-2   ~Init  0x601290 -1        DEFAULT
-
 [std::ostream]
-nth name            addr vt_offset type
----------------------------------------
-1   operator<<  0x6012a0 -1        DEFAULT
-


-- stderr
[ ] Analyze all flags starting with sym. and entry0 (aa)
[
[x] Analyze all flags starting with sym. and entry0 (aa)

[XX] db/cmd/cmd_ac acvf
RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc 'ac A
ac B
ac C
acv A 0x00400d28 0x0 0x10
acv B 0x00400d08 0x0 0x10
acv C 0x00400ce8 0x0 0x10
acll
acvf 0x0 A
acvf 0x8 B
acvf 0x16 C dasdass
acvf 0x0
acvf -50
acvf 0x0 000ASDASdjpsadoaspdjasdaspodasDDD
acv A 0x00400d28 0x0
' bins/elf/analysis/elf-virtualtable
-- stdout
@@ -1,9 +1,6 @@
 [A]
-  (vtable at 0x400d28)
 [B]
-  (vtable at 0x400d08)
 [C]
-  (vtable at 0x400ce8)

https://builds.sr.ht/~xvilka/job/474974#task-test-0

@valdaarhun
Copy link
Contributor Author

  1. I think I accidentally committed librz/main/rz-ax.c~HEAD while merging from upstream and resolving conflicts. I'll uncommit this.
  2. Should I progress by refactoring a few files at a time while ensuring that the function declarations, definitions and calls are all changed at the same time?

@XVilka
Copy link
Member

XVilka commented Apr 2, 2021

@valdaarhun yes, change one file and all callers of functions from that file.

@wargio wargio changed the title Refactor output modes to use enum - 2 Refactor output modes to use enum Apr 2, 2021
@wargio
Copy link
Member

wargio commented Apr 2, 2021

i would still go with function by function.

@valdaarhun
Copy link
Contributor Author

I think I have messed up this branch while updating and resolving conflicts. I think it'll be better if I close this issue and start from scratch in a new branch.

@valdaarhun valdaarhun closed this Apr 2, 2021
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.

Refactor output modes to use enum
3 participants