# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import os
import re
from contextlib import contextmanager
result.update(
{
- "source": make_source(filename, os.path.basename(filename)),
+ "source": make_source(filename),
"line": line,
}
)
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import os
-
# This is deprecated in 3.9, but required in older versions.
from typing import Optional
name += ", module " + objfile.username
filename = current_frame.filename()
if filename is not None:
- newframe["source"] = make_source(filename, os.path.basename(filename))
+ newframe["source"] = make_source(filename)
newframe["name"] = name
frames.append(newframe)
# Note that we do not calculate totalFrames here. Its absence
@in_gdb_thread
-def make_source(fullname, filename):
+def make_source(fullname, filename=None):
"""Return the Source for a given file name.
FULLNAME is the full name. This is used as the key.
- FILENAME is the base name.
+ FILENAME is the base name; if None (the default), then it is
+ computed from FULLNAME.
"""
global _source_map
if fullname in _source_map:
result = _source_map[fullname]
else:
+ if filename is None:
+ filename = os.path.basename(fullname)
+
result = {
"name": filename,
"path": fullname,