even more hover info

This commit is contained in:
silverweed 2024-07-30 00:03:35 +02:00
parent 4a2c23277d
commit 4fe4909cd9
5 changed files with 58 additions and 19 deletions

View file

@ -254,7 +254,7 @@ void gather_ntuple_metadata(Arena *arena, RMicroFileReader &reader, const RNTupl
}
internal
TFile_Data get_tfile_data(const Inspected_File &file)
TFile_Data get_tfile_data(const Inspected_File &file, String8 ntpl_name)
{
TFile_Data tfile_data{};
@ -272,7 +272,7 @@ TFile_Data get_tfile_data(const Inspected_File &file)
tfile_data.root_version_minor = (u16)version_minor;
tfile_data.root_version_patch = (u16)version_patch;
Root_File_Info root_file_info = get_root_file_info(file.name.c(), is_big_file);
Root_File_Info root_file_info = get_root_file_info(file.name.c(), ntpl_name.c(), is_big_file);
tfile_data.root_file_header_size = root_file_info.tfile_header_nbytes;
tfile_data.rng_root_file_obj.start = root_file_info.tfile_obj_seek;
tfile_data.rng_root_file_obj.len = root_file_info.tfile_obj_nbytes;
@ -286,29 +286,34 @@ TFile_Data get_tfile_data(const Inspected_File &file)
if (is_big_file) {
u64 info_seek_be;
memcpy(&info_seek_be, file.mem + root_file_info.info_seek_seek, sizeof(info_seek_be));
tfile_data.rng_root_file_info.start = bswap(info_seek_be);
tfile_data.rng_root_file_info_header.start = bswap(info_seek_be);
} else {
u32 info_seek_be;
memcpy(&info_seek_be, file.mem + root_file_info.info_seek_seek, sizeof(info_seek_be));
tfile_data.rng_root_file_info.start = bswap(info_seek_be);
tfile_data.rng_root_file_info_header.start = bswap(info_seek_be);
}
u32 info_nbytes_be;
memcpy(&info_nbytes_be, file.mem + root_file_info.info_nbytes_seek, sizeof(info_nbytes_be));
tfile_data.rng_root_file_info.len = bswap(info_nbytes_be);
tfile_data.rng_root_file_info_header.len = root_file_info.info_header_nbytes;
tfile_data.rng_root_file_info.start = tfile_data.rng_root_file_info_header.end();
tfile_data.rng_root_file_info.len = bswap(info_nbytes_be) - tfile_data.rng_root_file_info_header.len;
// parse free list
if (is_big_file) {
u64 free_seek_be;
memcpy(&free_seek_be, file.mem + root_file_info.free_seek_seek, sizeof(free_seek_be));
tfile_data.rng_root_file_free.start = bswap(free_seek_be);
tfile_data.rng_root_file_free_header.start = bswap(free_seek_be);
} else {
u32 free_seek_be;
memcpy(&free_seek_be, file.mem + root_file_info.free_seek_seek, sizeof(free_seek_be));
tfile_data.rng_root_file_free.start = bswap(free_seek_be);
tfile_data.rng_root_file_free_header.start = bswap(free_seek_be);
}
u32 free_nbytes_be;
memcpy(&free_nbytes_be, file.mem + root_file_info.free_nbytes_seek, sizeof(free_nbytes_be));
tfile_data.rng_root_file_free.len = bswap(free_nbytes_be);
// FIXME
// tfile_data.rng_root_file_free_header.len = root_file_info.free_header_nbytes;
tfile_data.rng_root_file_free.start = tfile_data.rng_root_file_free_header.end();
tfile_data.rng_root_file_free.len = bswap(free_nbytes_be) - tfile_data.rng_root_file_free_header.len;
return tfile_data;
}
@ -368,12 +373,22 @@ Section find_section(App_State &app, u64 off, i64 hilite_cluster = -1)
u64 rblob_sz = rdata.rblob_header_size; // @Incomplete
b8 hilite = false;
// TFile start
// TFile starting sections
u64 root_header_padding = tdata.rng_root_file_obj.start - tdata.root_file_header_size;
if (off < tdata.rng_root_file_obj.start) return { Sec_TFile_Header, { 0, tdata.root_file_header_size }, 0, root_header_padding, hilite };
if (tdata.rng_root_file_obj.start <= off && off < tdata.rng_root_file_obj.end()) return { Sec_TFile_Object, tdata.rng_root_file_obj, 0, 0, hilite };
if (tdata.rng_root_file_info.start <= off && off < tdata.rng_root_file_info.end()) return { Sec_TFile_Info, tdata.rng_root_file_info, 0, 0, hilite };
if (tdata.rng_root_file_free.start <= off && off < tdata.rng_root_file_free.end()) return { Sec_TFile_FreeList, tdata.rng_root_file_free, 0, 0, hilite };
if (off < tdata.rng_root_file_obj.start)
return { Sec_TFile_Header, { 0, tdata.root_file_header_size }, 0, root_header_padding, hilite };
if (tdata.rng_root_file_obj.start <= off && off < tdata.rng_root_file_obj.end())
return { Sec_TFile_Object, tdata.rng_root_file_obj, 0, 0, hilite };
// TFile ending sections
if (tdata.rng_root_file_info_header.start <= off && off < tdata.rng_root_file_info.end())
return { Sec_TFile_Info, tdata.rng_root_file_info, tdata.rng_root_file_info_header.len, 0, hilite };
if (tdata.rng_root_file_free_header.start <= off && off < tdata.rng_root_file_free.end()) {
printf("%lu\n", tdata.rng_root_file_free_header.len);
return { Sec_TFile_FreeList, tdata.rng_root_file_free, tdata.rng_root_file_free_header.len, 0, hilite };
}
/// Handle pages
{
@ -725,6 +740,18 @@ Sec_Hover_Info get_section_hover_info(Arena *arena, Section section, u64 off, co
;
} break;
case Sec_TFile_Info: {
hover_try_key(try_sec_hover, data, start)
|| try_sec_hover.range("Payload", section.range.len) // TODO: improve
;
} break;
case Sec_TFile_FreeList: {
hover_try_key(try_sec_hover, data, start)
|| try_sec_hover.range("Payload", section.range.len) // TODO: improve
;
} break;
default:;
}

View file

@ -46,7 +46,9 @@ struct TFile_Data {
u16 root_version_minor;
u16 root_version_patch;
u32 compression;
Byte_Range rng_root_file_info_header;
Byte_Range rng_root_file_info;
Byte_Range rng_root_file_free_header;
Byte_Range rng_root_file_free;
};

View file

@ -116,7 +116,7 @@ int main(int argc, char **argv)
app.ntpl_name = args.ntpl_name;
app.base_display_addr = args.start_addr;
app.tfile_data = get_tfile_data(app.inspected_file);
app.tfile_data = get_tfile_data(app.inspected_file, app.ntpl_name);
app.rndata = get_rntuple_data(arena, app.inspected_file, app.ntpl_name);
if (args.print_to_terminal) {

View file

@ -1068,9 +1068,9 @@ static size_t ComputeNumChunks(size_t nbytes, size_t maxChunkSize)
// PUBLIC INTERFACE
// =========================================================================================
Root_File_Info get_root_file_info(const char *fname, bool is_big_file)
Root_File_Info get_root_file_info(const char *fname, const char *ntplName, bool is_big_file)
{
RTFString fileName { fname };
RTFString fileNameStr { fname };
Root_File_Info fileInfo {};
RTFHeader header;
if (is_big_file)
@ -1078,16 +1078,24 @@ Root_File_Info get_root_file_info(const char *fname, bool is_big_file)
fileInfo.tfile_header_nbytes = header.GetSize();
fileInfo.tfile_obj_seek = 100; // kBEGIN
RTFKey fileHeader {
100, 0, RTFString{ "TFile" }, fileName, RTFString{},
sizeof(RTFFile) + fileName.GetSize() + RTFString{}.GetSize() + RTFUUID{}.GetSize()
100, 0, RTFString{"TFile"}, fileNameStr, RTFString{},
sizeof(RTFFile) + fileNameStr.GetSize() + RTFString{}.GetSize() + RTFUUID{}.GetSize()
};
fileInfo.tfile_obj_nbytes = fileHeader.GetSize();
fileInfo.version_seek = offsetof(RTFHeader, fVersion);
fileInfo.compression_seek = is_big_file ? offsetof(RTFHeader, fInfoLong.fCompress) : offsetof(RTFHeader, fInfoShort.fCompress);
fileInfo.info_seek_seek = is_big_file ? offsetof(RTFHeader, fInfoLong.fSeekInfo) : offsetof(RTFHeader, fInfoShort.fSeekInfo);
fileInfo.info_nbytes_seek = is_big_file ? offsetof(RTFHeader, fInfoLong.fNbytesInfo) : offsetof(RTFHeader, fInfoShort.fNbytesInfo);
RTFKey infoHeader {
0, 100, RTFString{"TList"}, RTFString{"StreamerInfo"}, RTFString{"Doubly linked list"}, 0
};
fileInfo.info_header_nbytes = infoHeader.GetSize();
fileInfo.free_seek_seek = is_big_file ? offsetof(RTFHeader, fInfoLong.fSeekFree) : offsetof(RTFHeader, fInfoShort.fSeekFree);
fileInfo.free_nbytes_seek = is_big_file ? offsetof(RTFHeader, fInfoLong.fNbytesFree) : offsetof(RTFHeader, fInfoShort.fNbytesFree);
RTFKey freeHeader {
0, 100, RTFString{kNTupleClassName}, RTFString{ntplName}, RTFString{}, sizeof(RTFNTuple) + sizeof(std::uint64_t)
};
fileInfo.free_header_nbytes = freeHeader.GetSize();
return fileInfo;
}

View file

@ -50,11 +50,13 @@ struct Root_File_Info {
std::uint64_t compression_seek;
std::uint64_t info_seek_seek;
std::uint64_t info_nbytes_seek;
std::uint64_t info_header_nbytes;
std::uint64_t free_seek_seek;
std::uint64_t free_nbytes_seek;
std::uint64_t free_header_nbytes;
};
Root_File_Info get_root_file_info(const char *fname, bool is_big_file);
Root_File_Info get_root_file_info(const char *fname, const char *ntplName, bool is_big_file);
class RMicroFileReader final {
public: