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

Feature/asm cpu desc #4847

Merged
merged 14 commits into from
Jan 21, 2025
Merged

Conversation

well-mannered-goat
Copy link
Contributor

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 rizin book with the relevant information (if needed)

Detailed description

I have added a command aLc which expects a plugin name as argument and prints out the cpu and their respective descriptions for that plugin. I added descriptions to each plugin which contained cpu in them. I have changed the aL to be a command group with state output and aLc having aL as its parent.

Test plan

Use the command:
aLc mips
aLc xtensa
aLc arm

Closing issues

closes #4806

librz/arch/p/asm/asm_avr.c Outdated Show resolved Hide resolved
Comment on lines 127 to 128
"noptr64", "NoPtr64: MIPS configuration without support for 64-bit pointers, targeting specific use cases.",
"nofloat", "NoFloat: MIPS configuration without floating-point unit, designed for cost-sensitive applications.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"noptr64", "NoPtr64: MIPS configuration without support for 64-bit pointers, targeting specific use cases.",
"nofloat", "NoFloat: MIPS configuration without floating-point unit, designed for cost-sensitive applications.",
"noptr64", "Special MIPS configuration to disable support for 64-bit pointers.",
"nofloat", "Special MIPS configuration to disable support for floating-points.",

Comment on lines 29 to 31
"highend", "High-End: Advanced microcontroller family with rich features and high processing capabilities.",
"midrange", "Mid-Range: Microcontroller family designed for moderate complexity applications with cost-effectiveness.",
"baseline", "Baseline: Entry-level microcontroller family with minimal features for basic applications.",
Copy link
Member

@wargio wargio Jan 17, 2025

Choose a reason for hiding this comment

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

this looks wrong, these are aliases.

baseline is pic14, midrange is pic16 and highend is pic18

@@ -116,6 +116,17 @@ static int ppc_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) {
return op->size;
}

char **ppc_cpu_descriptions() {
static char *cpu_desc[] = {
"ppc", "PowerPC: High-performance RISC architecture used in embedded systems, servers, and workstations.",
Copy link
Member

Choose a reason for hiding this comment

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

this should refer to the generic powerpc risc cpu.

@@ -103,6 +103,14 @@ static bool fini(void *u) {
return true;
}

char **tricore_cpu_descriptions() {
static char *cpu_desc[] = {
"tricore", "TriCore: A 32-bit and 64-bit architecture developed by Infineon, designed for automotive, industrial, and embedded applications with a focus on real-time processing and high performance.",
Copy link
Member

@wargio wargio Jan 17, 2025

Choose a reason for hiding this comment

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

shorten this, no need to mention 32/64 bits. just mention that is the generic tricore cpu developed by infineon.

Comment on lines 34 to 36
"esp32", "32-bit microcontroller with Wi-Fi and Bluetooth capabilities, designed for high-performance applications.",
"esp32s2", "32-bit microcontroller with Wi-Fi and USB OTG support, optimized for low-power and IoT applications.",
"esp8266", "Low-cost 32-bit microcontroller with Wi-Fi support, commonly used in IoT projects and embedded systems.",
Copy link
Member

@wargio wargio Jan 17, 2025

Choose a reason for hiding this comment

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

Instead of 32-bit microcontroller write Xtensa microcontroller ....

Copy link
Member

@wargio wargio left a comment

Choose a reason for hiding this comment

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

Shorten most of them. the CPU description should mention only the difference between cpus, no need for such long explanation.

For example: High-performance ARM Cortex-A72 processor, optimized for mobile and embedded systems. should just be ARM Cortex-A72 processor

@Rot127
Copy link
Member

Rot127 commented Jan 17, 2025

@wargio

no need for such long explanation.

I would not agree with this. Because if the feature was specifically targeted at beginners. So a longer explanation gives more context to them. Maybe it doesn't need to be very long, but more then just the model name IMHO. Otherwise, the current short name is already enough. Wouldn't it?

@kazarmy
Copy link
Member

kazarmy commented Jan 17, 2025

The longer explanation has to be accurate though.

@Rot127
Copy link
Member

Rot127 commented Jan 17, 2025

The longer explanation has to be accurate though.

Absolutely. I think Wikipedia accurate is enough. Not ChatGPT accurate though ;)
(Actually, Wikipedia links in there would be pretty helpful. Just the formatting would suffer very much).

@wargio
Copy link
Member

wargio commented Jan 17, 2025

The longer explanation has to be accurate though.

This is what I meant. The explanation I saw there is often meaningless. I would expect the beginner to also search the cpu name/model. So if we say cortexm it's OK to refer to a cpu family in the description but not such useless info I see there.

@wargio
Copy link
Member

wargio commented Jan 17, 2025

Otherwise, the current short name is already enough. Wouldn't it?

No is not. The cpu name is associated to a cpu family or instruction set extension, which may or not be understandable. See the Pic cpus. I didn't know what "baseline" was till I went and check the code.

Same for arm "cpus". Those are arch extensions which only some families of arm cpus have. The description should indicate what that X for rizin means, because not all the cpus names are obvious.

@Rot127
Copy link
Member

Rot127 commented Jan 17, 2025

No is not. The cpu name is associated to a cpu family or instruction set extension, which may or not be understandable. See the Pic cpus. I didn't know what "baseline" was till I went and check the code.

Good point. Then I agree with you.

@well-mannered-goat
Copy link
Contributor Author

Sorry, didnt check the descriptions.
Would work on it.

chore: formatting

formatting

formatting avr
Copy link
Member

@wargio wargio left a comment

Choose a reason for hiding this comment

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

Last small changes and then it can be merged.

Copy link
Member

@wargio wargio left a comment

Choose a reason for hiding this comment

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

Perfect for me! @well-mannered-goat well done!

Copy link
Member

@Rot127 Rot127 left a comment

Choose a reason for hiding this comment

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

Looks good! Please just address the small comments.
Also check the commands for leaks.

You can either use valgrind (if you are on Linux):

valgrind --leak-check=full rizin -qc "aL ; aLc mips"

or ASAN. How to build with ASAN is described in BUILDING.md.
Then you need to add the env variable

LSAN_OPTIONS: "halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1" rizin -qc "aL ; aLc mips"

librz/core/cmd_descs/cmd_analysis.yaml Outdated Show resolved Hide resolved
librz/core/cmd_descs/cmd_analysis.yaml Outdated Show resolved Hide resolved
librz/core/casm.c Outdated Show resolved Hide resolved
librz/core/casm.c Outdated Show resolved Hide resolved
librz/core/casm.c Outdated Show resolved Hide resolved
test/db/cmd/cmd_aL Show resolved Hide resolved
@wargio wargio merged commit 540b32a into rizinorg:dev Jan 21, 2025
45 checks passed
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.

Add text description for each value of asm.cpu of each architecture
5 participants