@@ -2241,38 +2241,68 @@ R"(
22412241// =========================================================================
22422242// GDB Offset Export - Global Symbols
22432243// These symbols are directly readable by GDB, no separate tool needed.
2244- // GDB Python script reads: gdb.parse_and_eval("gdb_thread_offset_vcpu ")
2244+ // GDB Python script reads: gdb.parse_and_eval("gdb_offsets ")
22452245// =========================================================================
22462246
2247- // Export as C symbols to avoid name mangling
2248- extern " C" {
2249-
2250- // Thread structure offsets
2251- [[gnu::used]] const size_t gdb_thread_size = sizeof (photon::thread);
2252- [[gnu::used]] const size_t gdb_thread_offset_prev = 0 ;
2253- [[gnu::used]] const size_t gdb_thread_offset_next = sizeof (void *);
2254- [[gnu::used]] const size_t gdb_thread_offset_vcpu = offsetof(photon::thread, vcpu);
2255- [[gnu::used]] const size_t gdb_thread_offset_stack_ptr = offsetof(photon::thread, stack);
2256- [[gnu::used]] const size_t gdb_thread_offset_idx = offsetof(photon::thread, idx);
2257- [[gnu::used]] const size_t gdb_thread_offset_error_number = offsetof(photon::thread, error_number);
2258- [[gnu::used]] const size_t gdb_thread_offset_waitq = offsetof(photon::thread, waitq);
2259- [[gnu::used]] const size_t gdb_thread_offset_flags = offsetof(photon::thread, flags);
2260- [[gnu::used]] const size_t gdb_thread_offset_state = offsetof(photon::thread, state);
2261- [[gnu::used]] const size_t gdb_thread_offset_ts_wakeup = offsetof(photon::thread, ts_wakeup);
2262- [[gnu::used]] const size_t gdb_thread_offset_tls = offsetof(photon::thread, tls);
2263- [[gnu::used]] const size_t gdb_thread_offset_buf = offsetof(photon::thread, buf);
2264- [[gnu::used]] const size_t gdb_thread_offset_stack_size = offsetof(photon::thread, stack_size);
2265-
2266- // vCPU structure offsets
2267- [[gnu::used]] const size_t gdb_vcpu_size = sizeof (photon::vcpu_t );
2268- [[gnu::used]] const size_t gdb_vcpu_offset_sleepq = offsetof(photon::vcpu_t , sleepq);
2269- [[gnu::used]] const size_t gdb_vcpu_offset_nthreads = offsetof(photon::vcpu_t , nthreads);
2270- [[gnu::used]] const size_t gdb_vcpu_offset_idle_worker = offsetof(photon::vcpu_t , idle_worker);
2271- [[gnu::used]] const size_t gdb_vcpu_offset_standbyq = offsetof(photon::vcpu_t , standbyq);
2272- [[gnu::used]] const size_t gdb_vcpu_offset_list_node_prev = offsetof(photon::vcpu_t , __prev_ptr);
2273- [[gnu::used]] const size_t gdb_vcpu_offset_list_node_next = offsetof(photon::vcpu_t , __next_ptr);
2274-
2275- // Pointer size for architecture detection
2276- [[gnu::used]] const size_t gdb_pointer_size = sizeof (void *);
2277-
2278- } // extern "C"
2247+ // All offsets in a single struct for easy access
2248+ struct GDBOffsets {
2249+ // Version number for compatibility checking
2250+ // Increment when adding/removing/modifying/reordering offset fields
2251+ uint32_t version;
2252+ uint32_t _reserved; // Padding for alignment
2253+
2254+ // Thread structure
2255+ size_t thread_size;
2256+ size_t thread_offset_prev;
2257+ size_t thread_offset_next;
2258+ size_t thread_offset_vcpu;
2259+ size_t thread_offset_stack_ptr;
2260+ size_t thread_offset_idx;
2261+ size_t thread_offset_error_number;
2262+ size_t thread_offset_waitq;
2263+ size_t thread_offset_flags;
2264+ size_t thread_offset_state;
2265+ size_t thread_offset_ts_wakeup;
2266+ size_t thread_offset_tls;
2267+ size_t thread_offset_buf;
2268+ size_t thread_offset_stack_size;
2269+
2270+ // vCPU structure
2271+ size_t vcpu_size;
2272+ size_t vcpu_offset_sleepq;
2273+ size_t vcpu_offset_nthreads;
2274+ size_t vcpu_offset_idle_worker;
2275+ size_t vcpu_offset_standbyq;
2276+ size_t vcpu_offset_list_node_prev;
2277+ size_t vcpu_offset_list_node_next;
2278+ };
2279+
2280+ extern " C" const GDBOffsets gdb_offsets = {
2281+ .version = 1 ,
2282+ ._reserved = 0 ,
2283+
2284+ // Thread structure
2285+ .thread_size = sizeof (photon::thread),
2286+ .thread_offset_prev = 0 ,
2287+ .thread_offset_next = sizeof (void *),
2288+ .thread_offset_vcpu = offsetof (photon::thread, vcpu),
2289+ .thread_offset_stack_ptr = offsetof (photon::thread, stack),
2290+ .thread_offset_idx = offsetof (photon::thread, idx),
2291+ .thread_offset_error_number = offsetof (photon::thread, error_number),
2292+ .thread_offset_waitq = offsetof (photon::thread, waitq),
2293+ .thread_offset_flags = offsetof (photon::thread, flags),
2294+ .thread_offset_state = offsetof (photon::thread, state),
2295+ .thread_offset_ts_wakeup = offsetof (photon::thread, ts_wakeup),
2296+ .thread_offset_tls = offsetof (photon::thread, tls),
2297+ .thread_offset_buf = offsetof (photon::thread, buf),
2298+ .thread_offset_stack_size = offsetof (photon::thread, stack_size),
2299+
2300+ // vCPU structure
2301+ .vcpu_size = sizeof (photon::vcpu_t ),
2302+ .vcpu_offset_sleepq = offsetof (photon::vcpu_t , sleepq),
2303+ .vcpu_offset_nthreads = offsetof (photon::vcpu_t , nthreads),
2304+ .vcpu_offset_idle_worker = offsetof (photon::vcpu_t , idle_worker),
2305+ .vcpu_offset_standbyq = offsetof (photon::vcpu_t , standbyq),
2306+ .vcpu_offset_list_node_prev = offsetof (photon::vcpu_t , __prev_ptr),
2307+ .vcpu_offset_list_node_next = offsetof (photon::vcpu_t , __next_ptr),
2308+ };
0 commit comments