mirror of https://gitee.com/openkylin/qemu.git
trace/simple: pass iter to st_write_event_mapping
Pass an iter to st_write_event_mapping, so the function can interate different things depending on how we initialize the iter. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 20210601132414.432430-5-kraxel@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
c5cc58b176
commit
3f2a09842f
|
@ -280,14 +280,12 @@ void trace_record_finish(TraceBufferRecord *rec)
|
|||
}
|
||||
}
|
||||
|
||||
static int st_write_event_mapping(void)
|
||||
static int st_write_event_mapping(TraceEventIter *iter)
|
||||
{
|
||||
uint64_t type = TRACE_RECORD_TYPE_MAPPING;
|
||||
TraceEventIter iter;
|
||||
TraceEvent *ev;
|
||||
|
||||
trace_event_iter_init_all(&iter);
|
||||
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
||||
while ((ev = trace_event_iter_next(iter)) != NULL) {
|
||||
uint64_t id = trace_event_get_id(ev);
|
||||
const char *name = trace_event_get_name(ev);
|
||||
uint32_t len = strlen(name);
|
||||
|
@ -309,6 +307,7 @@ static int st_write_event_mapping(void)
|
|||
*/
|
||||
bool st_set_trace_file_enabled(bool enable)
|
||||
{
|
||||
TraceEventIter iter;
|
||||
bool was_enabled = trace_fp;
|
||||
|
||||
if (enable == !!trace_fp) {
|
||||
|
@ -333,8 +332,9 @@ bool st_set_trace_file_enabled(bool enable)
|
|||
return was_enabled;
|
||||
}
|
||||
|
||||
trace_event_iter_init_all(&iter);
|
||||
if (fwrite(&header, sizeof header, 1, trace_fp) != 1 ||
|
||||
st_write_event_mapping() < 0) {
|
||||
st_write_event_mapping(&iter) < 0) {
|
||||
fclose(trace_fp);
|
||||
trace_fp = NULL;
|
||||
return was_enabled;
|
||||
|
|
Loading…
Reference in New Issue