Debug Problems in CodeExtractor

In the process of using CodeExtractor to extract some basic blocks from the original function as a new function, I found the following problems:

  1. There are no symbol name of the extracted function in pdb file.
    While extracting the basic block, I used the “-g” option to generate the pdb file, but found that the final generated exe file and pdb file did not contain the symbol information of the extracted function. The reason for this problem is that the link type of the extracted function is InternalLinkage, and the linker will not save the symbol information of the function whose link type is InternalLinkage to the exe file and the pdb file. I also checked the inplementation of CodeExtractor, and found that the Linkage type of the extracted function is set to InternalLinkage. I think the linkage type of the extracted function should be the same as the origin function.
  2. When I used Visual Stuido to debug the final generated exe file, I found that the instructions in the extracted function could not correspond to the source code.
    I found that the reason for this problem was that the extracted function did not have a corresponding DISubprogram. When I set the DISubprogram of the original function to the extracted function, the problem was solved.