Skip to content

Conversation

@mikem8361
Copy link
Contributor

Add "clrmaconfig" command to control clrma logging, direct DAC and managed support.

Move SOSExtensions to separate cpp/h files.

Cleanup Extensions::FlushCheck. Needed to call in the clrma code.

INIT_API_EXT macro cleanup: added ExtInit function that does all command entry init.

Change the no managed hosting fallback code (platform/*) to use the IDebuggerServices instance instead of the global dbgeng variables because it is always available/setup. This allows the CLRMA support to work with no managed code.

@mikem8361 mikem8361 requested review from hoyosjs and mdh1418 May 14, 2024 23:36
@mikem8361 mikem8361 self-assigned this May 14, 2024
@mikem8361 mikem8361 requested a review from a team as a code owner May 14, 2024 23:36
@mikem8361
Copy link
Contributor Author

@dotnet/dotnet-diag anybody up for a code review?

@mikem8361 mikem8361 requested a review from a team June 19, 2024 17:15
Copy link
Member

@tommcdon tommcdon left a comment

Choose a reason for hiding this comment

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

I left some comments for your review.

Mike McLaughlin added 16 commits June 28, 2024 11:46
Add "clrmaconfig" command to control clrma logging, direct DAC and managed support.

Move SOSExtensions to separate cpp/h files.

Cleanup Extensions::FlushCheck. Needed to call in the clrma code.

INIT_API_EXT macro cleanup: added ExtInit function that does all command entry init.

Change the no managed hosting fallback code (platform/*) to use the IDebuggerServices instance
instead of the global dbgeng variables because it is always available/setup. This allows the
CLRMA support to work with no managed code.
…::StackTraceEnabled flag; no longer needed.
using System.Text;

namespace Microsoft.Diagnostics.TestHelpers
namespace Microsoft.Diagnostics.DebugServices.Implementation
Copy link
Member

Choose a reason for hiding this comment

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

This was OK as test code, but I am not sure it properly handles multibyte sequences. Why is this needed? And why not just take line input as it and copy as-is? What breaks with line feeds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has always been used in the REPL console service. It deals with the .Write() of partial lines and turns them into full lines. It has been part of SOS for a long time; I used in the Midori debugger. When we have problems with multibyte UTF sequences, I'll fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like that it has been duplicated twice (once in REPL and this new one in the impl assembly) but we don't have a common utility assembly yet for things like this.

VTable.FlushCheck(Self);
}

public ImmutableArray<string> ExecuteHostCommand(string commandLine, DEBUG_OUTPUT interestMask = DEBUG_OUTPUT.NORMAL)
Copy link
Member

Choose a reason for hiding this comment

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

Any reason we are opting for ImmutableArray here over say IReadOnlyList? Is there anything that depends on CoW semmantics?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What CoW (I assume you mean copy-on-write) semantics does ImmutableArray have? I just want an array that the elements can't be changed/written. Why would IReadOnlyList be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I see now. List already implements IReadOnlyList and no copying/conversion would have to happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change it to IReadOnlyList.

Copy link
Member

Choose a reason for hiding this comment

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

ImmutableArray allows you to write - and it just allocates a new array. It just doesn't modify the old one. Things like https://learn.microsoft.com/en-us/dotnet/api/system.collections.immutable.immutablearray-1.add?view=net-8.0. So if I don't expect that to be a concern - I just prefer IReadOnly...

Copy link
Contributor

Choose a reason for hiding this comment

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

ImmutableArrays have lower overhead than IReadOnlyList, or other similar constructs.

IMO though, it actually wasn't worthwhile to use ImmutableArray in ClrMD. The dependency alone is a headache to maintain (as you see from our conversation about 6.0 vs 8.0), the perf benefit isn't noticeable (especially in something as slow as debugging), and the contract guarantees of immutability don't make things easier. In retrospect, just returning ClrModule[] instead of ImmutableArray<ClrModule> would have been fine. But that ship has sailed for ClrMD to make that big of a change without a lot of churn.

Avoiding immutable is a good decision. Even just returning raw arrays is conditionally fine, if it doesn't hurt anything if a user decides to modify one. Just my 2 cents.

@mikem8361 mikem8361 merged commit c71692f into dotnet:main Jul 2, 2024
@mikem8361 mikem8361 deleted the clrma branch July 2, 2024 22:18
@github-actions github-actions bot locked and limited conversation to collaborators Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants