On Thu, Oct 22, 2020 at 10:21:40PM +0900, Masami Hiramatsu wrote: > extern void insn_init(struct insn *insn, const void *kaddr, int buf_len, int > x86_64); > extern void insn_get_prefixes(struct insn *insn); > extern void insn_get_opcode(struct insn *insn); > extern void insn_get_modrm(struct insn *insn); > extern void insn_get_sib(struct insn *insn); > extern void insn_get_displacement(struct insn *insn); > extern void insn_get_immediate(struct insn *insn); > extern void insn_get_length(struct insn *insn);
... > Ah, so you meant that we don't need such a different insn_get_* APIs, > but a single insn_decode() API, which will decode all fields. > (IOW, alias of insn_init() and insn_get_length(), right?) Yes, so there should be a balance between what one wants to decode: length, opcodes, etc vs when one needs only a certain *single* aspect: sib, length, displacement, etc. So if you need a couple of things, you can simply call the insn_decode() function - I'm reading forward and I like your naming :) - and when that returns success, you can be sure that struct insn contains all the fields needed. Otherwise... > > If there are specialized uses, you can call some of the insn_get_* > > helpers if you're not interested in decoding the full insn. > > OK, agreed. ... yes, exactly! > > But if simply calling insn_decode_insn() would give you everything and > > that is not that expensive, we can do that - API simplicity. > > I rather like simple "insn_decode()" function, no need to repeat > insn again. > > int insn_decode(struct insn *insn, const void *kaddr, int buf_len, bool > x86_64); Yap, good. Ok, seems we agree, lemme poke at this one more time, convert some users and we can see how it looks like and talk then. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette