Skip to content
This repository was archived by the owner on Mar 15, 2022. It is now read-only.

Conversation

@sandreenko
Copy link

Fix problem with lldb debugging.

So after this fix we emit correct attributes for function symbols and sections.
The corresponding CoreRT PR .

Some examples:

(lldb) breakpoint set --file Hello.cs --line 14
Breakpoint 1: where = Hello`Hello_Hello_Program__Main, address = 0x00000000005366a4
(lldb) r
Process 9580 launched: '/home/sergey/git/corert/tests/src/Simple/Hello/bin/Debug/x64/native/Hello' (x86_64)
Process 9580 stopped
* thread #1, name = 'Hello', stop reason = breakpoint 1.1
    frame #0: 0x00000000005366a4 Hello`Hello_Hello_Program__Main at Hello.cs:14
   11  	    internal class Program
   12  	    {
   13  	        private static void Main(string[] args)
-> 14  	        {
   15  	            if (args.Length == 0)
   16  	            {
   17  	                Console.WriteLine("Usage: hello name");


(gdb) break Hello.cs:15
Breakpoint 1 at 0x5366bc: file /home/sergey/git/corert/tests/src/Simple/Hello/Hello.cs, line 15.
(gdb) r
Starting program: /home/sergey/git/corert/tests/src/Simple/Hello/bin/Debug/x64/native/Hello 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffdcbdd700 (LWP 9651)]

Breakpoint 1, Hello_Hello_Program__Main () at /home/sergey/git/corert/tests/src/Simple/Hello/Hello.cs:15
15	            if (args.Length == 0)
(gdb) 


(lldb) breakpoint set --name Hello_Hello_Program__Main
Breakpoint 1: where = Hello`Hello_Hello_Program__Main + 24, address = 0x00000000005366bc

There is problem with image --lookup output, it doesn't show source line for address, but it will be fixed in the other PR.

Also I want to rename all variables in camel case. gcc doesn't allow to name variables as types (TargetMachine TargetMachine; ) and it creates many problems. So I want to use the same naming rules as CoreCLR and CoreRT.

@sandreenko
Copy link
Author

PTAL @nattress @AndyAyersMS

@JosephTremoulet
Copy link
Contributor

Also I want to rename all variables in camel case. gcc doesn't allow to name variables as types (TargetMachine TargetMachine; ) and it creates many problems. So I want to use the same naming rules as CoreCLR and CoreRT.

FYI, a number of places in the codebase (and in LLVM) dodge this by prefixing with "The" (TargetMachine TheTargetMachine;). I'm not concerned whether you do it that way or camlCase as you suggest, just wanted to mention it for consideration.

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be helpful if for something like this you could describe a bit more about what was wrong before you made these changes, eg "elf/dwarf requires xxx ..."

Also would appreciate seeing reformatting/renaming changes done as separate PRs instead of mixing them in with functional changes. I see you kept them as separate commits but separate PRs is even better.

MCAsmBackend *AsmBackend; // Owned by MCStreamer
std::unique_ptr<MCInstrInfo> InstrInfo;
std::unique_ptr<MCSubtargetInfo> SubtargetInfo;
MCCodeEmitter *CodeEmmiter; // Owned by MCStreamer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: name should be CodeEmitter

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

if (!Section->getBeginSymbol()) { // Is it set for default sections?
MCSymbol *SectionStartSym = OutContext->createTempSymbol();
Streamer->EmitLabel(SectionStartSym);
Section->setBeginSymbol(SectionStartSym);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand what this does.

Do we ever refer to this temp symbol anywhere else? If so, you should leave a comment indicating where.

If not, why do we need it create it at all?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: I checked it again. We need this symbols for DWARF only. They are used as base symbols when we emit debug locations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So are you adding it back? Fixing it some other way?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this symbols and they are used in dwarf for EmitLabelPlusOffset, where label is our beginSymbol.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like that would make a good code comment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@sandreenko
Copy link
Author

FYI, a number of places in the codebase (and in LLVM) dodge this by prefixing with "The" (TargetMachine TheTargetMachine;). I'm not concerned whether you do it that way or camlCase as you suggest, just wanted to mention it for consideration.

Yes, it is possible variant, but it kills all advantages of intellisense because all variables start with the same prefix. But I will be happy with any decision.

@sandreenko sandreenko force-pushed the debug-function-symbols-for-non-windows branch 2 times, most recently from 4beffb3 to e7eda35 Compare February 28, 2017 01:15
Sergey Andreenko added 3 commits February 27, 2017 17:48
Use fields instead of getting context and streamer from AsmPrinter each time.

It allows to write small functions.
@sandreenko sandreenko force-pushed the debug-function-symbols-for-non-windows branch from e7eda35 to 1253cac Compare February 28, 2017 03:08
@AndyAyersMS
Copy link
Member

Latest version LGTM.

@sandreenko sandreenko force-pushed the debug-function-symbols-for-non-windows branch from 1253cac to 5054ea5 Compare March 2, 2017 19:17
@sandreenko sandreenko merged commit 1930a54 into dotnet:ObjectWriter Mar 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants