Fix serious race in attach to many-threaded process
- the gist is that tasks continue running while we attach, so more tasks
come into existence, or the ones that we didn't attach to yet disappear,
etc.
- besides, we really can't enable breakpoints before we are done attaching,
otherwise the still-running tasks risk running into them and dying of
SIGTRAP.
diff --git a/common.h b/common.h
index f40d405..1af2ac6 100644
--- a/common.h
+++ b/common.h
@@ -295,7 +295,7 @@
extern pid_t execute_program(const char * command, char ** argv);
extern int display_arg(enum tof type, Process * proc, int arg_num, arg_type_info * info);
extern Breakpoint * address2bpstruct(Process * proc, void * addr);
-extern void breakpoints_init(Process * proc, int enable);
+extern int breakpoints_init(Process * proc, int enable);
extern void insert_breakpoint(Process * proc, void * addr,
struct library_symbol * libsym, int enable);
extern void delete_breakpoint(Process * proc, void * addr);
@@ -308,7 +308,7 @@
extern void show_summary(void);
extern arg_type_info * lookup_prototype(enum arg_type at);
-extern void do_init_elf(struct ltelf *lte, const char *filename);
+extern int do_init_elf(struct ltelf *lte, const char *filename);
extern void do_close_elf(struct ltelf *lte);
extern int in_load_libraries(const char *name, struct ltelf *lte, size_t count, GElf_Sym *sym);
extern struct library_symbol *library_symbols;