[if gte mso 9]>
Subject: Re: [edk2] ASSERT Divisor != 0 Ia32
From: Evan Lloyd <Evan.Lloyd@arm.com>
To: "firstname.lastname@example.org" <email@example.com>
Date: 2012-01-06 17:36:41
You do not give the actual code of your macros, but I’d suggest trying:
#define macro1(a,b) ((a) / (b))
#define macro2(a,b) ((a) % (b))
which will at least eliminate one possible cause.
I wrote a device driver for edk2 which was tested using Ovmf on an X64 system.
Now for $insert_random_reason I switched to a 32 bit system and I began to receive errors due to missing __udivdi3 and __umoddi3. Went ahead and copied udivdi3.S/umoddi3.S from StdLib/LibC/CRT/Ia32 along with Gcc.c from StdLib/LibC/CRT and added Gcc.c | GCC to my .inf file.
Everything is fine and dandy except that I get
__udivdi3: 1 0 //somewhere there is a call to udivdi3 with arguments 1 and 0
ASSERT ...tianocore/edk2/MdePkg/Library/BaseLib/DivU64x64Remainder.c(47): Divisor != 0
There are 3 uses of division in my project in two macros. Let's say
#define macro1(a,b) (a) / (b)
#define macro2(a,b) (a) % (b)
Using DEBUG((EFI_D_INFO ...)) since I couldn't find any other way of debugging on Ovmf (if there's a better way please point me in the right direction) I tracked down a section of code after which no other messages are displayed.
OldTpl = gBS->RaiseTPL (TPL_CALLBACK); //with or without same result
macro1(a,b) // fine
macro2(a,b) // fine
DEBUG((mesage2)) //not displayed instead the ASSERT kicks in
If I go into func and place a DEBUG message as the first thing to do after being call it is not displayed. So this is really puzzling to me.
Is there a chance that a call to func can divide by 0? Am I misusing udivdi3.S/umoddi3.S? Any way that I can get a backtrace from __udivdi3?