User forums > General (but related to Code::Blocks)
Code blocks using too much cpu
ollydbg:
Some debug realize that the parser go to an infinite loop around the file x86_ops_bit.h, and around line 133, which is in a macro definition.
--- Code: ---#define opBT(name, operation) \
static int opBT ## name ## _w_r_a16(uint32_t fetchdat) \
{ \
int tempc; \
uint16_t temp; \
\
fetch_ea_16(fetchdat); \
eaaddr += ((regs[reg].w / 16) * 2); eal_r = eal_w = 0; \
temp = geteaw(); if (abrt) return 0; \
tempc = (temp & (1 << (regs[reg].w & 15))) ? 1 : 0; \
temp operation (1 << (regs[reg].w & 15)); \
seteaw(temp); if (abrt) return 0; \
flags_rebuild(); \
if (tempc) flags |= C_FLAG; \
else flags &= ~C_FLAG; \
\
cycles -= 6; \
return 0; \
} \
static int opBT ## name ## _w_r_a32(uint32_t fetchdat) \
{ \
int tempc; \
uint16_t temp; \
\
fetch_ea_32(fetchdat); \
eaaddr += ((regs[reg].w / 16) * 2); eal_r = eal_w = 0; \
temp = geteaw(); if (abrt) return 0; \
tempc = (temp & (1 << (regs[reg].w & 15))) ? 1 : 0; \
temp operation (1 << (regs[reg].w & 15)); \
seteaw(temp); if (abrt) return 0; \
flags_rebuild(); \
if (tempc) flags |= C_FLAG; \
else flags &= ~C_FLAG; \
\
cycles -= 6; \
return 0; \
} \
static int opBT ## name ## _l_r_a16(uint32_t fetchdat) \
{ \
int tempc; \
uint32_t temp; \
\
fetch_ea_16(fetchdat); \
eaaddr += ((regs[reg].l / 32) * 4); eal_r = eal_w = 0; \
temp = geteal(); if (abrt) return 0; \
tempc = (temp & (1 << (regs[reg].l & 31))) ? 1 : 0; \
temp operation (1 << (regs[reg].l & 31)); \
seteal(temp); if (abrt) return 0; \
flags_rebuild(); \
if (tempc) flags |= C_FLAG; \
else flags &= ~C_FLAG; \
\
cycles -= 6; \
return 0; \
} \
static int opBT ## name ## _l_r_a32(uint32_t fetchdat) \
{ \
int tempc; \
uint32_t temp; \
\
fetch_ea_32(fetchdat); \
eaaddr += ((regs[reg].l / 32) * 4); eal_r = eal_w = 0; \
temp = geteal(); if (abrt) return 0; \
tempc = (temp & (1 << (regs[reg].l & 31))) ? 1 : 0; \
temp operation (1 << (regs[reg].l & 31)); \
seteal(temp); if (abrt) return 0; \
flags_rebuild(); \
if (tempc) flags |= C_FLAG; \
else flags &= ~C_FLAG; \
\
cycles -= 6; \
return 0; \
}
opBT(C, ^=)
opBT(R, &=~)
opBT(S, |=)
--- End code ---
And from the Parserthread, I see that the m_Str becomes a very big string, it becomes bigger and bigger in this infinite loop...
--- Code: ---[debug]> p m_Str
[debug]$3 = "int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int "...
[debug]>>>>>>cb_gdb:
$3 = "int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int "...
> p m_Str.size()
[debug]> p m_Str.size()
[debug]$4 = 131788
[debug]>>>>>>cb_gdb:
--- End code ---
But currently I don't find the deeper reason about this infinite loop.
ollydbg:
Also, those two values are surely wrong.
--- Code: ---[debug]> whatis m_RepeatReplaceCount
[debug]type = size_t
[debug]>>>>>>cb_gdb:
[debug]> output &m_RepeatReplaceCount
[debug](size_t *) 0x90d7d70>>>>>>cb_gdb:
[debug]> output m_RepeatReplaceCount
[debug]65898>>>>>>cb_gdb:
[debug]> whatis savedReplaceCount
[debug]type = int
[debug]>>>>>>cb_gdb:
[debug]> output &savedReplaceCount
[debug](int *) 0xe09fca8>>>>>>cb_gdb:
[debug]> output savedReplaceCount
[debug]65896>>>>>>cb_gdb:
--- End code ---
ollydbg:
I add some sanity check for macro expansion code in rev 9601, this avoid the infinite loop, please test and report back, thanks.
Conker:
Can you link me to the binary with that fix ?
ollydbg:
--- Quote from: Conker on January 29, 2014, 08:17:23 pm ---Can you link me to the binary with that fix ?
--- End quote ---
http://forums.codeblocks.org/index.php/topic,18853.0.html
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version