Example #1
0
static void
process_bare_destroy(struct Process *proc, int was_exec)
{
	dict_clear(proc->breakpoints);
	if (!was_exec) {
		free(proc->filename);
		unlist_process(proc);
		destroy_unwind(proc);
	}
}
Example #2
0
void
remove_process(Process *proc)
{
	debug(DEBUG_FUNCTION, "remove_proc(pid=%d)", proc->pid);

	if (proc->leader == proc)
		each_task(proc, NULL, &clear_leader, NULL);

	unlist_process(proc);
	process_removed(proc);
	process_destroy(proc);
	free(proc);
}
Example #3
0
void
change_process_leader(Process * proc, Process * leader)
{
	Process ** leaderp = &list_of_processes;
	if (proc->leader == leader)
		return;

	assert(leader != NULL);
	unlist_process(proc);
	if (proc != leader)
		leaderp = &leader->next;

	proc->leader = leader;
	proc->next = *leaderp;
	*leaderp = proc;
}
Example #4
0
File: proc.c Project: jkkm/ltrace
static int
process_bare_init(struct process *proc, const char *filename,
		  pid_t pid, int was_exec)
{
	if (!was_exec) {
		memset(proc, 0, sizeof(*proc));

		proc->filename = strdup(filename);
		if (proc->filename == NULL) {
		fail:
			free(proc->filename);
			if (proc->breakpoints != NULL) {
				dict_destroy(proc->breakpoints,
					     NULL, NULL, NULL);
				free(proc->breakpoints);
				proc->breakpoints = NULL;
			}
			return -1;
		}
	}

	/* Add process so that we know who the leader is.  */
	proc->pid = pid;
	if (add_process(proc, was_exec) < 0)
		goto fail;
	if (proc->leader == NULL) {
	unlist_and_fail:
		if (!was_exec)
			unlist_process(proc);
		goto fail;
	}

	if (proc->leader == proc) {
		proc->breakpoints = malloc(sizeof(*proc->breakpoints));
		if (proc->breakpoints == NULL)
			goto unlist_and_fail;
		DICT_INIT(proc->breakpoints,
			  arch_addr_t, struct breakpoint *,
			  arch_addr_hash, arch_addr_eq, NULL);
	} else {