Put guards in place around debug heap operations (#7955)
* Put guards in place around debug heap operations * Add macros to clean up code * Add pointer as well
This commit is contained in:
@@ -193,11 +193,9 @@ void MeshService::handleToRadio(meshtastic_MeshPacket &p)
|
||||
// (so we update our nodedb for the local node)
|
||||
|
||||
// Send the packet into the mesh
|
||||
auto heapBefore = memGet.getFreeHeap();
|
||||
DEBUG_HEAP_BEFORE;
|
||||
auto a = packetPool.allocCopy(p);
|
||||
auto heapAfter = memGet.getFreeHeap();
|
||||
LOG_HEAP("Alloc in MeshService::handleToRadio() pointer 0x%x, size: %u, free: %u", a, heapBefore - heapAfter, heapAfter);
|
||||
|
||||
DEBUG_HEAP_AFTER("MeshService::handleToRadio", a);
|
||||
sendToMesh(a, RX_SRC_USER);
|
||||
|
||||
bool loopback = false; // if true send any packet the phone sends back itself (for testing)
|
||||
@@ -254,10 +252,9 @@ void MeshService::sendToMesh(meshtastic_MeshPacket *p, RxSource src, bool ccToPh
|
||||
}
|
||||
|
||||
if ((res == ERRNO_OK || res == ERRNO_SHOULD_RELEASE) && ccToPhone) { // Check if p is not released in case it couldn't be sent
|
||||
auto heapBefore = memGet.getFreeHeap();
|
||||
DEBUG_HEAP_BEFORE;
|
||||
auto a = packetPool.allocCopy(*p);
|
||||
auto heapAfter = memGet.getFreeHeap();
|
||||
LOG_HEAP("Alloc in MeshService::sendToMesh() pointer 0x%x, size: %u, free: %u", a, heapBefore - heapAfter, heapAfter);
|
||||
DEBUG_HEAP_AFTER("MeshService::sendToMesh", a);
|
||||
|
||||
sendToPhone(a);
|
||||
}
|
||||
|
||||
@@ -22,10 +22,9 @@ ErrorCode ReliableRouter::send(meshtastic_MeshPacket *p)
|
||||
if (p->hop_limit == 0) {
|
||||
p->hop_limit = Default::getConfiguredOrDefaultHopLimit(config.lora.hop_limit);
|
||||
}
|
||||
auto heapBefore = memGet.getFreeHeap();
|
||||
DEBUG_HEAP_BEFORE;
|
||||
auto copy = packetPool.allocCopy(*p);
|
||||
auto heapAfter = memGet.getFreeHeap();
|
||||
LOG_HEAP("Alloc in ReliableRouter::send() pointer 0x%x, size: %u, free: %u", copy, heapBefore - heapAfter, heapAfter);
|
||||
DEBUG_HEAP_AFTER("ReliableRouter::send", copy);
|
||||
|
||||
startRetransmission(copy, NUM_RELIABLE_RETX);
|
||||
}
|
||||
|
||||
+5
-7
@@ -276,11 +276,9 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
|
||||
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
|
||||
ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it
|
||||
|
||||
auto heapBefore = memGet.getFreeHeap();
|
||||
DEBUG_HEAP_BEFORE;
|
||||
meshtastic_MeshPacket *p_decoded = packetPool.allocCopy(*p);
|
||||
auto heapAfter = memGet.getFreeHeap();
|
||||
|
||||
LOG_HEAP("Alloc in Router::send pointer 0x%x, size: %u, free: %u", p_decoded, heapBefore - heapAfter, heapAfter);
|
||||
DEBUG_HEAP_AFTER("Router::send", p_decoded);
|
||||
|
||||
auto encodeResult = perhapsEncode(p);
|
||||
if (encodeResult != meshtastic_Routing_Error_NONE) {
|
||||
@@ -612,11 +610,11 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
|
||||
bool skipHandle = false;
|
||||
// Also, we should set the time from the ISR and it should have msec level resolution
|
||||
p->rx_time = getValidTime(RTCQualityFromNet); // store the arrival timestamp for the phone
|
||||
|
||||
// Store a copy of encrypted packet for MQTT
|
||||
auto heapBefore = memGet.getFreeHeap();
|
||||
DEBUG_HEAP_BEFORE;
|
||||
meshtastic_MeshPacket *p_encrypted = packetPool.allocCopy(*p);
|
||||
auto heapAfter = memGet.getFreeHeap();
|
||||
LOG_HEAP("Alloc in Router::handleReceived pointer 0x%x, size: %u, free: %u", p_encrypted, heapBefore - heapAfter, heapAfter);
|
||||
DEBUG_HEAP_AFTER("Router::handleReceived", p_encrypted);
|
||||
|
||||
// Take those raw bytes and convert them back into a well structured protobuf we can understand
|
||||
auto decodedState = perhapsDecode(p);
|
||||
|
||||
Reference in New Issue
Block a user