aboutsummaryrefslogtreecommitdiff
path: root/breakpoints.c
blob: 883d7edab4c08e565a8e193de0b68387d88bfced (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#if HAVE_CONFIG_H
#include "config.h"
#endif

#include "ltrace.h"
#include "options.h"
#include "output.h"

void enable_all_breakpoints(struct process * proc)
{
	if (proc->breakpoints_enabled <= 0) {
		struct library_symbol * tmp = proc->list_of_symbols;

		if (opt_d>0) {
			output_line(0, "Enabling breakpoints for pid %u...", proc->pid);
		}
		while(tmp) {
			insert_breakpoint(proc->pid, &tmp->brk);
			tmp = tmp->next;
		}
		if (proc->current_symbol) {
			insert_breakpoint(proc->pid, &proc->return_value);
		}
	}
	proc->breakpoints_enabled = 1;
}

void disable_all_breakpoints(struct process * proc)
{
	if (proc->breakpoints_enabled) {
		struct library_symbol * tmp = proc->list_of_symbols;

		if (opt_d>0) {
			output_line(0, "Disabling breakpoints for pid %u...", proc->pid);
		}
		while(tmp) {
			delete_breakpoint(proc->pid, &tmp->brk);
			tmp = tmp->next;
		}
		if (proc->current_symbol) {
			delete_breakpoint(proc->pid, &proc->return_value);
		}
	}
	proc->breakpoints_enabled = 0;
}