Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print thread id that belong to arena #1562

Closed
yooo1999 opened this issue Feb 2, 2023 · 5 comments
Closed

Print thread id that belong to arena #1562

yooo1999 opened this issue Feb 2, 2023 · 5 comments
Labels
feature For new features heap

Comments

@yooo1999
Copy link

yooo1999 commented Feb 2, 2023

arena print that struct

struct MallocState {
  int mutex;
  int flags;
  int have_fastchunks;
  pvoid_Array_10 fastbinsY;
  pvoid top;
  pvoid last_remainder;
  pvoid_Array_254 bins;
  int_Array_4 binmap;
  pvoid next;
  pvoid next_free;
  size_t attached_threads;
  size_t system_mem;
  size_t max_system_mem;
}
struct MallocState pwndbg_MallocState;

I offer to print the thread id that belong to that arena ( attached_threads print only the thread count )

@yooo1999 yooo1999 added the feature For new features label Feb 2, 2023
@CptGibbon CptGibbon added the heap label Feb 2, 2023
@CptGibbon
Copy link
Collaborator

Sounds useful 👍
Perhaps printing something like "Arena for thread N:" before the struct is dumped.
I suppose it would only work when no address argument was passed, at least not without doing a lot more legwork to tie an arena to a thread.

@yooo1999
Copy link
Author

yooo1999 commented Feb 2, 2023

Arena for thread N: sounds great

@disconnect3d
Copy link
Member

Which number do we care about here? I guess the GDB's thread identifier?

Variable: InferiorThread.num
The per-inferior number of the thread, as assigned by GDB.

Variable: InferiorThread.global_num
The global ID of the thread, as assigned by GDB. You can use this to make Python breakpoints thread-specific, for example (see [The Breakpoint.thread attribute](https://sourceware.org/gdb/onlinedocs/gdb/Breakpoints-In-Python.html#python_005fbreakpoint_005fthread)).

Variable: InferiorThread.ptid
ID of the thread, as assigned by the operating system. This attribute is a tuple containing three integers. The first is the Process ID (PID); the second is the Lightweight Process ID (LWPID), and the third is the Thread ID (TID). Either the LWPID or TID may be 0, which indicates that the operating system does not use that identifier.

(via https://sourceware.org/gdb/onlinedocs/gdb/Threads-In-Python.html)

@yooo1999
Copy link
Author

yooo1999 commented Feb 8, 2023

@disconnect3d GDB's thread identifier will be great.
Linux's thread identifier will be the best :)

@disconnect3d
Copy link
Member

Done in #1583

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature For new features heap
Development

No branches or pull requests

3 participants