| Juan Cespedes | d44c6b8 | 1998-09-25 14:48:42 +0200 | [diff] [blame] | 1 | #include "config.h" |
| Juan Cespedes | d44c6b8 | 1998-09-25 14:48:42 +0200 | [diff] [blame] | 2 | |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 3 | #include <stdlib.h> |
| Juan Cespedes | 7186e2a | 2003-01-31 19:56:34 +0100 | [diff] [blame] | 4 | #include <string.h> |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 5 | #include <assert.h> |
| 6 | |
| Juan Cespedes | f1bfe20 | 2002-03-27 00:22:23 +0100 | [diff] [blame] | 7 | #ifdef __powerpc__ |
| 8 | #include <sys/ptrace.h> |
| 9 | #endif |
| 10 | |
| Juan Cespedes | f728123 | 2009-06-25 16:11:21 +0200 | [diff] [blame] | 11 | #include "common.h" |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 12 | |
| 13 | /*****************************************************************************/ |
| 14 | |
| Juan Cespedes | 1dec217 | 2009-05-07 10:12:10 +0200 | [diff] [blame] | 15 | Breakpoint * |
| Petr Machata | fed1e8d | 2012-02-07 02:06:29 +0100 | [diff] [blame^] | 16 | address2bpstruct(Process *proc, void *addr) |
| 17 | { |
| Petr Machata | 2662768 | 2011-07-08 18:15:32 +0200 | [diff] [blame] | 18 | assert(proc != NULL); |
| 19 | assert(proc->breakpoints != NULL); |
| Petr Machata | 9a5420c | 2011-07-09 11:21:23 +0200 | [diff] [blame] | 20 | assert(proc->leader == proc); |
| Juan Cespedes | cd8976d | 2009-05-14 13:47:58 +0200 | [diff] [blame] | 21 | debug(DEBUG_FUNCTION, "address2bpstruct(pid=%d, addr=%p)", proc->pid, addr); |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 22 | return dict_find_entry(proc->breakpoints, addr); |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 23 | } |
| 24 | |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 25 | void |
| Juan Cespedes | a8909f7 | 2009-04-28 20:02:41 +0200 | [diff] [blame] | 26 | insert_breakpoint(Process *proc, void *addr, |
| Petr Machata | fed1e8d | 2012-02-07 02:06:29 +0100 | [diff] [blame^] | 27 | struct library_symbol *libsym, int enable) |
| 28 | { |
| Juan Cespedes | 1dec217 | 2009-05-07 10:12:10 +0200 | [diff] [blame] | 29 | Breakpoint *sbp; |
| Juan Cespedes | cd8976d | 2009-05-14 13:47:58 +0200 | [diff] [blame] | 30 | |
| Petr Machata | 9a5420c | 2011-07-09 11:21:23 +0200 | [diff] [blame] | 31 | Process * leader = proc->leader; |
| 32 | |
| 33 | /* Only the group leader should be getting the breakpoints and |
| 34 | * thus have ->breakpoint initialized. */ |
| 35 | assert(leader != NULL); |
| 36 | assert(leader->breakpoints != NULL); |
| 37 | |
| Zachary T Welch | a2ff9d6 | 2010-10-08 11:47:49 -0700 | [diff] [blame] | 38 | #ifdef __arm__ |
| 39 | int thumb_mode = (int)addr & 1; |
| 40 | if (thumb_mode) |
| 41 | addr = (void *)((int)addr & ~1); |
| 42 | #endif |
| 43 | |
| Juan Cespedes | cd8976d | 2009-05-14 13:47:58 +0200 | [diff] [blame] | 44 | debug(DEBUG_FUNCTION, "insert_breakpoint(pid=%d, addr=%p, symbol=%s)", proc->pid, addr, libsym ? libsym->name : "NULL"); |
| Petr Machata | b3f8fef | 2006-11-30 14:45:07 +0100 | [diff] [blame] | 45 | debug(1, "symbol=%s, addr=%p", libsym?libsym->name:"(nil)", addr); |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 46 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 47 | if (!addr) |
| 48 | return; |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 49 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 50 | if (libsym) |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 51 | libsym->needs_init = 0; |
| 52 | |
| Petr Machata | 9a5420c | 2011-07-09 11:21:23 +0200 | [diff] [blame] | 53 | sbp = dict_find_entry(leader->breakpoints, addr); |
| Petr Machata | fed1e8d | 2012-02-07 02:06:29 +0100 | [diff] [blame^] | 54 | if (sbp == NULL) { |
| 55 | sbp = calloc(1, sizeof(*sbp)); |
| 56 | if (sbp == NULL) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 57 | return; /* TODO FIXME XXX: error_mem */ |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 58 | } |
| Petr Machata | 9a5420c | 2011-07-09 11:21:23 +0200 | [diff] [blame] | 59 | dict_enter(leader->breakpoints, addr, sbp); |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 60 | sbp->addr = addr; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 61 | sbp->libsym = libsym; |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 62 | } |
| Juan Cespedes | 63184be | 2008-12-10 13:30:12 +0100 | [diff] [blame] | 63 | #ifdef __arm__ |
| Zachary T Welch | a2ff9d6 | 2010-10-08 11:47:49 -0700 | [diff] [blame] | 64 | sbp->thumb_mode = thumb_mode | proc->thumb_mode; |
| Juan Cespedes | 63184be | 2008-12-10 13:30:12 +0100 | [diff] [blame] | 65 | proc->thumb_mode = 0; |
| 66 | #endif |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 67 | sbp->enabled++; |
| Petr Machata | c7585b6 | 2011-07-08 22:58:12 +0200 | [diff] [blame] | 68 | if (sbp->enabled == 1 && enable) { |
| 69 | assert(proc->pid != 0); |
| Petr Machata | f789c9c | 2011-07-09 10:54:27 +0200 | [diff] [blame] | 70 | enable_breakpoint(proc, sbp); |
| Petr Machata | c7585b6 | 2011-07-08 22:58:12 +0200 | [diff] [blame] | 71 | } |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 72 | } |
| 73 | |
| Juan Cespedes | f135052 | 2008-12-16 18:19:58 +0100 | [diff] [blame] | 74 | void |
| Petr Machata | fed1e8d | 2012-02-07 02:06:29 +0100 | [diff] [blame^] | 75 | delete_breakpoint(Process *proc, void *addr) |
| 76 | { |
| Juan Cespedes | cd8976d | 2009-05-14 13:47:58 +0200 | [diff] [blame] | 77 | Breakpoint *sbp; |
| 78 | |
| 79 | debug(DEBUG_FUNCTION, "delete_breakpoint(pid=%d, addr=%p)", proc->pid, addr); |
| 80 | |
| Petr Machata | 9a5420c | 2011-07-09 11:21:23 +0200 | [diff] [blame] | 81 | Process * leader = proc->leader; |
| 82 | assert(leader != NULL); |
| 83 | |
| 84 | sbp = dict_find_entry(leader->breakpoints, addr); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 85 | assert(sbp); /* FIXME: remove after debugging has been done. */ |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 86 | /* This should only happen on out-of-memory conditions. */ |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 87 | if (sbp == NULL) |
| 88 | return; |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 89 | |
| 90 | sbp->enabled--; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 91 | if (sbp->enabled == 0) |
| Petr Machata | f789c9c | 2011-07-09 10:54:27 +0200 | [diff] [blame] | 92 | disable_breakpoint(proc, sbp); |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 93 | assert(sbp->enabled >= 0); |
| 94 | } |
| 95 | |
| Juan Cespedes | f135052 | 2008-12-16 18:19:58 +0100 | [diff] [blame] | 96 | static void |
| Petr Machata | fed1e8d | 2012-02-07 02:06:29 +0100 | [diff] [blame^] | 97 | enable_bp_cb(void *addr, void *sbp, void *proc) |
| 98 | { |
| Juan Cespedes | cd8976d | 2009-05-14 13:47:58 +0200 | [diff] [blame] | 99 | debug(DEBUG_FUNCTION, "enable_bp_cb(pid=%d)", ((Process *)proc)->pid); |
| Juan Cespedes | 1dec217 | 2009-05-07 10:12:10 +0200 | [diff] [blame] | 100 | if (((Breakpoint *)sbp)->enabled) { |
| Petr Machata | f789c9c | 2011-07-09 10:54:27 +0200 | [diff] [blame] | 101 | enable_breakpoint(proc, sbp); |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 102 | } |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 103 | } |
| 104 | |
| Juan Cespedes | f135052 | 2008-12-16 18:19:58 +0100 | [diff] [blame] | 105 | void |
| Juan Cespedes | a8909f7 | 2009-04-28 20:02:41 +0200 | [diff] [blame] | 106 | enable_all_breakpoints(Process *proc) { |
| Juan Cespedes | cd8976d | 2009-05-14 13:47:58 +0200 | [diff] [blame] | 107 | debug(DEBUG_FUNCTION, "enable_all_breakpoints(pid=%d)", proc->pid); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 108 | if (proc->breakpoints_enabled <= 0) { |
| Juan Cespedes | f1bfe20 | 2002-03-27 00:22:23 +0100 | [diff] [blame] | 109 | #ifdef __powerpc__ |
| 110 | unsigned long a; |
| 111 | |
| 112 | /* |
| 113 | * PPC HACK! (XXX FIXME TODO) |
| 114 | * If the dynamic linker hasn't populated the PLT then |
| 115 | * dont enable the breakpoints |
| 116 | */ |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 117 | if (options.libcalls) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 118 | a = ptrace(PTRACE_PEEKTEXT, proc->pid, |
| Paul Gilliam | 76c61f1 | 2006-06-14 06:55:21 +0200 | [diff] [blame] | 119 | sym2addr(proc, proc->list_of_symbols), |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 120 | 0); |
| Juan Cespedes | de5a7eb | 2002-03-31 20:53:52 +0200 | [diff] [blame] | 121 | if (a == 0x0) |
| 122 | return; |
| 123 | } |
| Juan Cespedes | f1bfe20 | 2002-03-27 00:22:23 +0100 | [diff] [blame] | 124 | #endif |
| 125 | |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 126 | debug(1, "Enabling breakpoints for pid %u...", proc->pid); |
| Juan Cespedes | a0ccf39 | 2003-02-01 19:02:37 +0100 | [diff] [blame] | 127 | if (proc->breakpoints) { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 128 | dict_apply_to_all(proc->breakpoints, enable_bp_cb, |
| 129 | proc); |
| Juan Cespedes | a0ccf39 | 2003-02-01 19:02:37 +0100 | [diff] [blame] | 130 | } |
| Eric Vaitl | 1228a91 | 2006-12-28 16:16:56 +0100 | [diff] [blame] | 131 | #ifdef __mips__ |
| Juan Cespedes | a413e5b | 2007-09-04 17:34:53 +0200 | [diff] [blame] | 132 | { |
| Juan Cespedes | 5c68204 | 2009-05-21 15:59:56 +0200 | [diff] [blame] | 133 | /* |
| 134 | * I'm sure there is a nicer way to do this. We need to |
| 135 | * insert breakpoints _after_ the child has been started. |
| 136 | */ |
| Juan Cespedes | a413e5b | 2007-09-04 17:34:53 +0200 | [diff] [blame] | 137 | struct library_symbol *sym; |
| 138 | struct library_symbol *new_sym; |
| 139 | sym=proc->list_of_symbols; |
| 140 | while(sym){ |
| 141 | void *addr= sym2addr(proc,sym); |
| 142 | if(!addr){ |
| 143 | sym=sym->next; |
| 144 | continue; |
| 145 | } |
| 146 | if(dict_find_entry(proc->breakpoints,addr)){ |
| 147 | sym=sym->next; |
| 148 | continue; |
| 149 | } |
| 150 | debug(2,"inserting bp %p %s",addr,sym->name); |
| Arnaud Patard | 4795087 | 2010-01-08 08:40:15 -0500 | [diff] [blame] | 151 | new_sym=malloc(sizeof(*new_sym) + strlen(sym->name) + 1); |
| 152 | memcpy(new_sym,sym,sizeof(*new_sym) + strlen(sym->name) + 1); |
| Juan Cespedes | a413e5b | 2007-09-04 17:34:53 +0200 | [diff] [blame] | 153 | new_sym->next=proc->list_of_symbols; |
| 154 | proc->list_of_symbols=new_sym; |
| Juan Cespedes | a413e5b | 2007-09-04 17:34:53 +0200 | [diff] [blame] | 155 | insert_breakpoint(proc, addr, new_sym); |
| 156 | sym=sym->next; |
| 157 | } |
| 158 | } |
| Eric Vaitl | 1228a91 | 2006-12-28 16:16:56 +0100 | [diff] [blame] | 159 | #endif |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 160 | } |
| 161 | proc->breakpoints_enabled = 1; |
| 162 | } |
| 163 | |
| Juan Cespedes | f135052 | 2008-12-16 18:19:58 +0100 | [diff] [blame] | 164 | static void |
| Petr Machata | fed1e8d | 2012-02-07 02:06:29 +0100 | [diff] [blame^] | 165 | disable_bp_cb(void *addr, void *sbp, void *proc) |
| 166 | { |
| Juan Cespedes | cd8976d | 2009-05-14 13:47:58 +0200 | [diff] [blame] | 167 | debug(DEBUG_FUNCTION, "disable_bp_cb(pid=%d)", ((Process *)proc)->pid); |
| Juan Cespedes | 1dec217 | 2009-05-07 10:12:10 +0200 | [diff] [blame] | 168 | if (((Breakpoint *)sbp)->enabled) { |
| Petr Machata | f789c9c | 2011-07-09 10:54:27 +0200 | [diff] [blame] | 169 | disable_breakpoint(proc, sbp); |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 170 | } |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 171 | } |
| 172 | |
| Juan Cespedes | f135052 | 2008-12-16 18:19:58 +0100 | [diff] [blame] | 173 | void |
| Juan Cespedes | a8909f7 | 2009-04-28 20:02:41 +0200 | [diff] [blame] | 174 | disable_all_breakpoints(Process *proc) { |
| Juan Cespedes | cd8976d | 2009-05-14 13:47:58 +0200 | [diff] [blame] | 175 | debug(DEBUG_FUNCTION, "disable_all_breakpoints(pid=%d)", proc->pid); |
| Petr Machata | 9a5420c | 2011-07-09 11:21:23 +0200 | [diff] [blame] | 176 | assert(proc->leader == proc); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 177 | if (proc->breakpoints_enabled) { |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame] | 178 | debug(1, "Disabling breakpoints for pid %u...", proc->pid); |
| 179 | dict_apply_to_all(proc->breakpoints, disable_bp_cb, proc); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 180 | } |
| 181 | proc->breakpoints_enabled = 0; |
| 182 | } |
| Juan Cespedes | 7186e2a | 2003-01-31 19:56:34 +0100 | [diff] [blame] | 183 | |
| Juan Cespedes | f135052 | 2008-12-16 18:19:58 +0100 | [diff] [blame] | 184 | static void |
| 185 | free_bp_cb(void *addr, void *sbp, void *data) { |
| Juan Cespedes | cd8976d | 2009-05-14 13:47:58 +0200 | [diff] [blame] | 186 | debug(DEBUG_FUNCTION, "free_bp_cb(sbp=%p)", sbp); |
| Juan Cespedes | 7186e2a | 2003-01-31 19:56:34 +0100 | [diff] [blame] | 187 | assert(sbp); |
| 188 | free(sbp); |
| 189 | } |
| 190 | |
| Petr Machata | 1974dbc | 2011-08-19 18:58:01 +0200 | [diff] [blame] | 191 | int |
| Petr Machata | c7585b6 | 2011-07-08 22:58:12 +0200 | [diff] [blame] | 192 | breakpoints_init(Process *proc, int enable) |
| 193 | { |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 194 | struct library_symbol *sym; |
| Juan Cespedes | 7186e2a | 2003-01-31 19:56:34 +0100 | [diff] [blame] | 195 | |
| Juan Cespedes | cd8976d | 2009-05-14 13:47:58 +0200 | [diff] [blame] | 196 | debug(DEBUG_FUNCTION, "breakpoints_init(pid=%d)", proc->pid); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 197 | if (proc->breakpoints) { /* let's remove that struct */ |
| Juan Cespedes | 7186e2a | 2003-01-31 19:56:34 +0100 | [diff] [blame] | 198 | dict_apply_to_all(proc->breakpoints, free_bp_cb, NULL); |
| 199 | dict_clear(proc->breakpoints); |
| 200 | proc->breakpoints = NULL; |
| 201 | } |
| Petr Machata | 2662768 | 2011-07-08 18:15:32 +0200 | [diff] [blame] | 202 | |
| Petr Machata | 9a5420c | 2011-07-09 11:21:23 +0200 | [diff] [blame] | 203 | /* Only the thread group leader should hold the breakpoints. |
| 204 | * (N.B. PID may be set to 0 temporarily when called by |
| 205 | * handle_exec). */ |
| 206 | assert(proc->leader == proc); |
| 207 | |
| Petr Machata | 2662768 | 2011-07-08 18:15:32 +0200 | [diff] [blame] | 208 | proc->breakpoints = dict_init(dict_key2hash_int, |
| 209 | dict_key_cmp_int); |
| Juan Cespedes | 7186e2a | 2003-01-31 19:56:34 +0100 | [diff] [blame] | 210 | |
| Petr Machata | 534e00f | 2011-09-27 17:58:38 +0200 | [diff] [blame] | 211 | destroy_library_symbol_chain(proc->list_of_symbols); |
| Petr Machata | 3d7e4b8 | 2011-07-08 18:15:19 +0200 | [diff] [blame] | 212 | proc->list_of_symbols = NULL; |
| 213 | |
| Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 214 | if (options.libcalls && proc->filename) { |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 215 | proc->list_of_symbols = read_elf(proc); |
| Petr Machata | 1974dbc | 2011-08-19 18:58:01 +0200 | [diff] [blame] | 216 | if (proc->list_of_symbols == NULL) { |
| 217 | /* XXX leak breakpoints */ |
| 218 | return -1; |
| 219 | } |
| 220 | |
| Juan Cespedes | 7186e2a | 2003-01-31 19:56:34 +0100 | [diff] [blame] | 221 | if (opt_e) { |
| Petr Machata | 2662768 | 2011-07-08 18:15:32 +0200 | [diff] [blame] | 222 | struct library_symbol **tmp1 = &proc->list_of_symbols; |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 223 | while (*tmp1) { |
| 224 | struct opt_e_t *tmp2 = opt_e; |
| Juan Cespedes | 7186e2a | 2003-01-31 19:56:34 +0100 | [diff] [blame] | 225 | int keep = !opt_e_enable; |
| 226 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 227 | while (tmp2) { |
| Petr Machata | 2662768 | 2011-07-08 18:15:32 +0200 | [diff] [blame] | 228 | if (!strcmp((*tmp1)->name, |
| 229 | tmp2->name)) { |
| Juan Cespedes | 7186e2a | 2003-01-31 19:56:34 +0100 | [diff] [blame] | 230 | keep = opt_e_enable; |
| 231 | } |
| 232 | tmp2 = tmp2->next; |
| 233 | } |
| 234 | if (!keep) { |
| 235 | *tmp1 = (*tmp1)->next; |
| 236 | } else { |
| 237 | tmp1 = &((*tmp1)->next); |
| 238 | } |
| 239 | } |
| 240 | } |
| Juan Cespedes | 7186e2a | 2003-01-31 19:56:34 +0100 | [diff] [blame] | 241 | } |
| Petr Machata | c7585b6 | 2011-07-08 22:58:12 +0200 | [diff] [blame] | 242 | |
| 243 | for (sym = proc->list_of_symbols; sym; sym = sym->next) |
| 244 | insert_breakpoint(proc, sym2addr(proc, sym), sym, enable); |
| 245 | |
| Juan Cespedes | 7186e2a | 2003-01-31 19:56:34 +0100 | [diff] [blame] | 246 | proc->callstack_depth = 0; |
| 247 | proc->breakpoints_enabled = -1; |
| Petr Machata | 1974dbc | 2011-08-19 18:58:01 +0200 | [diff] [blame] | 248 | return 0; |
| Juan Cespedes | 7186e2a | 2003-01-31 19:56:34 +0100 | [diff] [blame] | 249 | } |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 250 | |
| Juan Cespedes | f135052 | 2008-12-16 18:19:58 +0100 | [diff] [blame] | 251 | void |
| Juan Cespedes | a8909f7 | 2009-04-28 20:02:41 +0200 | [diff] [blame] | 252 | reinitialize_breakpoints(Process *proc) { |
| Juan Cespedes | cd8976d | 2009-05-14 13:47:58 +0200 | [diff] [blame] | 253 | struct library_symbol *sym; |
| 254 | |
| 255 | debug(DEBUG_FUNCTION, "reinitialize_breakpoints(pid=%d)", proc->pid); |
| 256 | |
| 257 | sym = proc->list_of_symbols; |
| Ian Wienand | 9a2ad35 | 2006-02-20 22:44:45 +0100 | [diff] [blame] | 258 | |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 259 | while (sym) { |
| 260 | if (sym->needs_init) { |
| Petr Machata | c7585b6 | 2011-07-08 22:58:12 +0200 | [diff] [blame] | 261 | insert_breakpoint(proc, sym2addr(proc, sym), sym, 1); |
| Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 262 | if (sym->needs_init && !sym->is_weak) { |
| 263 | fprintf(stderr, |
| 264 | "could not re-initialize breakpoint for \"%s\" in file \"%s\"\n", |
| 265 | sym->name, proc->filename); |
| 266 | exit(1); |
| 267 | } |
| 268 | } |
| 269 | sym = sym->next; |
| 270 | } |
| 271 | } |