From d3583b8360071725f525f292e8aeafa1f867a341 Mon Sep 17 00:00:00 2001 From: Bill Holmes Date: Wed, 24 Jan 2024 10:44:07 -0500 Subject: [PATCH] Fix source_file bug in mono_ppdb_lookup_location_internal (#97392) document-records affect sequence points that follow in the byte stream, not points previously read. When reading the document-record we may already be at the target offset. Do not update docname local if we have reached the end target already otherwise the wrong source_file will be reported for the requested offset --- src/mono/mono/metadata/debug-mono-ppdb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/metadata/debug-mono-ppdb.c b/src/mono/mono/metadata/debug-mono-ppdb.c index 9c675af4dc7..545e5713f45 100644 --- a/src/mono/mono/metadata/debug-mono-ppdb.c +++ b/src/mono/mono/metadata/debug-mono-ppdb.c @@ -409,7 +409,10 @@ mono_ppdb_lookup_location_internal (MonoImage *image, int idx, uint32_t offset, if (!first && delta_il == 0) { /* document-record */ docidx = mono_metadata_decode_value (ptr, &ptr); - docname = get_docname (ppdb, image, docidx); + // check the current iloffset to ensure that we do not update docname after the target + // offset has been reached (the updated docname will be for the next sequence point) + if (iloffset < offset) + docname = get_docname (ppdb, image, docidx); continue; } if (!first && iloffset + delta_il > offset)