X86/disasm: Make immediate annotation flag thread-local
The "annotate immediates" flag in the x86 disassembler is now thread-local, preventing unintended side effects in multi-threaded contexts.
The “annotate immediates” flag in the x86 disassembler was changed from a global variable to a thread-local variable within the instr_info struct. This prevents unintended side effects in multi-threaded scenarios where disassembly functions are used concurrently. The change ensures that the annotation setting is specific to each disassembly operation.
In Details
The x86 disassembler, specifically opcodes/i386-dis.c, had a global flag annotate_immediates controlling immediate value annotation. With disassembly functions now thread-safe, introducing new global state variables is discouraged. This commit moves the flag to the instr_info struct, making it thread-local.
For Context
In software development, thread safety is crucial when multiple threads access and modify shared data. A disassembler translates machine code back into assembly, and the "annotate immediates" feature adds symbolic information to immediate values in the disassembled output. This change makes the x86 disassembler thread-safe by ensuring that the annotation setting doesn't interfere with other threads.