blob: 6d978f7a7c6594c5989814ec50ee7487430bf263 [file] [log] [blame]
// Copyright (C) 2025 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import m from 'mithril';
import {MenuItem} from '../../widgets/menu';
import {Arg} from '../sql_utils/args';
import {Trace} from '../../public/trace';
import {renderArguments} from './args';
import {extensions} from '../extensions';
import {assertExists} from '../../base/logging';
import {getSqlTableDescription} from '../widgets/sql/table/sql_table_registry';
import {sqliteString} from '../../base/string_utils';
// Renders slice arguments (key/value pairs) as a subtree.
export function renderSliceArguments(
trace: Trace,
args: ReadonlyArray<Arg>,
): m.Children {
return renderArguments(trace, args, (arg) => {
return [
m(MenuItem, {
label: 'Find slices with same arg value',
icon: 'search',
onclick: () => {
extensions.addLegacySqlTableTab(trace, {
table: assertExists(getSqlTableDescription('slice')),
filters: [
{
op: (cols) => `${cols[0]} = ${sqliteString(arg.displayValue)}`,
columns: [
{
column: 'display_value',
source: {
table: 'args',
joinOn: {
arg_set_id: 'arg_set_id',
key: sqliteString(arg.flatKey),
},
},
},
],
},
],
});
},
}),
m(MenuItem, {
label: 'Visualize argument values',
icon: 'query_stats',
onclick: () => {
extensions.addVisualizedArgTracks(trace, arg.flatKey);
},
}),
];
});
}