mirror of
https://github.com/AetherDroid/android_kernel_samsung_on5xelte.git
synced 2025-10-29 23:28:52 +01:00
Fixed MTP to work with TWRP
This commit is contained in:
commit
f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions
1023
tools/perf/ui/browsers/annotate.c
Normal file
1023
tools/perf/ui/browsers/annotate.c
Normal file
File diff suppressed because it is too large
Load diff
128
tools/perf/ui/browsers/header.c
Normal file
128
tools/perf/ui/browsers/header.c
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
#include "util/cache.h"
|
||||
#include "util/debug.h"
|
||||
#include "ui/browser.h"
|
||||
#include "ui/keysyms.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/util.h"
|
||||
#include "ui/libslang.h"
|
||||
#include "util/header.h"
|
||||
#include "util/session.h"
|
||||
|
||||
static void ui_browser__argv_write(struct ui_browser *browser,
|
||||
void *entry, int row)
|
||||
{
|
||||
char **arg = entry;
|
||||
char *str = *arg;
|
||||
char empty[] = " ";
|
||||
bool current_entry = ui_browser__is_current_entry(browser, row);
|
||||
unsigned long offset = (unsigned long)browser->priv;
|
||||
|
||||
if (offset >= strlen(str))
|
||||
str = empty;
|
||||
else
|
||||
str = str + offset;
|
||||
|
||||
ui_browser__set_color(browser, current_entry ? HE_COLORSET_SELECTED :
|
||||
HE_COLORSET_NORMAL);
|
||||
|
||||
slsmg_write_nstring(str, browser->width);
|
||||
}
|
||||
|
||||
static int list_menu__run(struct ui_browser *menu)
|
||||
{
|
||||
int key;
|
||||
unsigned long offset;
|
||||
const char help[] =
|
||||
"h/?/F1 Show this window\n"
|
||||
"UP/DOWN/PGUP\n"
|
||||
"PGDN/SPACE\n"
|
||||
"LEFT/RIGHT Navigate\n"
|
||||
"q/ESC/CTRL+C Exit browser";
|
||||
|
||||
if (ui_browser__show(menu, "Header information", "Press 'q' to exit") < 0)
|
||||
return -1;
|
||||
|
||||
while (1) {
|
||||
key = ui_browser__run(menu, 0);
|
||||
|
||||
switch (key) {
|
||||
case K_RIGHT:
|
||||
offset = (unsigned long)menu->priv;
|
||||
offset += 10;
|
||||
menu->priv = (void *)offset;
|
||||
continue;
|
||||
case K_LEFT:
|
||||
offset = (unsigned long)menu->priv;
|
||||
if (offset >= 10)
|
||||
offset -= 10;
|
||||
menu->priv = (void *)offset;
|
||||
continue;
|
||||
case K_F1:
|
||||
case 'h':
|
||||
case '?':
|
||||
ui_browser__help_window(menu, help);
|
||||
continue;
|
||||
case K_ESC:
|
||||
case 'q':
|
||||
case CTRL('c'):
|
||||
key = -1;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
ui_browser__hide(menu);
|
||||
return key;
|
||||
}
|
||||
|
||||
static int ui__list_menu(int argc, char * const argv[])
|
||||
{
|
||||
struct ui_browser menu = {
|
||||
.entries = (void *)argv,
|
||||
.refresh = ui_browser__argv_refresh,
|
||||
.seek = ui_browser__argv_seek,
|
||||
.write = ui_browser__argv_write,
|
||||
.nr_entries = argc,
|
||||
};
|
||||
|
||||
return list_menu__run(&menu);
|
||||
}
|
||||
|
||||
int tui__header_window(struct perf_session_env *env)
|
||||
{
|
||||
int i, argc = 0;
|
||||
char **argv;
|
||||
struct perf_session *session;
|
||||
char *ptr, *pos;
|
||||
size_t size;
|
||||
FILE *fp = open_memstream(&ptr, &size);
|
||||
|
||||
session = container_of(env, struct perf_session, header.env);
|
||||
perf_header__fprintf_info(session, fp, true);
|
||||
fclose(fp);
|
||||
|
||||
for (pos = ptr, argc = 0; (pos = strchr(pos, '\n')) != NULL; pos++)
|
||||
argc++;
|
||||
|
||||
argv = calloc(argc + 1, sizeof(*argv));
|
||||
if (argv == NULL)
|
||||
goto out;
|
||||
|
||||
argv[0] = pos = ptr;
|
||||
for (i = 1; (pos = strchr(pos, '\n')) != NULL; i++) {
|
||||
*pos++ = '\0';
|
||||
argv[i] = pos;
|
||||
}
|
||||
|
||||
BUG_ON(i != argc + 1);
|
||||
|
||||
ui__list_menu(argc, argv);
|
||||
|
||||
out:
|
||||
free(argv);
|
||||
free(ptr);
|
||||
return 0;
|
||||
}
|
||||
2028
tools/perf/ui/browsers/hists.c
Normal file
2028
tools/perf/ui/browsers/hists.c
Normal file
File diff suppressed because it is too large
Load diff
130
tools/perf/ui/browsers/map.c
Normal file
130
tools/perf/ui/browsers/map.c
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
#include "../libslang.h"
|
||||
#include <elf.h>
|
||||
#include <inttypes.h>
|
||||
#include <sys/ttydefaults.h>
|
||||
#include <string.h>
|
||||
#include <linux/bitops.h>
|
||||
#include "../../util/util.h"
|
||||
#include "../../util/debug.h"
|
||||
#include "../../util/symbol.h"
|
||||
#include "../browser.h"
|
||||
#include "../helpline.h"
|
||||
#include "../keysyms.h"
|
||||
#include "map.h"
|
||||
|
||||
struct map_browser {
|
||||
struct ui_browser b;
|
||||
struct map *map;
|
||||
u8 addrlen;
|
||||
};
|
||||
|
||||
static void map_browser__write(struct ui_browser *browser, void *nd, int row)
|
||||
{
|
||||
struct symbol *sym = rb_entry(nd, struct symbol, rb_node);
|
||||
struct map_browser *mb = container_of(browser, struct map_browser, b);
|
||||
bool current_entry = ui_browser__is_current_entry(browser, row);
|
||||
int width;
|
||||
|
||||
ui_browser__set_percent_color(browser, 0, current_entry);
|
||||
slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ",
|
||||
mb->addrlen, sym->start, mb->addrlen, sym->end,
|
||||
sym->binding == STB_GLOBAL ? 'g' :
|
||||
sym->binding == STB_LOCAL ? 'l' : 'w');
|
||||
width = browser->width - ((mb->addrlen * 2) + 4);
|
||||
if (width > 0)
|
||||
slsmg_write_nstring(sym->name, width);
|
||||
}
|
||||
|
||||
/* FIXME uber-kludgy, see comment on cmd_report... */
|
||||
static u32 *symbol__browser_index(struct symbol *browser)
|
||||
{
|
||||
return ((void *)browser) - sizeof(struct rb_node) - sizeof(u32);
|
||||
}
|
||||
|
||||
static int map_browser__search(struct map_browser *browser)
|
||||
{
|
||||
char target[512];
|
||||
struct symbol *sym;
|
||||
int err = ui_browser__input_window("Search by name/addr",
|
||||
"Prefix with 0x to search by address",
|
||||
target, "ENTER: OK, ESC: Cancel", 0);
|
||||
if (err != K_ENTER)
|
||||
return -1;
|
||||
|
||||
if (target[0] == '0' && tolower(target[1]) == 'x') {
|
||||
u64 addr = strtoull(target, NULL, 16);
|
||||
sym = map__find_symbol(browser->map, addr, NULL);
|
||||
} else
|
||||
sym = map__find_symbol_by_name(browser->map, target, NULL);
|
||||
|
||||
if (sym != NULL) {
|
||||
u32 *idx = symbol__browser_index(sym);
|
||||
|
||||
browser->b.top = &sym->rb_node;
|
||||
browser->b.index = browser->b.top_idx = *idx;
|
||||
} else
|
||||
ui_helpline__fpush("%s not found!", target);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int map_browser__run(struct map_browser *browser)
|
||||
{
|
||||
int key;
|
||||
|
||||
if (ui_browser__show(&browser->b, browser->map->dso->long_name,
|
||||
"Press <- or ESC to exit, %s / to search",
|
||||
verbose ? "" : "restart with -v to use") < 0)
|
||||
return -1;
|
||||
|
||||
while (1) {
|
||||
key = ui_browser__run(&browser->b, 0);
|
||||
|
||||
switch (key) {
|
||||
case '/':
|
||||
if (verbose)
|
||||
map_browser__search(browser);
|
||||
default:
|
||||
break;
|
||||
case K_LEFT:
|
||||
case K_ESC:
|
||||
case 'q':
|
||||
case CTRL('c'):
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
out:
|
||||
ui_browser__hide(&browser->b);
|
||||
return key;
|
||||
}
|
||||
|
||||
int map__browse(struct map *map)
|
||||
{
|
||||
struct map_browser mb = {
|
||||
.b = {
|
||||
.entries = &map->dso->symbols[map->type],
|
||||
.refresh = ui_browser__rb_tree_refresh,
|
||||
.seek = ui_browser__rb_tree_seek,
|
||||
.write = map_browser__write,
|
||||
},
|
||||
.map = map,
|
||||
};
|
||||
struct rb_node *nd;
|
||||
char tmp[BITS_PER_LONG / 4];
|
||||
u64 maxaddr = 0;
|
||||
|
||||
for (nd = rb_first(mb.b.entries); nd; nd = rb_next(nd)) {
|
||||
struct symbol *pos = rb_entry(nd, struct symbol, rb_node);
|
||||
|
||||
if (maxaddr < pos->end)
|
||||
maxaddr = pos->end;
|
||||
if (verbose) {
|
||||
u32 *idx = symbol__browser_index(pos);
|
||||
*idx = mb.b.nr_entries;
|
||||
}
|
||||
++mb.b.nr_entries;
|
||||
}
|
||||
|
||||
mb.addrlen = snprintf(tmp, sizeof(tmp), "%" PRIx64, maxaddr);
|
||||
return map_browser__run(&mb);
|
||||
}
|
||||
6
tools/perf/ui/browsers/map.h
Normal file
6
tools/perf/ui/browsers/map.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef _PERF_UI_MAP_BROWSER_H_
|
||||
#define _PERF_UI_MAP_BROWSER_H_ 1
|
||||
struct map;
|
||||
|
||||
int map__browse(struct map *map);
|
||||
#endif /* _PERF_UI_MAP_BROWSER_H_ */
|
||||
187
tools/perf/ui/browsers/scripts.c
Normal file
187
tools/perf/ui/browsers/scripts.c
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
#include <elf.h>
|
||||
#include <inttypes.h>
|
||||
#include <sys/ttydefaults.h>
|
||||
#include <string.h>
|
||||
#include "../../util/sort.h"
|
||||
#include "../../util/util.h"
|
||||
#include "../../util/hist.h"
|
||||
#include "../../util/debug.h"
|
||||
#include "../../util/symbol.h"
|
||||
#include "../browser.h"
|
||||
#include "../helpline.h"
|
||||
#include "../libslang.h"
|
||||
|
||||
/* 2048 lines should be enough for a script output */
|
||||
#define MAX_LINES 2048
|
||||
|
||||
/* 160 bytes for one output line */
|
||||
#define AVERAGE_LINE_LEN 160
|
||||
|
||||
struct script_line {
|
||||
struct list_head node;
|
||||
char line[AVERAGE_LINE_LEN];
|
||||
};
|
||||
|
||||
struct perf_script_browser {
|
||||
struct ui_browser b;
|
||||
struct list_head entries;
|
||||
const char *script_name;
|
||||
int nr_lines;
|
||||
};
|
||||
|
||||
#define SCRIPT_NAMELEN 128
|
||||
#define SCRIPT_MAX_NO 64
|
||||
/*
|
||||
* Usually the full path for a script is:
|
||||
* /home/username/libexec/perf-core/scripts/python/xxx.py
|
||||
* /home/username/libexec/perf-core/scripts/perl/xxx.pl
|
||||
* So 256 should be long enough to contain the full path.
|
||||
*/
|
||||
#define SCRIPT_FULLPATH_LEN 256
|
||||
|
||||
/*
|
||||
* When success, will copy the full path of the selected script
|
||||
* into the buffer pointed by script_name, and return 0.
|
||||
* Return -1 on failure.
|
||||
*/
|
||||
static int list_scripts(char *script_name)
|
||||
{
|
||||
char *buf, *names[SCRIPT_MAX_NO], *paths[SCRIPT_MAX_NO];
|
||||
int i, num, choice, ret = -1;
|
||||
|
||||
/* Preset the script name to SCRIPT_NAMELEN */
|
||||
buf = malloc(SCRIPT_MAX_NO * (SCRIPT_NAMELEN + SCRIPT_FULLPATH_LEN));
|
||||
if (!buf)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < SCRIPT_MAX_NO; i++) {
|
||||
names[i] = buf + i * (SCRIPT_NAMELEN + SCRIPT_FULLPATH_LEN);
|
||||
paths[i] = names[i] + SCRIPT_NAMELEN;
|
||||
}
|
||||
|
||||
num = find_scripts(names, paths);
|
||||
if (num > 0) {
|
||||
choice = ui__popup_menu(num, names);
|
||||
if (choice < num && choice >= 0) {
|
||||
strcpy(script_name, paths[choice]);
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void script_browser__write(struct ui_browser *browser,
|
||||
void *entry, int row)
|
||||
{
|
||||
struct script_line *sline = list_entry(entry, struct script_line, node);
|
||||
bool current_entry = ui_browser__is_current_entry(browser, row);
|
||||
|
||||
ui_browser__set_color(browser, current_entry ? HE_COLORSET_SELECTED :
|
||||
HE_COLORSET_NORMAL);
|
||||
|
||||
slsmg_write_nstring(sline->line, browser->width);
|
||||
}
|
||||
|
||||
static int script_browser__run(struct perf_script_browser *browser)
|
||||
{
|
||||
int key;
|
||||
|
||||
if (ui_browser__show(&browser->b, browser->script_name,
|
||||
"Press <- or ESC to exit") < 0)
|
||||
return -1;
|
||||
|
||||
while (1) {
|
||||
key = ui_browser__run(&browser->b, 0);
|
||||
|
||||
/* We can add some special key handling here if needed */
|
||||
break;
|
||||
}
|
||||
|
||||
ui_browser__hide(&browser->b);
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
int script_browse(const char *script_opt)
|
||||
{
|
||||
char cmd[SCRIPT_FULLPATH_LEN*2], script_name[SCRIPT_FULLPATH_LEN];
|
||||
char *line = NULL;
|
||||
size_t len = 0;
|
||||
ssize_t retlen;
|
||||
int ret = -1, nr_entries = 0;
|
||||
FILE *fp;
|
||||
void *buf;
|
||||
struct script_line *sline;
|
||||
|
||||
struct perf_script_browser script = {
|
||||
.b = {
|
||||
.refresh = ui_browser__list_head_refresh,
|
||||
.seek = ui_browser__list_head_seek,
|
||||
.write = script_browser__write,
|
||||
},
|
||||
.script_name = script_name,
|
||||
};
|
||||
|
||||
INIT_LIST_HEAD(&script.entries);
|
||||
|
||||
/* Save each line of the output in one struct script_line object. */
|
||||
buf = zalloc((sizeof(*sline)) * MAX_LINES);
|
||||
if (!buf)
|
||||
return -1;
|
||||
sline = buf;
|
||||
|
||||
memset(script_name, 0, SCRIPT_FULLPATH_LEN);
|
||||
if (list_scripts(script_name))
|
||||
goto exit;
|
||||
|
||||
sprintf(cmd, "perf script -s %s ", script_name);
|
||||
|
||||
if (script_opt)
|
||||
strcat(cmd, script_opt);
|
||||
|
||||
if (input_name) {
|
||||
strcat(cmd, " -i ");
|
||||
strcat(cmd, input_name);
|
||||
}
|
||||
|
||||
strcat(cmd, " 2>&1");
|
||||
|
||||
fp = popen(cmd, "r");
|
||||
if (!fp)
|
||||
goto exit;
|
||||
|
||||
while ((retlen = getline(&line, &len, fp)) != -1) {
|
||||
strncpy(sline->line, line, AVERAGE_LINE_LEN);
|
||||
|
||||
/* If one output line is very large, just cut it short */
|
||||
if (retlen >= AVERAGE_LINE_LEN) {
|
||||
sline->line[AVERAGE_LINE_LEN - 1] = '\0';
|
||||
sline->line[AVERAGE_LINE_LEN - 2] = '\n';
|
||||
}
|
||||
list_add_tail(&sline->node, &script.entries);
|
||||
|
||||
if (script.b.width < retlen)
|
||||
script.b.width = retlen;
|
||||
|
||||
if (nr_entries++ >= MAX_LINES - 1)
|
||||
break;
|
||||
sline++;
|
||||
}
|
||||
|
||||
if (script.b.width > AVERAGE_LINE_LEN)
|
||||
script.b.width = AVERAGE_LINE_LEN;
|
||||
|
||||
free(line);
|
||||
pclose(fp);
|
||||
|
||||
script.nr_lines = nr_entries;
|
||||
script.b.nr_entries = nr_entries;
|
||||
script.b.entries = &script.entries;
|
||||
|
||||
ret = script_browser__run(&script);
|
||||
exit:
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue