WinDBG/Exts/CodeAnalyzer/gdbplus/gdb-7.7/gdb/gdb_dep.c
/*
 * Get the value of the registers of the thread context
 * If buffer is NULL, return number of registers could be returned
 */
Get the value of the registers of the thread context
If buffer is NULL, return number of registers could be returned
Get the value of the registers of the thread context If buffer is NULL return number of registers could be returned
int read_registers(const struct ca_segment* segment, struct reg_value* regs, int bufsz)
{
	size_t ptr_sz = g_ptr_bit >> 3;
	struct gdbarch *gdbarch = get_current_arch();
	const int numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
	if (regs)
	{
		const struct thread_info *info = (const struct thread_info*) segment->m_thread.context;
		struct regcache *regcache = get_thread_regcache (info->ptid);
		if (regcache)
		{
			if (bufsz >= numregs)
			{
				int i;
				for (i=0; i<numregs; i++)
				{
					ULONGEST val;
					regs[i].reg_num = i;
					regs[i].reg_width = register_size(gdbarch, i);
					if (regs[i].reg_width <= ptr_sz
						&& regcache_cooked_read_unsigned (regcache, i, &val) == REG_VALID)
						regs[i].value = (address_t) val;
					else
						regs[i].value = 0;
				}
				return numregs;
			}
		}
	}
	else
		return numregs;
	return 0;
}
int read_registers ( const struct ca_segment * segment , struct reg_value * regs , int bufsz ) { size_t ptr_sz = g_ptr_bit >> 3 ; struct gdbarch * gdbarch = get_current_arch ( ) ; const int numregs = gdbarch_num_regs ( gdbarch ) + gdbarch_num_pseudo_regs ( gdbarch ) ; if ( regs ) { const struct thread_info * info = ( const struct thread_info * ) segment -> m_thread . context ; struct regcache * regcache = get_thread_regcache ( info -> ptid ) ; if ( regcache ) { if ( bufsz >= numregs ) { int i ; for ( i = 0 ; i < numregs ; i ++ ) { ULONGEST val ; regs [ i ] . reg_num = i ; regs [ i ] . reg_width = register_size ( gdbarch , i ) ; if ( regs [ i ] . reg_width <= ptr_sz && regcache_cooked_read_unsigned ( regcache , i , & val ) == REG_VALID ) regs [ i ] . value = ( address_t ) val ; else regs [ i ] . value = 0 ; } return numregs ; } } } else return numregs ; return 0 ; }
Get the value of the registers of the thread context
 If buffer is NULL, return number of registers could be returned
Get the value of the registers of the thread context If buffer is NULL return number of registers could be returned