Repository: pwndbg/pwndbg

Issue:
"'function' object has no attribute '_reset'" in `pwndbg/pwndbg/color/syntax_highlight.py`
<!--
Before reporting a new issue, make sure that we do not have any duplicates already open.
If there is one it might be good to take part in the discussion there.

Please make sure you have checked that the issue persists on LATEST pwndbg version.

Below is a template for BUG REPORTS.
Don't include it if this is a FEATURE REQUEST.
-->


### Description

using latest dev branch, with `set syntax-highlight-style solarized-light` param, above error will be thrown

```bash
$ gdb ~/matrix-matrix-multiply/build/src/dgemm -ex 'start' -ex ''
pwndbg: loaded 141 pwndbg commands and 42 shell commands. Type pwndbg [--shell | --all] [filter] for a list.
pwndbg: created $rebase, $ida GDB functions (can be used with print/break)
Traceback (most recent call last):
  File "/home/czg/pwndbg/pwndbg/gdblib/config.py", line 93, in __get_set_string_gdb_gte_9
    trigger()
  File "/home/czg/pwndbg/pwndbg/color/syntax_highlight.py", line 37, in check_style
    get_highlight_source._reset()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'function' object has no attribute '_reset'
/home/czg/.gdbinit:19: Error in sourced command file:
Error occurred in Python: 'function' object has no attribute '_reset'
```

when I read `$ git log -p pwndbg/commands/context.py` I found nothing about `_reset`, but the error only exists after I upgrade python from `3.10` to `3.11.3` and pwndbg recently.

<!--
Briefly describe the problem you are having in a few paragraphs.
-->

<!--
### Steps to reproduce
-->

<!--
What do we have to do to reproduce the problem?
If this is connected to particular C/asm code, 
please provide the smallest C code that reproduces the issue.
-->

<!--
### My setup
-->

<!--
Show us your gdb/python/pwndbg/OS/IDA Pro version (depending on your case).

NOTE: We are currently supporting only Ubuntu installations.
It is known that pwndbg is not fully working e.g. on Arch Linux (the heap stuff is not working there).
If you would like to change this situation - help us improving pwndbg and supporting other distros!

This can be displayed in pwndbg through `version` command.

If it is somehow unavailable, use:
* `show version` - for gdb
* `py import sys; print(sys.version)` - for python
* pwndbg version/git commit id
-->



Discussion:
The `_reset` was a method to clear a cache for a given function; this method name was changed with recent caching rewrite.

This should be changed as:
```diff
- get_highlight_source._reset()
+ get_highlight_source.cache.clear()
```

Resolving patch:
diff --git a/pwndbg/color/syntax_highlight.py b/pwndbg/color/syntax_highlight.py
--- a/pwndbg/color/syntax_highlight.py
+++ b/pwndbg/color/syntax_highlight.py
@@ -34,7 +34,7 @@ def check_style() -> None:
         # Reset the highlighted source cache
         from pwndbg.commands.context import get_highlight_source
 
-        get_highlight_source._reset()
+        get_highlight_source.cache.clear()
     except pygments.util.ClassNotFound:
         print(
             message.warn(f"The pygment formatter style '{style}' is not found, restore to default")


Test patch: