* Fix#1534: disable emulation if mmap(1G,RWX) fails
TL:DR: Unicorn Engine aborts if mmap(1G, RWX) fails, so we are doing a
best effort check if we can do such allocation before using it for the
first time and if we can't, we disable it.
* add mmap.close() call
* Fix vermin lint
* Update pwndbg/commands/context.py
* Refactor TLS module
- Replace unreliable `__errno_location()` trick with `pthread_self()` to acquire TLS address
- Consolidate heap heuristics checks about TLS within the `pwndbg.gdblib.tls` module for better organization
* Bug fix for the `errno` command
Calling `__errno_location()` without locking the scheduler can cause another thread to inadvertently continue execution
* Refactor code about heap heuristics of thread-local variables
- Replace some checks with some functions in `pwndbg.gdblib.tls`
- Try to find tcache with `mp_.sbrk_base + 0x10` if the target is single-threaded
* Add tests for heap heuristics with multi-threaded
* Refacotr scheduler-locking related functions
- Move these functions into `pwndbg.gdblib.scheduler`
- Fetch the parameter value once (https://github.com/pwndbg/pwndbg/pull/1536#discussion_r1082549746)
* Avoid bug caused by GLIBC_TUNABLES
See https://github.com/pwndbg/pwndbg/pull/1536#discussion_r1083202815
* Add note about `set scheduler-locking on`
* Add comment for `lock_scheduler`
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
* Update DEVELOPING.md
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
This fixes memoize when debug=True is set in pwndbg/lib/memoize.py
Before this commit, one gets the following error:
```
dc@jhtc:~$ gdb
Executed: <stop-memoized function pwndbg.ida.available>(())
.... False
Traceback (most recent call last):
File "/home/dc/pwndbg/gdbinit.py", line 100, in <module>
import pwndbg # noqa: F401
File "/home/dc/pwndbg/pwndbg/__init__.py", line 11, in <module>
load_commands()
File "/home/dc/pwndbg/pwndbg/commands/__init__.py", line 601, in load_commands
import pwndbg.commands.cymbol
File "/home/dc/pwndbg/pwndbg/commands/cymbol.py", line 53, in <module>
pwndbg_cachedir = pwndbg.lib.tempfile.cachedir("custom-symbols")
File "/home/dc/pwndbg/pwndbg/lib/memoize.py", line 52, in __call__
print("%s: %s(%r)" % (how, self, args))
File "/home/dc/pwndbg/pwndbg/lib/memoize.py", line 58, in __repr__
return "<%s-memoized function %s>" % (self.kind, funcname)
AttributeError: 'forever' object has no attribute 'kind'
/home/dc/.gdbinit:12: Error in sourced command file:
No symbol table is loaded. Use the "file" command.
```