Repository: pwndbg/pwndbg

Issue:
Generating configfile with modifed context-sections fails
### Description

Trying to generate a configfile when changing context-sections produces error.

### Steps to reproduce

Happens with no binary loaded

Gdb session history:
```
set context-sections ''
configfile
```


With exception-verbose on:
```
pwndbg> configfile
Showing only changed values:
# context-sections: which context sections are displayed (controls order)
Traceback (most recent call last):
  File "/home/rene/tempenis/pwndbg/pwndbg/commands/__init__.py", line 184, in __call__
    return self.function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rene/tempenis/pwndbg/pwndbg/commands/config.py", line 127, in configfile
    configfile_print_scope("config", show_all)
  File "/home/rene/tempenis/pwndbg/pwndbg/commands/config.py", line 154, in configfile_print_scope
    print("# default: %s" % p.native_default)
                            ^^^^^^^^^^^^^^^^
  File "/home/rene/tempenis/pwndbg/pwndbg/lib/config.py", line 64, in __getattr__
    return getattr(self.value, name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'native_default'

If that is an issue, you can report it on https://github.com/pwndbg/pwndbg/issues
(Please don't forget to search if it hasn't been reported before)
To generate the report and open a browser, you may run `bugreport --run-browser`
PS: Pull requests are welcome
pwndbg>
```
### My setup

```
Platform: Linux-6.1.0-3-amd64-x86_64-with-glibc2.36
Gdb:      12.1
Python:   3.11.1 (main, Dec 31 2022, 10:23:59) [GCC 12.2.0]
Pwndbg:   1.1.1 build: 47e4e09
Capstone: 4.0.1024
Unicorn:  2.0.1
This GDB was configured as follows:
   configure --host=x86_64-linux-gnu --target=x86_64-linux-gnu
	     --with-auto-load-dir=$debugdir:$datadir/auto-load
	     --with-auto-load-safe-path=$debugdir:$datadir/auto-load
	     --with-expat
	     --with-gdb-datadir=/usr/share/gdb (relocatable)
	     --with-jit-reader-dir=/usr/lib/gdb (relocatable)
	     --without-libunwind-ia64
	     --with-lzma
	     --with-babeltrace
	     --with-intel-pt
	     --with-mpfr
	     --with-xxhash
	     --with-python=/usr (relocatable)
	     --with-python-libdir=/usr/lib (relocatable)
	     --with-debuginfod
	     --without-guile
	     --enable-source-highlight
	     --with-separate-debug-dir=/usr/lib/debug (relocatable)
	     --with-system-gdbinit=/etc/gdb/gdbinit
	     --with-system-gdbinit-dir=/etc/gdb/gdbinit.d

("Relocatable" means the directory can be moved with the GDB installation
tree, and GDB will still find it.)

```


Discussion:
Looks like #1568 fixes this issue.

Resolving patch:
diff --git a/pwndbg/commands/config.py b/pwndbg/commands/config.py
--- a/pwndbg/commands/config.py
+++ b/pwndbg/commands/config.py
@@ -150,9 +150,15 @@ def configfile_print_scope(scope, show_all=False) -> None:
         if not show_all:
             print(hint("Showing only changed values:"))
         for p in params:
+            native_default = pwndbg.gdblib.config_mod.Parameter._value_to_gdb_native(
+                p.default, param_class=p.param_class
+            )
+            native_value = pwndbg.gdblib.config_mod.Parameter._value_to_gdb_native(
+                p.value, param_class=p.param_class
+            )
             print("# %s: %s" % (p.name, p.set_show_doc))
-            print("# default: %s" % p.native_default)
-            print("set %s %s" % (p.name, p.native_value))
+            print("# default: %s" % native_default)
+            print("set %s %s" % (p.name, native_value))
             print()
     else:
         print(hint("No changed values. To see current values use `%s`." % scope))


Test patch: