On Wed, Aug 21, 2019 at 04:01:48PM -0300, Vanderson Martins do Rosario wrote: > On Thu, Aug 15, 2019 at 11:40 AM Stefan Hajnoczi wrote: > > On Wed, Aug 14, 2019 at 11:37:24PM -0300, vandersonmr wrote: > > > +void start_jitdump_file(void) > > > +{ > > > + GString *dumpfile_name = g_string_new(NULL);; > > > + g_string_printf(dumpfile_name, "./jit-%d.dump", getpid()); > > > > Simpler: > > > > gchar *dumpfile_name = g_strdup_printf("./jit-%d.dump", getpid()); > > ... > > g_free(dumpfile_name); > > > > > + dumpfile = fopen(dumpfile_name->str, "w+"); > > > > getpid() and the global dumpfile variable make me wonder what happens > > with multi-threaded TCG? > > > > I did some tests and it appears to be working fine with multi-threaded TCG. > tcg_exec_init should execute only once even in multi-threaded TCG, right? > If so, we are going to create only one jitdump file. Also, both in Windows > and Linux/POSIX fwrites is thread-safe, thus we would be safely updating > the jitdump file. Does it make sense? append_load_in_jitdump_file() calls fwrite() multiple times. What guarantees they will not be interleaved when multiple threads call this function? Stefan