* lldb: port version and bugreport commands + refactor
Port `version` and `bugreport` commands to LLDB.
Additionally, refactor them to provide better information and be less
bloated.
* fix lint
* fix lint
* fix lint
* lldb: add support for attaching via `attach <pid|name>`
This commit adds support for the `attach <pid|name>` command so that it
can attach to a pid or full process name similarly to as in LLDB.
Please note that this LLDB command is a bit confusing.
It may seem it is an alias for `process attach` as in here:
```
(lldb) attach -n -w htop
error: 'process attach' doesn't take any arguments.
```
However, in practice it is not. It is an alias for `_regexp-attach`:
```
(lldb) help attach
Attach to process by ID or name. Expects 'raw' input (see 'help raw-input'.)
Syntax: _regexp-attach <pid> | <process-name>
'attach' is an abbreviation for '_regexp-attach'
```
...which has its own problems:
1) it does not perform any regexp match in practice. passing `hto.*`,
`hto?` or `hto[p]` will not attach to `htop`. One must pass the full process name like `htop`.
2) it can work without arguments, which is stupid and we should not
support it?:
```
(lldb) _regexp-attach
There is a running process, detach from it and attach?: [Y/n] y
Process 56358 detached
Process 56358 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0x00007ff8118bedd2 libsystem_kernel.dylib`__select + 10
libsystem_kernel.dylib`__select:
-> 0x7ff8118bedd2 <+10>: jae 0x7ff8118beddc ; <+20>
0x7ff8118bedd4 <+12>: movq %rax, %rdi
0x7ff8118bedd7 <+15>: jmp 0x7ff8118b737b ; cerror
0x7ff8118beddc <+20>: retq
```
* fixup
* Update pwndbg/dbg/lldb/repl/__init__.py
Co-authored-by: Matt. <dark.ryu.550@gmail.com>
---------
Co-authored-by: Matt. <dark.ryu.550@gmail.com>
* Support for loongarch64. Add Loongarch64 register set definition, make a ManualPwndbgInstruction to define an instruction without a Capstone object underlying it, and detect Loongarch64 on GDB
* Update pwndbg/aglib/disasm/instruction.py
* Use Python Protocols to create an interface that the two PwndbgInstruction implementations conform to + make suggested changes
---------
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
- select a matching lexer based on filename only
- dramatically speeds up time of the first `context` when there is debug
source code that needs to be highlighted (3-4x speedup, from 0.8s to
0.2s on my machine)
- the only chance that a lexer can be selected wrong is when a plugin lexer
has the same filename pattern as a built-in lexer (in which case the
built-in lexer will always be used)
The output of the expressions section changes even when running `context` multiple times after each other. The output variables in GDB are counted up when reexecuting the watched commands for example. The other sections don't change their output. This caused the history to be extended infinitely when using `ctxp` while having a `cwatch` command executed.
Special case the `expressions` context section in the history handling to avoid reevaluating the watched commands/expressions while browsing the history. This doesn't add the context output to the history when the expressions VALUES change somehow like it is done for the other sections, but since we cannot know if gdb counted up their output variable names from $1 to $2 or the value changed, this is a compromise.