<div dir="ltr"><div>Hi all,</div><div>sorry I forgot to mention that I understood that the LoadValueFromMemory would execute only:</div><div><br></div><div>case Type::PointerTyID:<br> Result.PointerVal = *((PointerTy*)Ptr);<br> break;</div><div><br></div><div>I think this should not be the case considering that Type I think is a Vector.</div><div><br></div><div>Thanks<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno mer 17 lug 2019 alle ore 20:41 Alberto Barbaro <<a href="mailto:barbaro.alberto@gmail.com">barbaro.alberto@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi all,</div><div>I'm trying to print to screen the value read by the fread function. I'm at the point where source refers to the GetElementPtrInst ( pointer to the buffer where fread stored the data - %5 in my case ) and the fread() has been already called.</div><div><br></div><div>I thought the correct approach to achieve what I need was:</div><div><br></div>ExecutionContext& SF = ECStack.back();<br> GenericValue SRC = getOperandValue(source, SF);<br> GenericValue* Ptr = (GenericValue*)GVTOP(SRC);<br> GenericValue Result;<br><br> source->getPointerOperand()->getType()->dump(); //[40 x i8]*<br> <br><div> LoadValueFromMemory(Result, Ptr, source->getPointerOperand()->getType());</div><div><br></div><div>and use Result.PointerVal ...<br></div><div><br></div><div>In the end I have the first 4 bytes within Result.PointrVal but I cannot see the other bytes.. Unfortunately also Result.AggregateVal has size 0.</div><div><br></div><div>Could you help me to understand why please?</div><div><br></div><div>The core part of the .ll is the following:</div><div><br></div><div>define i32 @main() #0 {<br> %1 = alloca i32, align 4<br> %2 = alloca %struct._IO_FILE*, align 8<br> %3 = alloca [40 x i8], align 16<br> store i32 0, i32* %1, align 4<br> %4 = call %struct._IO_FILE* @fopen(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0))<br> store %struct._IO_FILE* %4, %struct._IO_FILE** %2, align 8<br> <b> %5 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i32 0, i32 0</b><br> %6 = load %struct._IO_FILE*, %struct._IO_FILE** %2, align 8<br> <b>%7 = call i64 @fread(i8* %5, i64 30, i64 1, %struct._IO_FILE* %6)</b><br> %8 = load %struct._IO_FILE*, %struct._IO_FILE** %2, align 8<br> %9 = call i32 @fclose(%struct._IO_FILE* %8)<br> %10 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0<br> %11 = load i8, i8* %10, align 16<br> %12 = sext i8 %11 to i32<br> %13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i32 %12)<br> %14 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0<br> %15 = load i8, i8* %14, align 16<br> %16 = sext i8 %15 to i32<br> ret i32 %16<br>}</div><div><br></div><div>Thanks<br></div><div><br></div></div>
</blockquote></div>