question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage of type code with structs is outdated

See original GitHub issue

Once upon a time in angr, I didn’t understand that there was a difference between the declaration of a struct (struct asdf) and a global typename for a structure (typedef struct asdf asdf;), because we all grow and learn things with time, and sometimes while designing a gigantically complicated system you mistake the trees for the forest.

Regardless, there’s some weird inconsistent behavior in angr.sim_type related to structure (and union, but nobody uses those) declarations. angr.sim_type.define_struct was up until yesterday a function which added to the global type namespace the typename of the struct (asdf) but not the struct asdf name. this is bad obviously!!! i just made it so it added both, but really it should just add struct asdf. I have no idea the extent to which people rely on this behavior, so deprecating it would be weird, except…

Really, define_struct should not exist at all. I think the only reason it existed was because I thought "oh well the point of simtypes is to make it so you can type state.mem[addr].type, and you can’t type types there that have spaces in their names, so what’s the point! anyway I later realized I could just add struct as a special keyword to the mem accessors, so now you can go state.mem[addr].struct.asdf, so there’s absolutely no need to have a big important function to import struct names as global typenames.

So, a to-do list:

  • mark define_struct as deprecated
  • fix the docs which tell you to use define_struct and add the state.mem[addr].struct.name syntax

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:22 (22 by maintainers)

github_iconTop GitHub Comments

1reaction
saullocarvalhocommented, Jun 5, 2019

I can do this, so you can focus on more important issues.

1reaction
rhelmotcommented, Jun 5, 2019

Good work. I’ll mark define_struct deprecated and update any examples using it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When does it make sense to use a struct without a typedef?
It makes particular sense if you have experience with languages in which class/type names do not intrude into the lexical variable namespace, ...
Read more >
Stop Using Structs! | by Gokhan Topcu | Commencis | Medium
By providing powerful value types, Swift aims to maximize value type usage to avoid possible errors related to sharing the state.
Read more >
Use Structs Not Classes - Wiki
One should only use structs for POD (PlainOldData) types that have no methods and whose data members are all public. Even then, why...
Read more >
java - Is there any reason to use "plain old data" classes?
My understanding of OO is that classes are structures for data and the methods of operating on that data. This seems to preclude...
Read more >
No more plain old data - Marius Bancila's Blog
This article discusses the deprecated concept of plain old data (POD) C++ types and the new trivial and standard-layout types.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found