| Juan Cespedes | d44c6b8 | 1998-09-25 14:48:42 +0200 | [diff] [blame] | 1 | #if HAVE_CONFIG_H |
| 2 | #include "config.h" |
| 3 | #endif |
| 4 | |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 5 | #define _GNU_SOURCE |
| 6 | #include <stdio.h> |
| 7 | #include <string.h> |
| Juan Cespedes | 1fe93d5 | 1998-03-13 00:29:21 +0100 | [diff] [blame] | 8 | #include <stdlib.h> |
| Juan Cespedes | 28f6019 | 1998-04-12 00:04:39 +0200 | [diff] [blame] | 9 | #include <signal.h> |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 10 | #include <assert.h> |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 11 | |
| 12 | #include "ltrace.h" |
| 13 | #include "output.h" |
| 14 | #include "options.h" |
| Juan Cespedes | 81690ef | 1998-03-13 19:31:29 +0100 | [diff] [blame] | 15 | #include "elf.h" |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame^] | 16 | #include "debug.h" |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 17 | |
| Juan Cespedes | f1bfe20 | 2002-03-27 00:22:23 +0100 | [diff] [blame] | 18 | #ifdef __powerpc__ |
| 19 | #include <sys/ptrace.h> |
| 20 | #endif |
| 21 | |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 22 | static void process_signal(struct event * event); |
| 23 | static void process_exit(struct event * event); |
| 24 | static void process_exit_signal(struct event * event); |
| 25 | static void process_syscall(struct event * event); |
| 26 | static void process_sysret(struct event * event); |
| 27 | static void process_breakpoint(struct event * event); |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 28 | static void remove_proc(struct process * proc); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 29 | |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 30 | static void callstack_push_syscall(struct process * proc, int sysnum); |
| 31 | static void callstack_push_symfunc(struct process * proc, struct library_symbol * sym); |
| 32 | static void callstack_pop(struct process * proc); |
| 33 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 34 | void |
| 35 | process_event(struct event * event) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 36 | switch (event->thing) { |
| 37 | case LT_EV_NONE: |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame^] | 38 | debug(1, "event: none"); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 39 | return; |
| 40 | case LT_EV_SIGNAL: |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame^] | 41 | debug(1, "event: signal (%d)", event->e_un.signum); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 42 | process_signal(event); |
| 43 | return; |
| 44 | case LT_EV_EXIT: |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame^] | 45 | debug(1, "event: exit (%d)", event->e_un.ret_val); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 46 | process_exit(event); |
| 47 | return; |
| 48 | case LT_EV_EXIT_SIGNAL: |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame^] | 49 | debug(1, "event: exit signal (%d)", event->e_un.signum); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 50 | process_exit_signal(event); |
| 51 | return; |
| 52 | case LT_EV_SYSCALL: |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame^] | 53 | debug(1, "event: syscall (%d)", event->e_un.sysnum); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 54 | process_syscall(event); |
| 55 | return; |
| 56 | case LT_EV_SYSRET: |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame^] | 57 | debug(1, "event: sysret (%d)", event->e_un.sysnum); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 58 | process_sysret(event); |
| 59 | return; |
| 60 | case LT_EV_BREAKPOINT: |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame^] | 61 | debug(1, "event: breakpoint"); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 62 | process_breakpoint(event); |
| 63 | return; |
| 64 | default: |
| 65 | fprintf(stderr, "Error! unknown event?\n"); |
| 66 | exit(1); |
| 67 | } |
| 68 | } |
| 69 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 70 | static char * |
| 71 | shortsignal(int signum) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 72 | static char * signalent0[] = { |
| 73 | #include "signalent.h" |
| 74 | }; |
| 75 | int nsignals0 = sizeof signalent0 / sizeof signalent0[0]; |
| 76 | |
| Juan Cespedes | 8cc1b9d | 2002-03-01 19:54:23 +0100 | [diff] [blame] | 77 | if (signum<0 || signum>=nsignals0) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 78 | return "UNKNOWN_SIGNAL"; |
| 79 | } else { |
| 80 | return signalent0[signum]; |
| 81 | } |
| 82 | } |
| 83 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 84 | static char * |
| 85 | sysname(int sysnum) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 86 | static char result[128]; |
| 87 | static char * syscalent0[] = { |
| 88 | #include "syscallent.h" |
| 89 | }; |
| 90 | int nsyscals0 = sizeof syscalent0 / sizeof syscalent0[0]; |
| 91 | |
| 92 | if (sysnum<0 || sysnum>nsyscals0) { |
| 93 | sprintf(result, "SYS_%d", sysnum); |
| 94 | return result; |
| 95 | } else { |
| 96 | sprintf(result, "SYS_%s", syscalent0[sysnum]); |
| 97 | return result; |
| 98 | } |
| 99 | } |
| 100 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 101 | static void |
| 102 | process_signal(struct event * event) { |
| Juan Cespedes | 28f6019 | 1998-04-12 00:04:39 +0200 | [diff] [blame] | 103 | if (exiting && event->e_un.signum == SIGSTOP) { |
| 104 | pid_t pid = event->proc->pid; |
| 105 | disable_all_breakpoints(event->proc); |
| 106 | untrace_pid(pid); |
| 107 | remove_proc(event->proc); |
| 108 | continue_after_signal(pid, event->e_un.signum); |
| 109 | return; |
| 110 | } |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 111 | output_line(event->proc, "--- %s (%s) ---", |
| 112 | shortsignal(event->e_un.signum), strsignal(event->e_un.signum)); |
| 113 | continue_after_signal(event->proc->pid, event->e_un.signum); |
| 114 | } |
| 115 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 116 | static void |
| 117 | process_exit(struct event * event) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 118 | output_line(event->proc, "+++ exited (status %d) +++", |
| 119 | event->e_un.ret_val); |
| Juan Cespedes | 1fe93d5 | 1998-03-13 00:29:21 +0100 | [diff] [blame] | 120 | remove_proc(event->proc); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 121 | } |
| 122 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 123 | static void |
| 124 | process_exit_signal(struct event * event) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 125 | output_line(event->proc, "+++ killed by %s +++", |
| 126 | shortsignal(event->e_un.signum)); |
| Juan Cespedes | 1fe93d5 | 1998-03-13 00:29:21 +0100 | [diff] [blame] | 127 | remove_proc(event->proc); |
| 128 | } |
| 129 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 130 | static void |
| 131 | remove_proc(struct process * proc) { |
| Juan Cespedes | 1fe93d5 | 1998-03-13 00:29:21 +0100 | [diff] [blame] | 132 | struct process *tmp, *tmp2; |
| 133 | |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame^] | 134 | debug(1, "Removing pid %u\n", proc->pid); |
| Juan Cespedes | 28f6019 | 1998-04-12 00:04:39 +0200 | [diff] [blame] | 135 | |
| Juan Cespedes | 1fe93d5 | 1998-03-13 00:29:21 +0100 | [diff] [blame] | 136 | if (list_of_processes == proc) { |
| 137 | tmp = list_of_processes; |
| 138 | list_of_processes = list_of_processes->next; |
| 139 | free(tmp); |
| 140 | return; |
| 141 | } |
| 142 | tmp = list_of_processes; |
| 143 | while(tmp->next) { |
| 144 | if (tmp->next==proc) { |
| 145 | tmp2 = tmp->next; |
| 146 | tmp->next = tmp->next->next; |
| 147 | free(tmp2); |
| Juan Cespedes | 28f6019 | 1998-04-12 00:04:39 +0200 | [diff] [blame] | 148 | continue; |
| Juan Cespedes | 1fe93d5 | 1998-03-13 00:29:21 +0100 | [diff] [blame] | 149 | } |
| Juan Cespedes | 35d7063 | 1998-03-15 14:05:40 +0100 | [diff] [blame] | 150 | tmp = tmp->next; |
| Juan Cespedes | 1fe93d5 | 1998-03-13 00:29:21 +0100 | [diff] [blame] | 151 | } |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 152 | } |
| 153 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 154 | static void |
| 155 | process_syscall(struct event * event) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 156 | if (opt_S) { |
| 157 | output_left(LT_TOF_SYSCALL, event->proc, sysname(event->e_un.sysnum)); |
| 158 | } |
| Juan Cespedes | 3f0b62e | 2001-07-09 01:02:52 +0200 | [diff] [blame] | 159 | callstack_push_syscall(event->proc, event->e_un.sysnum); |
| Juan Cespedes | 81690ef | 1998-03-13 19:31:29 +0100 | [diff] [blame] | 160 | if (fork_p(event->e_un.sysnum) || exec_p(event->e_un.sysnum)) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 161 | disable_all_breakpoints(event->proc); |
| Juan Cespedes | 81690ef | 1998-03-13 19:31:29 +0100 | [diff] [blame] | 162 | } else if (!event->proc->breakpoints_enabled) { |
| 163 | enable_all_breakpoints(event->proc); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 164 | } |
| 165 | continue_process(event->proc->pid); |
| 166 | } |
| 167 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 168 | static void |
| 169 | process_sysret(struct event * event) { |
| Juan Cespedes | 81690ef | 1998-03-13 19:31:29 +0100 | [diff] [blame] | 170 | if (exec_p(event->e_un.sysnum)) { |
| 171 | if (gimme_arg(LT_TOF_SYSCALL,event->proc,-1)==0) { |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 172 | |
| Juan Cespedes | 81690ef | 1998-03-13 19:31:29 +0100 | [diff] [blame] | 173 | event->proc->filename = pid2name(event->proc->pid); |
| 174 | event->proc->list_of_symbols = read_elf(event->proc->filename); |
| Juan Cespedes | 5916fda | 2002-02-25 00:19:21 +0100 | [diff] [blame] | 175 | |
| 176 | /* The kernel will stop the process just after an execve() |
| 177 | * and we will be able to enable breakpoints again |
| 178 | */ |
| Juan Cespedes | 53eabb1 | 2001-12-10 04:11:39 +0100 | [diff] [blame] | 179 | event->proc->breakpoints_enabled = -1; |
| Juan Cespedes | 81690ef | 1998-03-13 19:31:29 +0100 | [diff] [blame] | 180 | } |
| 181 | } |
| 182 | if (fork_p(event->e_un.sysnum)) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 183 | if (opt_f) { |
| Juan Cespedes | 273ea6d | 1998-03-14 23:02:40 +0100 | [diff] [blame] | 184 | pid_t child = gimme_arg(LT_TOF_SYSCALL,event->proc,-1); |
| 185 | if (child>0) { |
| 186 | open_pid(child, 0); |
| 187 | } |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 188 | } |
| Juan Cespedes | 35d7063 | 1998-03-15 14:05:40 +0100 | [diff] [blame] | 189 | enable_all_breakpoints(event->proc); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 190 | } |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 191 | callstack_pop(event->proc); |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 192 | if (opt_S) { |
| 193 | output_right(LT_TOF_SYSCALL, event->proc, sysname(event->e_un.sysnum)); |
| 194 | } |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 195 | continue_process(event->proc->pid); |
| 196 | } |
| 197 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 198 | static void |
| 199 | process_breakpoint(struct event * event) { |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 200 | struct library_symbol * tmp; |
| Juan Cespedes | 5916fda | 2002-02-25 00:19:21 +0100 | [diff] [blame] | 201 | int i,j; |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 202 | |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame^] | 203 | debug(2, "event: breakpoint (0x%08x)", event->e_un.brk_addr); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 204 | if (event->proc->breakpoint_being_enabled) { |
| Juan Cespedes | b1dd77d | 2002-03-03 00:22:06 +0100 | [diff] [blame] | 205 | /* Reinsert breakpoint */ |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 206 | continue_enabling_breakpoint(event->proc->pid, event->proc->breakpoint_being_enabled); |
| 207 | event->proc->breakpoint_being_enabled = NULL; |
| 208 | return; |
| 209 | } |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 210 | |
| Juan Cespedes | 5916fda | 2002-02-25 00:19:21 +0100 | [diff] [blame] | 211 | for(i=event->proc->callstack_depth-1; i>=0; i--) { |
| 212 | if (event->e_un.brk_addr == event->proc->callstack[i].return_addr) { |
| Juan Cespedes | 5bfb061 | 2002-03-31 20:01:28 +0200 | [diff] [blame] | 213 | #ifdef __powerpc__ |
| 214 | unsigned long a; |
| 215 | unsigned long addr = event->proc->callstack[i].c_un.libfunc->enter_addr; |
| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame^] | 216 | struct breakpoint *sbp = address2bpstruct(event->proc, addr); |
| Juan Cespedes | 5bfb061 | 2002-03-31 20:01:28 +0200 | [diff] [blame] | 217 | unsigned char break_insn[] = BREAKPOINT_VALUE; |
| 218 | |
| 219 | /* |
| 220 | * PPC HACK! (XXX FIXME TODO) |
| 221 | * The PLT gets modified during the first call, |
| 222 | * so be sure to re-enable the breakpoint. |
| 223 | */ |
| 224 | a = ptrace(PTRACE_PEEKTEXT, event->proc->pid, addr); |
| 225 | |
| 226 | if (memcmp(&a, break_insn, 4)) { |
| 227 | sbp->enabled--; |
| 228 | insert_breakpoint(event->proc, addr); |
| 229 | } |
| 230 | #endif |
| Juan Cespedes | 5916fda | 2002-02-25 00:19:21 +0100 | [diff] [blame] | 231 | for(j=event->proc->callstack_depth-1; j>=i; j--) { |
| 232 | callstack_pop(event->proc); |
| 233 | } |
| 234 | event->proc->return_addr = event->e_un.brk_addr; |
| 235 | output_right(LT_TOF_FUNCTION, event->proc, |
| 236 | event->proc->callstack[i].c_un.libfunc->name); |
| 237 | continue_after_breakpoint(event->proc, |
| 238 | address2bpstruct(event->proc, event->e_un.brk_addr)); |
| 239 | return; |
| 240 | } |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | tmp = event->proc->list_of_symbols; |
| 244 | while(tmp) { |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 245 | if (event->e_un.brk_addr == tmp->enter_addr) { |
| Juan Cespedes | 3f0b62e | 2001-07-09 01:02:52 +0200 | [diff] [blame] | 246 | event->proc->stack_pointer = get_stack_pointer(event->proc->pid); |
| 247 | event->proc->return_addr = get_return_addr(event->proc->pid, event->proc->stack_pointer); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 248 | output_left(LT_TOF_FUNCTION, event->proc, tmp->name); |
| Juan Cespedes | 3f0b62e | 2001-07-09 01:02:52 +0200 | [diff] [blame] | 249 | callstack_push_symfunc(event->proc, tmp); |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 250 | continue_after_breakpoint(event->proc, address2bpstruct(event->proc, tmp->enter_addr)); |
| Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 251 | return; |
| 252 | } |
| 253 | tmp = tmp->next; |
| 254 | } |
| 255 | output_line(event->proc, "breakpointed at 0x%08x (?)", |
| 256 | (unsigned)event->e_un.brk_addr); |
| 257 | continue_process(event->proc->pid); |
| 258 | } |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 259 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 260 | static void |
| 261 | callstack_push_syscall(struct process * proc, int sysnum) { |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 262 | struct callstack_element * elem; |
| 263 | |
| 264 | /* FIXME: not good -- should use dynamic allocation. 19990703 mortene. */ |
| 265 | if (proc->callstack_depth == MAX_CALLDEPTH-1) { |
| 266 | fprintf(stderr, "Error: call nesting too deep!\n"); |
| 267 | return; |
| 268 | } |
| 269 | |
| 270 | elem = & proc->callstack[proc->callstack_depth]; |
| 271 | elem->is_syscall = 1; |
| 272 | elem->c_un.syscall = sysnum; |
| 273 | elem->return_addr = NULL; |
| 274 | |
| 275 | proc->callstack_depth++; |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 276 | } |
| 277 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 278 | static void |
| 279 | callstack_push_symfunc(struct process * proc, struct library_symbol * sym) { |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 280 | struct callstack_element * elem; |
| 281 | |
| 282 | /* FIXME: not good -- should use dynamic allocation. 19990703 mortene. */ |
| 283 | if (proc->callstack_depth == MAX_CALLDEPTH-1) { |
| 284 | fprintf(stderr, "Error: call nesting too deep!\n"); |
| 285 | return; |
| 286 | } |
| 287 | |
| 288 | elem = & proc->callstack[proc->callstack_depth]; |
| 289 | elem->is_syscall = 0; |
| 290 | elem->c_un.libfunc = sym; |
| 291 | |
| Juan Cespedes | 3f0b62e | 2001-07-09 01:02:52 +0200 | [diff] [blame] | 292 | elem->return_addr = proc->return_addr; |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 293 | insert_breakpoint(proc, elem->return_addr); |
| 294 | |
| 295 | proc->callstack_depth++; |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 296 | } |
| 297 | |
| Juan Cespedes | 21c63a1 | 2001-07-07 20:56:56 +0200 | [diff] [blame] | 298 | static void |
| 299 | callstack_pop(struct process * proc) { |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 300 | struct callstack_element * elem; |
| 301 | assert(proc->callstack_depth > 0); |
| 302 | |
| 303 | elem = & proc->callstack[proc->callstack_depth-1]; |
| 304 | if (!elem->is_syscall) { |
| 305 | delete_breakpoint(proc, elem->return_addr); |
| 306 | } |
| 307 | proc->callstack_depth--; |
| Juan Cespedes | 5b3ffdf | 2001-07-02 00:52:45 +0200 | [diff] [blame] | 308 | } |