Exemplo n.º 1
0
static int merge_cluster_tables(void)
{
	int i, j, k = 0, count = 1;
	struct cpufreq_frequency_table *table;

	for (i = 0; i < MAX_CLUSTERS; i++)
		count += get_table_count(freq_table[i]);

	table = kzalloc(sizeof(*table) * count, GFP_KERNEL);
	if (!table)
		return -ENOMEM;

	freq_table[MAX_CLUSTERS] = table;

	/* Add in reverse order to get freqs in increasing order */
	for (i = MAX_CLUSTERS - 1; i >= 0; i--) {
		for (j = 0; freq_table[i][j].frequency != CPUFREQ_TABLE_END;
				j++) {
			table[k].frequency = VIRT_FREQ(i,
					freq_table[i][j].frequency);
			pr_debug("%s: index: %d, freq: %d\n", __func__, k,
					table[k].frequency);
			k++;
		}
	}

	table[k].driver_data = k;
	table[k].frequency = CPUFREQ_TABLE_END;

	pr_debug("%s: End, table: %p, count: %d\n", __func__, table, k);

	return 0;
}
Exemplo n.º 2
0
/*=============================================+
 * disp_table -- Display table contents
 *  used for drilldown in variable debugger
 *  tab:  table to display
 *============================================*/
static void
disp_table (TABLE tab)
{
	struct dbgsymtab_s sdata;
	INT nels = get_table_count(tab);
	if (!nels) {
		msg_info(_("table is empty"));
		return;
	}
	init_dbgsymtab_arrays(&sdata, nels);

	/* loop thru table building display array */
	{
		TABLE_ITER tabit = begin_table_iter(tab);
		STRING key=0;
		VPTR ptr = 0;
		while (next_table_ptr(tabit, &key, &ptr)) {
			PVALUE val = ptr;
			format_dbgsymtab_val(key, val, &sdata);
		}
		end_table_iter(&tabit);
	}
	

	disp_dbgsymtab(_("TABLE contents"), &sdata);

	free_dbgsymtab_arrays(&sdata);
}
Exemplo n.º 3
0
/*====================================================
 * disp_symtab -- Display contents of a symbol table
 *  This is part of the report language debugger
 *==================================================*/
static void
disp_symtab (STRING title, SYMTAB stab)
{
	SYMTAB_ITER symtabit=0;
	INT nels = (stab->tab ? get_table_count(stab->tab) : 0);
	struct dbgsymtab_s sdata;
	if (!nels) return;
	init_dbgsymtab_arrays(&sdata, nels);
	/* Now traverse & print the actual entries into string array
	(sdata.locals) via format_dbgsymtab_val() */
	symtabit = begin_symtab_iter(stab);
	if (symtabit) {
		STRING key=0;
		PVALUE val=0;
		while (next_symtab_entry(symtabit, (CNSTRING *)&key, &val)) {
			format_dbgsymtab_val(key, val, &sdata);
		}
		end_symtab_iter(&symtabit);
	}
	disp_dbgsymtab(title, &sdata);
	free_dbgsymtab_arrays(&sdata);
}
Exemplo n.º 4
0
/*=============================================+
 * prog_var_error_zstr -- Report a run time program error
 *  node:  [IN]  current parse node
 *  stab:  [IN]  current symbol table (lexical scope)
 *  arg:   [IN]  if non-null, parse node of troublesome argument
 *  val:   [IN]  if non-null, PVALUE of troublesome argument
 *  zstr:  [IN]  message
 *
 * Inline debugger is implemented here
 * See vprog_error
 * Created: 2002/02/17, Perry Rapp
 *============================================*/
static void
prog_var_error_zstr (PNODE node, SYMTAB stab, PNODE arg, PVALUE val, ZSTR zstr)
{
	STRING choices[5];
	INT rtn=0;
	SYMTAB curstab = stab; /* currently displayed symbol table */
	INT nlevels=0; /* number frames on callstack */
	INT curlevel=0; /* 0 is lowest */

	ASSERT(zstr);

	if (val) {
		ZSTR zval = describe_pvalue(val);
		zs_appf(zstr, " (value: %s)", zs_str(zval));
	} else if (arg) {
		INT max=40 + zs_len(zstr); /* not too much argument description */
		/* arg isn't evaluated, but describe will at least give its type */
		zs_apps(zstr, " (arg: ");
		describe_pnode(arg, zstr, max);
		zs_apps(zstr, ")");
	}
	prog_error(node, zs_str(zstr));
	zs_free(&zstr);

	if (dbg_mode != -99 && dbg_mode != 3) {
		INT ch = 0;
		while (!(ch=='d' || ch=='q'))
			ch = rptui_prompt_stdout(_("Enter d for debugger, q to quit"));
		if (ch == 'q')
			dbg_mode = -99;
	}

	/* call stack size & location */
	nlevels = count_symtab_ancestors(stab) + 1;
	curlevel = 0;

	/* report debugger loop */
	while (dbg_mode != -99) {
		ZSTR zstr=zs_new();
		INT n=0;
		/* 0: display local variable(s) */
		n = (curstab->tab ? get_table_count(curstab->tab) : 0);
		zs_setf(zstr, _pl("Display local (%d var)",
			"Display locals (%d vars)", n), n);
		zs_appf(zstr, " [%s]", curstab->title);
		choices[0] = strsave(zs_str(zstr));
		/* 1: display global variables */
		n = (globtab->tab ? get_table_count(globtab->tab) : 0);
		zs_setf(zstr, _pl("Display global (%d var)",
			"Display globals (%d vars)", n), n);
		choices[1] = strsave(zs_str(zstr));
		/* 2: up call stack */
		n = nlevels - curlevel - 1;
		zs_setf(zstr, _pl("Call stack has %d higher level", "Call stack has %d higher levels", n), n);
		zs_apps(zstr, ". ");
		if (n > 0) {
			zs_apps(zstr, _(" Go up one level"));
			zs_appf(zstr, "(%s)", curstab->parent->title);
		}
		choices[2] = strsave(zs_str(zstr));
		/* 3: down call stack */
		n = curlevel;
		zs_setf(zstr, _pl("Call stack has %d lower level", "Call stack has %d lower levels", n), n);
		zs_apps(zstr, ". ");
		if (n > 0) {
			CNSTRING title = get_symtab_ancestor(stab, n-1)->title;
			zs_apps(zstr, _(" Go down one level"));
			zs_appf(zstr, "(%s)", title);
		}
		choices[3] = strsave(zs_str(zstr));
		/* quit */
		choices[4] = strsave(_("Quit debugger"));
dbgloop:
		rtn = rptui_choose_from_array(_("Report debugger"), ARRSIZE(choices), choices);
		if (rtn == 4 || rtn == -1) {
			dbg_mode = -99;
		} else if (rtn == 0) {
			disp_symtab(_("Local variables"), curstab);
			goto dbgloop;
		} else if (rtn == 1) {
			disp_symtab(_("Global variables"), globtab);
			goto dbgloop;
		} else if (rtn == 2) {
			if (curlevel+1 < nlevels) {
				curstab = curstab->parent;
				++curlevel;
				ASSERT(curstab);
			}
		} else if (rtn == 3) {
			if (curlevel > 0) {
				curstab = get_symtab_ancestor(stab, curlevel-1);
				--curlevel;
				ASSERT(curstab);
			}
		}
		zs_free(&zstr);
		free_array_strings(ARRSIZE(choices), choices);
	}
}